This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 268772
Collapse All | Expand All

(-)a/dlight.remote.impl/src/org/netbeans/modules/remote/impl/fileoperations/spi/RemoteVcsSupportUtil.java (+30 lines)
Lines 433-436 Link Here
433
            }
433
            }
434
        }
434
        }
435
    }
435
    }
436
    
437
    private static boolean isForbiddenFolderImpl(RemoteFileSystem rfs, String path) {
438
        if (path.isEmpty()) {
439
            return true;
440
        } else if (rfs.isAutoMount(path)) {
441
            return true;
442
        } else if(rfs.isProhibitedToEnter(path)) {
443
            return true;
444
        }
445
        return false;
446
    }
447
    
448
    public static boolean isForbiddenFolder(FileSystem fs, String path) {
449
        if (fs instanceof RemoteFileSystem) {
450
            RemoteFileSystem rfs = (RemoteFileSystem) fs;
451
            if (isForbiddenFolderImpl(rfs, path)) {
452
                return true;
453
            }
454
            int pos = path.lastIndexOf('/');
455
            if (pos >= 0) {
456
                String parent = path.substring(0, pos);
457
                if (isForbiddenFolderImpl(rfs, parent)) {
458
                    return true;
459
                }
460
            }
461
            return false;
462
            //return rfs.isAutoMount(path);
463
        }
464
        return false;
465
    }
436
}
466
}
(-)a/git.remote/src/org/netbeans/modules/git/remote/Git.java (-1 / +1 lines)
Lines 371-377 Link Here
371
                break;
371
                break;
372
            }
372
            }
373
            // is the folder a special one where metadata should not be looked for?
373
            // is the folder a special one where metadata should not be looked for?
374
            boolean forbiddenFolder = Utils.isForbiddenFolder(file.getPath());
374
            boolean forbiddenFolder = org.netbeans.modules.versioning.core.util.Utils.isForbiddenFolder(file);
