# HG changeset patch # User Vladimir Kvashin # Date 1478200074 -10800 # Branch release82 # Node ID 21f6eabd4aa4d1b0aba480a306f326afa4fa05e1 # Parent 404ffed5292eaa022b975ac94ffcc04a8b46d9e9 Introducing VCSForbiddenFolderProvider diff -r 404ffed5292e -r 21f6eabd4aa4 versioning.core/src/org/netbeans/modules/versioning/core/Utils.java --- a/versioning.core/src/org/netbeans/modules/versioning/core/Utils.java Wed Nov 02 23:08:27 2016 +0300 +++ b/versioning.core/src/org/netbeans/modules/versioning/core/Utils.java Thu Nov 03 22:07:54 2016 +0300 @@ -65,6 +65,7 @@ import java.util.prefs.Preferences; import org.netbeans.modules.versioning.core.api.VCSFileProxy; import org.netbeans.modules.versioning.core.api.VersioningSupport; +import org.netbeans.modules.versioning.core.spi.VCSForbiddenFolderProvider; import org.openide.filesystems.FileSystem; import org.openide.filesystems.URLMapper; import org.openide.modules.Places; @@ -345,6 +346,12 @@ } public static boolean isForbiddenFolder (VCSFileProxy folder) { + Collection forbiddenFolderProviders = Lookup.getDefault().lookupAll(VCSForbiddenFolderProvider.class); + for (VCSForbiddenFolderProvider provider : forbiddenFolderProviders) { + if (provider.isForbiddenFolder(folder)) { + return true; + } + } return forbiddenFolders.contains(folder.getPath()); } diff -r 404ffed5292e -r 21f6eabd4aa4 versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSForbiddenFolderProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSForbiddenFolderProvider.java Thu Nov 03 22:07:54 2016 +0300 @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + */ +package org.netbeans.modules.versioning.core.spi; + +import org.netbeans.modules.versioning.core.api.VCSFileProxy; + + +public interface VCSForbiddenFolderProvider { + /** + * Some folders are special and versioning should not look for metadata in + * them. Folders like /net with automount enabled may take a long time to + * answer I/O on their children, so + * VCSFileProxy.exists("/net/.git") will freeze until it timeouts. + * This method is called from org.netbeans.modules.versioning.core.util.Utils.isForbiddenFolder() + * This does not mean however that whole subtree should be excluded from version control, + * only that you should not look for the metadata directly in this folder. + * Returns true if the given folder is among such folders. + * @author vkvashin + * @param folder a folder to query + * @return true if the given folder should be skipped when + * searching for metadata. + * @since 1.19 + */ + boolean isForbiddenFolder (VCSFileProxy folder); +}