/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License.
*/
/** * Runs a given callable and disable listening for external repository events for the time the callable is running. * Refreshes cached modification timestamp of metadata for the given git repository after. * @param callable code to run * @param repository * @param commandName name of the git command if available
*/ public <T> T runWithoutExternalEvents(File repository, String commandName, Callable<T> callable) throws Exception { return getVCSInterceptor().runWithoutExternalEvents(repository, commandName, callable);
}
/** * Returns a set of known repository roots (those visible or open in IDE) * @param repositoryRoot * @return
*/ public Set<File> getSeenRoots (File repositoryRoot) { return getVCSInterceptor().getSeenRoots(repositoryRoot);
}
public File getTopmostManagedAncestor (File file) { return getTopmostManagedAncestor(file, false);
}
private File getTopmostManagedAncestor (File file, boolean noExceptions) { long t = System.currentTimeMillis();
LOG.log(Level.FINE, "getTopmostManagedParent {0}", new Object[] { file }); if(unversionedParents.contains(file)) {
LOG.fine(" cached as unversioned"); returnnull;
}
LOG.log(Level.FINE, "getTopmostManagedParent {0}", new Object[] { file });
File parent = getKnownParent(file); if(parent != null) {
LOG.log(Level.FINE, " getTopmostManagedParent returning known parent {0}", parent); return parent;
}
if (GitUtils.isPartOfGitMetadata(file)) { for (;file != null; file = file.getParentFile()) { if (GitUtils.isAdministrative(file)) {
file = file.getParentFile(); // the parent folder of .hg metadata cannot be unversioned, it's nonsense
unversionedParents.remove(file); break;
}
}
}
Set<File> done = new HashSet<File>();
File topmost = null; for (;file != null; file = file.getParentFile()) { if(unversionedParents.contains(file)) {
LOG.log(Level.FINE, " already known as unversioned {0}", new Object[] { file }); break;
} if (!noExceptions && VersioningSupport.isExcluded(file)) break; // is the folder a special one where metadata should not be looked for? boolean forbiddenFolder = Utils.isForbiddenFolder(file); if (!forbiddenFolder && GitUtils.repositoryExistsFor(file)) {
LOG.log(Level.FINE, " found managed parent {0}", new Object[] { file });
done.clear(); // all folders added before must be removed, they ARE in fact managed by git
topmost = file; if (topmost.getParentFile() == null) {
LOG.log(Level.WARNING, "found managed root folder {0}", file); //NOI18N
}
} else {
LOG.log(Level.FINE, " found unversioned {0}", new Object[] { file }); if(file.exists()) { // could be created later ...
done.add(file);
}
}
} if(done.size() > 0) {
LOG.log(Level.FINE, " storing unversioned");
unversionedParents.addAll(done);
} if(LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, " getTopmostManagedParent returns {0} after {1} millis", new Object[] { topmost, System.currentTimeMillis() - t });
} if(topmost != null) { if (knownRoots.add(topmost)) {
String homeDir = System.getProperty("user.home"); //NOI18N if (homeDir != null && homeDir.startsWith(topmost.getAbsolutePath())) {
LOG.log(Level.WARNING, "Home folder {0} lies under a git versioned root {1}. "//NOI18N
+ "Expecting lots of performance issues.", new Object[] { homeDir, topmost }); //NOI18N
}
}
}
return topmost;
}
private File singleInstanceRepositoryRoot (File repository) { // get the only instance for the repository folder, so we can synchronize on it
File repositoryFolder = getRepositoryRoot(repository); if (repositoryFolder != null && repository.equals(repositoryFolder)) {
repository = repositoryFolder;
} return repository;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.