Search in sources :

Example 1 with VcsRoot

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;
}
Also used : VcsRoot(com.intellij.openapi.vcs.VcsRoot) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 2 with VcsRoot

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);
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Pair(com.intellij.openapi.util.Pair)

Example 3 with VcsRoot

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);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 4 with VcsRoot

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;
}
Also used : DiffProvider(com.intellij.openapi.vcs.diff.DiffProvider) VcsRoot(com.intellij.openapi.vcs.VcsRoot)

Example 5 with VcsRoot

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRoot(com.intellij.openapi.vcs.VcsRoot) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

VcsRoot (com.intellij.openapi.vcs.VcsRoot)17 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 NotNull (org.jetbrains.annotations.NotNull)8 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)7 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)3 Disposable (com.intellij.openapi.Disposable)2 Project (com.intellij.openapi.project.Project)2 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)2 VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)2 File (java.io.File)2 Nullable (org.jetbrains.annotations.Nullable)2 AdditionalOptionsPanel (com.intellij.cvsSupport2.checkinProject.AdditionalOptionsPanel)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1 ServiceManager (com.intellij.openapi.components.ServiceManager)1 FileChooser (com.intellij.openapi.fileChooser.FileChooser)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1