use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class RemoteRevisionsNumbersCache method directoryMappingChanged.
public void directoryMappingChanged() {
// copy myData under lock
HashSet<String> keys;
synchronized (myLock) {
keys = new HashSet<>(myData.keySet());
}
// collect new vcs for scheduled files
final Map<String, Pair<VirtualFile, AbstractVcs>> vFiles = new HashMap<>();
for (String key : keys) {
final VirtualFile vf = myLfs.refreshAndFindFileByIoFile(new File(key));
final AbstractVcs newVcs = (vf == null) ? null : myVcsManager.getVcsFor(vf);
vFiles.put(key, vf == null ? Pair.create((VirtualFile) null, (AbstractVcs) null) : Pair.create(vf, newVcs));
}
synchronized (myLock) {
keys = new HashSet<>(myData.keySet());
for (String key : keys) {
final Pair<VcsRoot, VcsRevisionNumber> value = myData.get(key);
final VcsRoot storedVcsRoot = value.getFirst();
final Pair<VirtualFile, AbstractVcs> pair = vFiles.get(key);
if (pair == null) {
// already added with new mappings
continue;
}
final VirtualFile vf = pair.getFirst();
final AbstractVcs newVcs = pair.getSecond();
if (newVcs == null) {
myData.remove(key);
getQueue(storedVcsRoot).forceRemove(key);
} else {
final VirtualFile newRoot = myVcsManager.getVcsRootFor(vf);
final VcsRoot newVcsRoot = new VcsRoot(newVcs, newRoot);
if (!storedVcsRoot.equals(newVcsRoot)) {
switchVcs(storedVcsRoot, newVcsRoot, key);
}
}
}
}
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class RemoteRevisionsNumbersCache method plus.
public void plus(final Pair<String, AbstractVcs> pair) {
// does not support
if (pair.getSecond().getDiffProvider() == null)
return;
final String key = pair.getFirst();
final AbstractVcs newVcs = pair.getSecond();
final VirtualFile root = getRootForPath(key);
if (root == null)
return;
final VcsRoot vcsRoot = new VcsRoot(newVcs, root);
synchronized (myLock) {
final Pair<VcsRoot, VcsRevisionNumber> value = myData.get(key);
if (value == null) {
final LazyRefreshingSelfQueue<String> queue = getQueue(vcsRoot);
myData.put(key, Pair.create(vcsRoot, NOT_LOADED));
queue.addRequest(key);
} else if (!value.getFirst().equals(vcsRoot)) {
switchVcs(value.getFirst(), vcsRoot, key);
}
}
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class VcsDirtyScopeManagerImpl method calculateInvalidated.
@NotNull
private VcsInvalidated calculateInvalidated(@NotNull DirtBuilder dirt) {
MultiMap<AbstractVcs, FilePath> files = dirt.getFilesForVcs();
MultiMap<AbstractVcs, FilePath> dirs = dirt.getDirsForVcs();
if (dirt.isEverythingDirty()) {
dirs.putAllValues(getEverythingDirtyRoots());
}
Set<AbstractVcs> keys = ContainerUtil.union(files.keySet(), dirs.keySet());
Map<AbstractVcs, VcsDirtyScopeImpl> scopes = ContainerUtil.newHashMap();
for (AbstractVcs key : keys) {
VcsDirtyScopeImpl scope = new VcsDirtyScopeImpl(key, myProject);
scopes.put(key, scope);
scope.addDirtyData(dirs.get(key), files.get(key));
}
return new VcsInvalidated(new ArrayList<>(scopes.values()), dirt.isEverythingDirty());
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class VcsDirtyScopeManagerImpl method getEverythingDirtyRoots.
@NotNull
private MultiMap<AbstractVcs, FilePath> getEverythingDirtyRoots() {
MultiMap<AbstractVcs, FilePath> dirtyRoots = MultiMap.createSet();
dirtyRoots.putAllValues(groupByVcs(toFilePaths(DefaultVcsRootPolicy.getInstance(myProject).getDirtyRoots())));
List<VcsDirectoryMapping> mappings = myVcsManager.getDirectoryMappings();
for (VcsDirectoryMapping mapping : mappings) {
if (!mapping.isDefaultMapping() && mapping.getVcs() != null) {
AbstractVcs vcs = myVcsManager.findVcsByName(mapping.getVcs());
if (vcs != null) {
dirtyRoots.putValue(vcs, VcsUtil.getFilePath(mapping.getDirectory(), true));
}
}
}
return dirtyRoots;
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class DescindingFilesFilter method filterDescindingFiles.
@NotNull
public static FilePath[] filterDescindingFiles(@NotNull FilePath[] roots, Project project) {
final List<FilePath> result = new LinkedList<>();
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
Arrays.sort(roots, FilePathComparator.getInstance());
final Map<VcsKey, List<FilePath>> chains = new HashMap<>();
for (FilePath root : roots) {
final AbstractVcs vcs = manager.getVcsFor(root);
if (vcs == null)
continue;
if (vcs.allowsNestedRoots()) {
// just put into result: nested roots are allowed
result.add(root);
continue;
}
//if (pathsFilter != null && (! pathsFilter.convert(new Pair<FilePath, AbstractVcs>(root, vcs)))) continue;
final List<FilePath> chain = chains.get(vcs.getKeyInstanceMethod());
if (chain == null) {
final LinkedList<FilePath> newList = new LinkedList<>();
newList.add(root);
chains.put(vcs.getKeyInstanceMethod(), newList);
} else {
boolean failed = false;
for (FilePath chainedPath : chain) {
if (VfsUtilCore.isAncestor(chainedPath.getIOFile(), root.getIOFile(), false)) {
// do not take this root
failed = true;
break;
}
}
if (!failed) {
chain.add(root);
}
}
}
for (List<FilePath> filePaths : chains.values()) {
result.addAll(filePaths);
}
return result.toArray(new FilePath[result.size()]);
}
Aggregations