use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.
the class RemoteRevisionsNumbersCache method updateStep.
public boolean updateStep() {
mySomethingChanged = false;
// copy under lock
final HashMap<VcsRoot, LazyRefreshingSelfQueue> copyMap;
synchronized (myLock) {
copyMap = new HashMap<>(myRefreshingQueues);
}
// filter only items for vcs roots that support background operations
for (Iterator<Map.Entry<VcsRoot, LazyRefreshingSelfQueue>> iterator = copyMap.entrySet().iterator(); iterator.hasNext(); ) {
final Map.Entry<VcsRoot, LazyRefreshingSelfQueue> entry = iterator.next();
final VcsRoot key = entry.getKey();
final boolean backgroundOperationsAllowed = key.getVcs().isVcsBackgroundOperationsAllowed(key.getPath());
LOG.debug("backgroundOperationsAllowed: " + backgroundOperationsAllowed + " for " + key.getVcs().getName() + ", " + key.getPath().getPath());
if (!backgroundOperationsAllowed) {
iterator.remove();
}
}
LOG.debug("queues refresh started, queues: " + copyMap.size());
// refresh "up to date" info
for (LazyRefreshingSelfQueue queue : copyMap.values()) {
if (myProject.isDisposed())
throw new ProcessCanceledException();
queue.updateStep();
}
return mySomethingChanged;
}
use of com.intellij.openapi.vcs.VcsRoot 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.VcsRoot 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.VcsRoot in project intellij-community by JetBrains.
the class VcsAnnotationLocalChangesListenerImpl method fromDiffProvider.
private VcsRevisionNumber fromDiffProvider(final VirtualFile vf) {
final VcsRoot vcsRoot = myVcsManager.getVcsRootObjectFor(vf);
DiffProvider diffProvider;
if (vcsRoot != null && vcsRoot.getVcs() != null && (diffProvider = vcsRoot.getVcs().getDiffProvider()) != null) {
return diffProvider.getCurrentRevision(vf);
}
return null;
}
use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.
the class LocalChangesUnderRoots method getRootForPath.
@Nullable
private VirtualFile getRootForPath(@NotNull FilePath file, @NotNull Collection<VirtualFile> rootsToSave) {
final VirtualFile vf = ChangesUtil.findValidParentUnderReadAction(file);
if (vf == null) {
return null;
}
VirtualFile rootCandidate = null;
for (VcsRoot root : myRoots) {
if (VfsUtilCore.isAncestor(root.getPath(), vf, false)) {
if (rootCandidate == null || VfsUtil.isAncestor(rootCandidate, root.getPath(), true)) {
// in the case of nested roots choose the closest root
rootCandidate = root.getPath();
}
}
}
if (!rootsToSave.contains(rootCandidate))
return null;
return rootCandidate;
}
Aggregations