void () { // 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 = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(key)); final AbstractVcs newVcs = (vf == null) ? null : getVcsFor(myProject, vf); vFiles.put(key, vf == null ? Pair.create(null, 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) { continue; // already added with new mappings } final VirtualFile vf = pair.getFirst(); final AbstractVcs newVcs = pair.getSecond(); final VirtualFile newRoot = newVcs != null ? getVcsRootFor(myProject, vf) : null; if (newRoot == null) { myData.remove(key); getQueue(storedVcsRoot).forceRemove(key); } else { final VcsRoot newVcsRoot = new VcsRoot(newVcs, newRoot); if (! storedVcsRoot.equals(newVcsRoot)) { switchVcs(storedVcsRoot, newVcsRoot, key); } } } } }