375
            if (!forbiddenFolder && GitUtils.repositoryExistsFor(file)) {
375
            if (!forbiddenFolder && GitUtils.repositoryExistsFor(file)) {
376
                if (LOG.isLoggable(Level.FINE)) {
376
                if (LOG.isLoggable(Level.FINE)) {
377
                    LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
377
                    LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
(-)a/git/src/org/netbeans/modules/git/Git.java (-1 / +1 lines)
Lines 331-337 Link Here
331
            }
331
            }
332
            if (!noExceptions && VersioningSupport.isExcluded(file)) break;
332
            if (!noExceptions && VersioningSupport.isExcluded(file)) break;
333
            // is the folder a special one where metadata should not be looked for?
333
            // is the folder a special one where metadata should not be looked for?
334
            boolean forbiddenFolder = Utils.isForbiddenFolder(file.getAbsolutePath());
334
            boolean forbiddenFolder = Utils.isForbiddenFolder(file);
335
            if (!forbiddenFolder && GitUtils.repositoryExistsFor(file)) {
335
            if (!forbiddenFolder && GitUtils.repositoryExistsFor(file)) {
336
                LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
336
                LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
337
                done.clear();   // all folders added before must be removed, they ARE in fact managed by git
337
                done.clear();   // all folders added before must be removed, they ARE in fact managed by git
(-)a/mercurial.remote/src/org/netbeans/modules/mercurial/remote/Mercurial.java (-1 / +1 lines)
Lines 599-605 Link Here
599
                break;
599
                break;
600
            }
600
            }
601
            // is the folder a special one where metadata should not be looked for?
601
            // is the folder a special one where metadata should not be looked for?
602
            boolean forbiddenFolder = Utils.isForbiddenFolder(file.getPath());
602
            boolean forbiddenFolder = org.netbeans.modules.versioning.core.util.Utils.isForbiddenFolder(file);
603
            if (!forbiddenFolder && HgUtils.hgExistsFor(file)){
603
            if (!forbiddenFolder && HgUtils.hgExistsFor(file)){
604
                if (Mercurial.LOG.isLoggable(Level.FINE)) {
604
                if (Mercurial.LOG.isLoggable(Level.FINE)) {
605
                    Mercurial.LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
605
                    Mercurial.LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
(-)a/mercurial/src/org/netbeans/modules/mercurial/Mercurial.java (-1 / +1 lines)
Lines 569-575 Link Here
569
            }
569
            }
570
            if (VersioningSupport.isExcluded(file)) break;
570
            if (VersioningSupport.isExcluded(file)) break;
571
            // is the folder a special one where metadata should not be looked for?
571
            // is the folder a special one where metadata should not be looked for?
572
            boolean forbiddenFolder = Utils.isForbiddenFolder(file.getAbsolutePath());
572
            boolean forbiddenFolder = Utils.isForbiddenFolder(file);
573
            if (!forbiddenFolder && HgUtils.hgExistsFor(file)){
573
            if (!forbiddenFolder && HgUtils.hgExistsFor(file)){
574
                if (Mercurial.LOG.isLoggable(Level.FINE)) {
574
                if (Mercurial.LOG.isLoggable(Level.FINE)) {
575
                    Mercurial.LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
575
                    Mercurial.LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
(-)404ffed5292e (+60 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 */
40
package org.netbeans.modules.remotefs.versioning.impl;
41
42
import org.netbeans.modules.remote.impl.fileoperations.spi.RemoteVcsSupportUtil;
43
import org.netbeans.modules.remotefs.versioning.api.RemoteVcsSupport;
44
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
45
import org.netbeans.modules.versioning.core.spi.VCSForbiddenFolderProvider;
46
import org.openide.filesystems.FileSystem;
47
import org.openide.util.lookup.ServiceProvider;
48
49
/**
50
 *
51
 * @author vkvashin
52
 */
53
@ServiceProvider(service = VCSForbiddenFolderProvider.class)
54
public class VCSForbiddenFolderProviderImpl implements VCSForbiddenFolderProvider {
55
    @Override
56
    public boolean isForbiddenFolder(VCSFileProxy folder) {
57
        FileSystem fs = RemoteVcsSupport.getFileSystem(folder);
58
        return RemoteVcsSupportUtil.isForbiddenFolder(fs, folder.getPath());
59
    }
60
}
(-)a/subversion/src/org/netbeans/modules/subversion/Subversion.java (-1 / +1 lines)
Lines 528-534 Link Here
528
            }
528
            }
529
            if (org.netbeans.modules.versioning.util.Utils.isScanForbidden(file)) break;
529
            if (org.netbeans.modules.versioning.util.Utils.isScanForbidden(file)) break;
530
            // is the folder a special one where metadata should not be looked for?
530
            // is the folder a special one where metadata should not be looked for?
531
            boolean forbiddenFolder = org.netbeans.modules.versioning.util.Utils.isForbiddenFolder(file.getAbsolutePath());
531
            boolean forbiddenFolder = org.netbeans.modules.versioning.util.Utils.isForbiddenFolder(file);
532
            if (!forbiddenFolder && SvnUtils.hasMetadata(file)) {
532
            if (!forbiddenFolder && SvnUtils.hasMetadata(file)) {
533
                if (Subversion.LOG.isLoggable(Level.FINE)) {
533
                if (Subversion.LOG.isLoggable(Level.FINE)) {
534
                    Subversion.LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
534
                    Subversion.LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
(-)a/versioning.core/src/org/netbeans/modules/versioning/core/Utils.java (+7 lines)
Lines 65-70 Link Here
65
import java.util.prefs.Preferences;
65
import java.util.prefs.Preferences;
66
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
66
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
67
import org.netbeans.modules.versioning.core.api.VersioningSupport;
67
import org.netbeans.modules.versioning.core.api.VersioningSupport;
68
import org.netbeans.modules.versioning.core.spi.VCSForbiddenFolderProvider;
68
import org.openide.filesystems.FileSystem;
69
import org.openide.filesystems.FileSystem;
69
import org.openide.filesystems.URLMapper;
70
import org.openide.filesystems.URLMapper;
70
import org.openide.modules.Places;
71
import org.openide.modules.Places;
Lines 345-350 Link Here
345
    }
346
    }
346
347
347
    public static boolean isForbiddenFolder (VCSFileProxy folder) {
348
    public static boolean isForbiddenFolder (VCSFileProxy folder) {
349
        Collection<? extends VCSForbiddenFolderProvider> forbiddenFolderProviders = Lookup.getDefault().lookupAll(VCSForbiddenFolderProvider.class);
350
        for (VCSForbiddenFolderProvider provider : forbiddenFolderProviders) {
351
            if (provider.isForbiddenFolder(folder)) {
352
                return true;
353
            }
354
        }
348
        return forbiddenFolders.contains(folder.getPath());
355
        return forbiddenFolders.contains(folder.getPath());
349
    }
356
    }
350
357
(-)404ffed5292e (+62 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 */
40
package org.netbeans.modules.versioning.core.spi;
41
42
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
43
44
45
public interface VCSForbiddenFolderProvider {
46
    /**
47
     * Some folders are special and versioning should not look for metadata in
48
     * them. Folders like /net with automount enabled may take a long time to
49
     * answer I/O on their children, so
50
     * <code>VCSFileProxy.exists("/net/.git")</code> will freeze until it timeouts.
51
     * This method is called from org.netbeans.modules.versioning.core.util.Utils.isForbiddenFolder()
52
     * This does not mean however that whole subtree should be excluded from version control, 
53
     * only that you should not look for the metadata directly in this folder.
54
     * Returns <code>true</code> if the given folder is among such folders.
55
     * @author vkvashin
56
     * @param folder a folder to query
57
     * @return <code>true</code> if the given folder should be skipped when
58
     * searching for metadata.
59
     * @since 1.19
60
     */
61
    boolean isForbiddenFolder (VCSFileProxy folder);
62
}
(-)a/versioning.system.cvss/src/org/netbeans/modules/versioning/system/cvss/CvsVersioningSystem.java (-1 / +1 lines)
Lines 463-469 Link Here
463
            }
463
            }
464
            if (org.netbeans.modules.versioning.util.Utils.isScanForbidden(file)) break;
464
            if (org.netbeans.modules.versioning.util.Utils.isScanForbidden(file)) break;
465
            // is the folder a special one where metadata should not be looked for?
465
            // is the folder a special one where metadata should not be looked for?
466
            boolean forbiddenFolder = org.netbeans.modules.versioning.util.Utils.isForbiddenFolder(file.getAbsolutePath());
466
            boolean forbiddenFolder = org.netbeans.modules.versioning.util.Utils.isForbiddenFolder(file);
467
            if (!forbiddenFolder && Utils.containsMetadata(file)) {
467
            if (!forbiddenFolder && Utils.containsMetadata(file)) {
468
                LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
468
                LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
469
                topmost = file;
469
                topmost = file;
(-)a/versioning.util/src/org/netbeans/modules/versioning/util/Utils.java (+22 lines)
Lines 91-96 Link Here
91
import org.netbeans.api.project.Sources;
91
import org.netbeans.api.project.Sources;
92
import org.netbeans.api.queries.FileEncodingQuery;
92
import org.netbeans.api.queries.FileEncodingQuery;
93
import org.netbeans.api.queries.VersioningQuery;
93
import org.netbeans.api.queries.VersioningQuery;
94
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
94
import org.netbeans.modules.versioning.spi.VersioningSystem;
95
import org.netbeans.modules.versioning.spi.VersioningSystem;
95
import org.openide.ErrorManager;
96
import org.openide.ErrorManager;
96
import org.openide.awt.AcceleratorBinding;
97
import org.openide.awt.AcceleratorBinding;
Lines 298-308 Link Here
298
     * @return <code>true</code> if the folder identified by the given path
299
     * @return <code>true</code> if the folder identified by the given path
299
     * should be skipped when searching for metadata.
300
     * should be skipped when searching for metadata.
300
     * @since 1.54
301
     * @since 1.54
302
     * @deprecated  use org.netbeans.modules.versioning.core.Utils.isForbiddenFolder()
301
     */
303
     */
302
    public static boolean isForbiddenFolder (String folderPath) {
304
    public static boolean isForbiddenFolder (String folderPath) {
303
        return forbiddenFolders.contains(folderPath);
305
        return forbiddenFolders.contains(folderPath);
304
    }
306
    }
305
307
308
    /**
309
     * Some folders are special and versioning should not look for metadata in
310
     * them. Folders like /net with automount enabled may take a long time to
311
     * answer I/O on their children, so
312
     * <code>VCSFileProxy.exists("/net/.git")</code> will freeze until it
313
     * timeouts. You should call this method before asking any I/O on children
314
     * of this folder you are unsure to actually exist. This does not mean
315
     * however that whole subtree should be excluded from version control, only
316
     * that you should not look for the metadata directly in this folder.
317
     * Returns <code>true</code> if the given folder is among such folders.
318
     *
319
     * @param folderPath path to a folder to query
320
     * @return <code>true</code> if the folder identified by the given path
321
     * should be skipped when searching for metadata.
322
     * @since 1.54
323
     */
324
    public static boolean isForbiddenFolder (File folder) {
325
        return org.netbeans.modules.versioning.core.Utils.isForbiddenFolder(VCSFileProxy.createFileProxy(folder));
326
    }
327
306
    private static DataObject findDataObject(File file) {
328
    private static DataObject findDataObject(File file) {
307
        FileObject fo = FileUtil.toFileObject(file);
329
        FileObject fo = FileUtil.toFileObject(file);
308
        if (fo != null) {
330
        if (fo != null) {

Return to bug 268772