# HG changeset patch # User Vladimir Kvashin # Date 1478164375 -10800 # Branch release82 # Node ID 6ca1355b4e8235b0d939cceabcb905f71a8b2590 # Parent 404ffed5292eaa022b975ac94ffcc04a8b46d9e9 fixing #268772 - Remote Versioning asks for /home/.hg and similar files diff -r 404ffed5292e -r 6ca1355b4e82 dlight.remote.impl/src/org/netbeans/modules/remote/impl/fileoperations/spi/RemoteVcsSupportUtil.java --- a/dlight.remote.impl/src/org/netbeans/modules/remote/impl/fileoperations/spi/RemoteVcsSupportUtil.java Wed Nov 02 23:08:27 2016 +0300 +++ b/dlight.remote.impl/src/org/netbeans/modules/remote/impl/fileoperations/spi/RemoteVcsSupportUtil.java Thu Nov 03 12:12:55 2016 +0300 @@ -433,4 +433,26 @@ } } } + + public static boolean isForbiddenFolder(FileSystem fs, String path) { + if (fs instanceof RemoteFileSystem) { + RemoteFileSystem rfs = (RemoteFileSystem) fs; + if (path.isEmpty()) { + return true; + } + if (rfs.isAutoMount(path) || rfs.isProhibitedToEnter(path)) { + return true; + } + int pos = path.lastIndexOf('/'); + if (pos > 0) { + String parent = path.substring(0, pos); + if (rfs.isAutoMount(parent) || rfs.isProhibitedToEnter(parent)) { + return true; + } + } + return false; + //return rfs.isAutoMount(path); + } + return false; + } } diff -r 404ffed5292e -r 6ca1355b4e82 git.remote/src/org/netbeans/modules/git/remote/Git.java --- a/git.remote/src/org/netbeans/modules/git/remote/Git.java Wed Nov 02 23:08:27 2016 +0300 +++ b/git.remote/src/org/netbeans/modules/git/remote/Git.java Thu Nov 03 12:12:55 2016 +0300 @@ -371,7 +371,7 @@ break; } // is the folder a special one where metadata should not be looked for? - boolean forbiddenFolder = Utils.isForbiddenFolder(file.getPath()); + boolean forbiddenFolder = org.netbeans.modules.versioning.core.util.Utils.isForbiddenFolder(file); if (!forbiddenFolder && GitUtils.repositoryExistsFor(file)) { if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file }); diff -r 404ffed5292e -r 6ca1355b4e82 mercurial.remote/src/org/netbeans/modules/mercurial/remote/Mercurial.java --- a/mercurial.remote/src/org/netbeans/modules/mercurial/remote/Mercurial.java Wed Nov 02 23:08:27 2016 +0300 +++ b/mercurial.remote/src/org/netbeans/modules/mercurial/remote/Mercurial.java Thu Nov 03 12:12:55 2016 +0300 @@ -599,7 +599,7 @@ break; } // is the folder a special one where metadata should not be looked for? - boolean forbiddenFolder = Utils.isForbiddenFolder(file.getPath()); + boolean forbiddenFolder = org.netbeans.modules.versioning.core.util.Utils.isForbiddenFolder(file); if (!forbiddenFolder && HgUtils.hgExistsFor(file)){ if (Mercurial.LOG.isLoggable(Level.FINE)) { Mercurial.LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file }); diff -r 404ffed5292e -r 6ca1355b4e82 remotefs.versioning/src/org/netbeans/modules/remotefs/versioning/impl/VCSForbiddenFolderProviderImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/remotefs.versioning/src/org/netbeans/modules/remotefs/versioning/impl/VCSForbiddenFolderProviderImpl.java Thu Nov 03 12:12:55 2016 +0300 @@ -0,0 +1,60 @@ +/* + * 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.remotefs.versioning.impl; + +import org.netbeans.modules.remote.impl.fileoperations.spi.RemoteVcsSupportUtil; +import org.netbeans.modules.remotefs.versioning.api.RemoteVcsSupport; +import org.netbeans.modules.versioning.core.api.VCSFileProxy; +import org.netbeans.modules.versioning.core.spi.VCSForbiddenFolderProvider; +import org.openide.filesystems.FileSystem; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author vkvashin + */ +@ServiceProvider(service = VCSForbiddenFolderProvider.class) +public class VCSForbiddenFolderProviderImpl implements VCSForbiddenFolderProvider { + @Override + public boolean isForbiddenFolder(VCSFileProxy folder) { + FileSystem fs = RemoteVcsSupport.getFileSystem(folder); + return RemoteVcsSupportUtil.isForbiddenFolder(fs, folder.getPath()); + } +} diff -r 404ffed5292e -r 6ca1355b4e82 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 12:12:55 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 6ca1355b4e82 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 12:12:55 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); +}