Search in sources :

Example 11 with VcsRoot

use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.

the class VcsRootDetectorImpl method scanForSingleRootAboveDir.

@NotNull
private List<VcsRoot> scanForSingleRootAboveDir(@NotNull final VirtualFile dir) {
    List<VcsRoot> roots = new ArrayList<>();
    if (myProject.isDisposed()) {
        return roots;
    }
    VirtualFile par = dir.getParent();
    while (par != null) {
        List<AbstractVcs> vcsList = getVcsListFor(par);
        for (AbstractVcs vcs : vcsList) {
            roots.add(new VcsRoot(vcs, par));
        }
        if (!roots.isEmpty()) {
            return roots;
        }
        par = par.getParent();
    }
    return roots;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with VcsRoot

use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.

the class GitShowExternalLogAction method createManagerAndContent.

@NotNull
private static MyContentComponent createManagerAndContent(@NotNull Project project, @NotNull final GitVcs vcs, @NotNull final List<VirtualFile> roots, @Nullable String tabName) {
    final GitRepositoryManager repositoryManager = GitRepositoryManager.getInstance(project);
    for (VirtualFile root : roots) {
        repositoryManager.addExternalRepository(root, GitRepositoryImpl.getInstance(root, project, true));
    }
    VcsLogManager manager = new VcsLogManager(project, ServiceManager.getService(project, VcsLogTabsProperties.class), ContainerUtil.map(roots, root -> new VcsRoot(vcs, root)));
    return new MyContentComponent(manager.createLogPanel(calcLogId(roots), tabName), roots, () -> {
        for (VirtualFile root : roots) {
            repositoryManager.removeExternalRepository(root);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) Arrays(java.util.Arrays) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) GitRepositoryManager(git4idea.repo.GitRepositoryManager) GitRepositoryImpl(git4idea.repo.GitRepositoryImpl) ContainerUtil(com.intellij.util.containers.ContainerUtil) VcsLogContentProvider(com.intellij.vcs.log.impl.VcsLogContentProvider) GitVcs(git4idea.GitVcs) GitUtil(git4idea.GitUtil) Task(com.intellij.openapi.progress.Task) VcsRoot(com.intellij.openapi.vcs.VcsRoot) Comparing(com.intellij.openapi.util.Comparing) GitVersion(git4idea.config.GitVersion) WindowWrapper(com.intellij.openapi.ui.WindowWrapper) Disposer(com.intellij.openapi.util.Disposer) VcsLogManager(com.intellij.vcs.log.impl.VcsLogManager) Project(com.intellij.openapi.project.Project) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) ProgressManager(com.intellij.openapi.progress.ProgressManager) ToolWindow(com.intellij.openapi.wm.ToolWindow) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) ChangesViewContentManager(com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager) Content(com.intellij.ui.content.Content) Disposable(com.intellij.openapi.Disposable) File(java.io.File) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) ServiceManager(com.intellij.openapi.components.ServiceManager) ContentFactory(com.intellij.ui.content.ContentFactory) WindowWrapperBuilder(com.intellij.openapi.ui.WindowWrapperBuilder) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ContentManager(com.intellij.ui.content.ContentManager) ObjectUtils(com.intellij.util.ObjectUtils) VcsLogTabsProperties(com.intellij.vcs.log.impl.VcsLogTabsProperties) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) FileChooser(com.intellij.openapi.fileChooser.FileChooser) javax.swing(javax.swing) VcsLogManager(com.intellij.vcs.log.impl.VcsLogManager) VcsLogTabsProperties(com.intellij.vcs.log.impl.VcsLogTabsProperties) GitRepositoryManager(git4idea.repo.GitRepositoryManager) VcsRoot(com.intellij.openapi.vcs.VcsRoot) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with VcsRoot

use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.

the class IdeaTextPatchBuilder method revisionsConvertor.

public static List<BeforeAfter<AirContentRevision>> revisionsConvertor(final Project project, final List<Change> changes) throws VcsException {
    final List<BeforeAfter<AirContentRevision>> result = new ArrayList<>(changes.size());
    Map<VcsRoot, List<Change>> byRoots = groupByRoots(project, changes, change -> chooseNotNull(getBeforePath(change), getAfterPath(change)));
    for (VcsRoot root : byRoots.keySet()) {
        final Collection<Change> rootChanges = byRoots.get(root);
        if (root.getVcs() == null || root.getVcs().getOutgoingChangesProvider() == null) {
            addConvertChanges(rootChanges, result);
            continue;
        }
        final VcsOutgoingChangesProvider<?> provider = root.getVcs().getOutgoingChangesProvider();
        final Collection<Change> basedOnLocal = provider.filterLocalChangesBasedOnLocalCommits(rootChanges, root.getPath());
        rootChanges.removeAll(basedOnLocal);
        addConvertChanges(rootChanges, result);
        for (Change change : basedOnLocal) {
            // dates are here instead of numbers
            result.add(new BeforeAfter<>(convertRevision(change.getBeforeRevision(), provider), convertRevision(change.getAfterRevision(), provider)));
        }
    }
    return result;
}
Also used : BeforeAfter(com.intellij.util.BeforeAfter) VcsRoot(com.intellij.openapi.vcs.VcsRoot) Change(com.intellij.openapi.vcs.changes.Change)

Example 14 with VcsRoot

use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.

the class RemoteRevisionsNumbersCache method invalidate.

public void invalidate(final Collection<String> paths) {
    synchronized (myLock) {
        for (String path : paths) {
            final Pair<VcsRoot, VcsRevisionNumber> pair = myData.remove(path);
            if (pair != null) {
                // vcs [root] seems to not change
                final VcsRoot vcsRoot = pair.getFirst();
                final LazyRefreshingSelfQueue<String> queue = getQueue(vcsRoot);
                queue.forceRemove(path);
                queue.addRequest(path);
                myData.put(path, Pair.create(vcsRoot, NOT_LOADED));
            }
        }
    }
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) VcsRoot(com.intellij.openapi.vcs.VcsRoot)

Example 15 with VcsRoot

use of com.intellij.openapi.vcs.VcsRoot in project intellij-community by JetBrains.

the class RemoteRevisionsNumbersCache method minus.

public void minus(Pair<String, AbstractVcs> pair) {
    // does not support
    if (pair.getSecond().getDiffProvider() == null)
        return;
    final VirtualFile root = getRootForPath(pair.getFirst());
    if (root == null)
        return;
    final LazyRefreshingSelfQueue<String> queue;
    final String key = pair.getFirst();
    synchronized (myLock) {
        queue = getQueue(new VcsRoot(pair.getSecond(), root));
        myData.remove(key);
    }
    queue.forceRemove(key);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsRoot(com.intellij.openapi.vcs.VcsRoot)

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