Search in sources :

Example 6 with FileAnnotation

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

the class SvnAnnotationIsClosedTest method testNotClosedByRenaming.

@Test
public void testNotClosedByRenaming() throws Exception {
    final SubTree tree = new SubTree(myWorkingCopyDir);
    checkin();
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3\n4\n");
    checkin();
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4\n");
    checkin();
    final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
    final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
    annotation.setCloser(() -> {
        myIsClosed = true;
        listener.unregisterAnnotation(tree.myS1File, annotation);
    });
    listener.registerAnnotation(tree.myS1File, annotation);
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4++\n");
    // not closed on typing
    Assert.assertFalse(myIsClosed);
    VcsTestUtil.renameFileInCommand(myProject, tree.myS1File, "5364536");
    // not closed on typing
    Assert.assertFalse(myIsClosed);
    myDirtyScopeManager.markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    final Change change = myChangeListManager.getChange(tree.myS1File);
    Assert.assertNotNull(change);
}
Also used : VcsAnnotationLocalChangesListener(com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Change(com.intellij.openapi.vcs.changes.Change) Test(org.junit.Test)

Example 7 with FileAnnotation

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

the class SvnAnnotationIsClosedTest method testClosedByCommitFromIdea.

@Test
public void testClosedByCommitFromIdea() throws Exception {
    final SubTree tree = new SubTree(myWorkingCopyDir);
    checkin();
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3\n4\n");
    checkin();
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4\n");
    checkin();
    final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
    final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
    annotation.setCloser(() -> {
        myIsClosed = true;
        listener.unregisterAnnotation(tree.myS1File, annotation);
    });
    listener.registerAnnotation(tree.myS1File, annotation);
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4++\n");
    // not closed on typing
    Assert.assertFalse(myIsClosed);
    myDirtyScopeManager.markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    final Change change = myChangeListManager.getChange(tree.myS1File);
    Assert.assertNotNull(change);
    final List<VcsException> exceptions = myVcs.getCheckinEnvironment().commit(Collections.singletonList(change), "commit");
    Assert.assertTrue(exceptions == null || exceptions.isEmpty());
    myDirtyScopeManager.fileDirty(tree.myS1File);
    myChangeListManager.ensureUpToDate(false);
    // wait for after-events like annotations recalculation
    myChangeListManager.ensureUpToDate(false);
    // zipper updater
    sleep(100);
    Assert.assertTrue(myIsClosed);
}
Also used : VcsAnnotationLocalChangesListener(com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener) VcsException(com.intellij.openapi.vcs.VcsException) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Change(com.intellij.openapi.vcs.changes.Change) Test(org.junit.Test)

Example 8 with FileAnnotation

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

the class SvnAnnotationIsClosedTest method testClosedChangedByUpdateInIdea.

@Test
public void testClosedChangedByUpdateInIdea() throws Exception {
    final SubTree tree = new SubTree(myWorkingCopyDir);
    //#1
    checkin();
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3\n4\n");
    //#2
    checkin();
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1\n2\n3**\n4\n");
    //#3
    checkin();
    // take #2
    runInAndVerifyIgnoreOutput("up", "-r", "2");
    final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
    final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
    annotation.setCloser(() -> {
        myIsClosed = true;
        listener.unregisterAnnotation(tree.myS1File, annotation);
    });
    listener.registerAnnotation(tree.myS1File, annotation);
    VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1+\n2\n3\n4\n");
    myDirtyScopeManager.markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    Assert.assertFalse(myIsClosed);
    ProjectLevelVcsManagerEx.getInstanceEx(myProject).getOptions(VcsConfiguration.StandardOption.UPDATE).setValue(false);
    final CommonUpdateProjectAction action = new CommonUpdateProjectAction();
    action.getTemplatePresentation().setText("1");
    action.actionPerformed(new AnActionEvent(null, dataId -> {
        if (CommonDataKeys.PROJECT.is(dataId)) {
            return myProject;
        }
        return null;
    }, "test", new Presentation(), ActionManager.getInstance(), 0));
    myChangeListManager.ensureUpToDate(false);
    // wait for after-events like annotations recalculation
    myChangeListManager.ensureUpToDate(false);
    // zipper updater
    sleep(100);
    Assert.assertTrue(myIsClosed);
}
Also used : VcsTestUtil(com.intellij.openapi.vcs.VcsTestUtil) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) VcsRevisionDescription(com.intellij.openapi.vcs.history.VcsRevisionDescription) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsAnnotationLocalChangesListener(com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener) CommonUpdateProjectAction(com.intellij.openapi.vcs.update.CommonUpdateProjectAction) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) Presentation(com.intellij.openapi.actionSystem.Presentation) Test(org.junit.Test) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) File(java.io.File) ActionManager(com.intellij.openapi.actionSystem.ActionManager) VcsConfiguration(com.intellij.openapi.vcs.VcsConfiguration) List(java.util.List) Assert(junit.framework.Assert) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) VcsDirtyScopeManager(com.intellij.openapi.vcs.changes.VcsDirtyScopeManager) ProjectLevelVcsManagerEx(com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) VcsException(com.intellij.openapi.vcs.VcsException) Collections(java.util.Collections) Before(org.junit.Before) VcsAnnotationLocalChangesListener(com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener) CommonUpdateProjectAction(com.intellij.openapi.vcs.update.CommonUpdateProjectAction) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Presentation(com.intellij.openapi.actionSystem.Presentation) Test(org.junit.Test)

Example 9 with FileAnnotation

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

the class VcsAnnotationLocalChangesListenerImpl method processUnderFile.

private void processUnderFile(VirtualFile file) {
    final MultiMap<VirtualFile, FileAnnotation> annotations = new MultiMap<>();
    synchronized (myLock) {
        for (VirtualFile virtualFile : myFileAnnotationMap.keySet()) {
            if (VfsUtilCore.isAncestor(file, virtualFile, true)) {
                final Collection<FileAnnotation> values = myFileAnnotationMap.get(virtualFile);
                for (FileAnnotation value : values) {
                    annotations.putValue(virtualFile, value);
                }
            }
        }
    }
    if (!annotations.isEmpty()) {
        for (Map.Entry<VirtualFile, Collection<FileAnnotation>> entry : annotations.entrySet()) {
            final VirtualFile key = entry.getKey();
            final VcsRevisionNumber number = fromDiffProvider(key);
            if (number == null)
                continue;
            final Collection<FileAnnotation> fileAnnotations = entry.getValue();
            for (FileAnnotation annotation : fileAnnotations) {
                if (annotation.isBaseRevisionChanged(number)) {
                    annotation.close();
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MultiMap(com.intellij.util.containers.MultiMap) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) MultiMap(com.intellij.util.containers.MultiMap)

Example 10 with FileAnnotation

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

the class AnnotateVcsVirtualFileAction method doAnnotate.

private static void doAnnotate(@NotNull final Project project, @NotNull final Editor editor, @NotNull final VirtualFile file) {
    final AnnotationData data = extractData(project, file);
    assert data != null;
    final AnnotationProviderEx provider = (AnnotationProviderEx) data.vcs.getAnnotationProvider();
    assert provider != null;
    final Ref<FileAnnotation> fileAnnotationRef = new Ref<>();
    final Ref<VcsException> exceptionRef = new Ref<>();
    VcsAnnotateUtil.getBackgroundableLock(project, file).lock();
    final Task.Backgroundable annotateTask = new Task.Backgroundable(project, VcsBundle.message("retrieving.annotations"), true) {

        @Override
        public void run(@NotNull final ProgressIndicator indicator) {
            try {
                fileAnnotationRef.set(provider.annotate(data.filePath, data.revisionNumber));
            } catch (VcsException e) {
                exceptionRef.set(e);
            } catch (ProcessCanceledException pce) {
                throw pce;
            } catch (Throwable t) {
                exceptionRef.set(new VcsException(t));
            }
        }

        @Override
        public void onCancel() {
            onSuccess();
        }

        @Override
        public void onSuccess() {
            VcsAnnotateUtil.getBackgroundableLock(project, file).unlock();
            if (!exceptionRef.isNull()) {
                LOG.warn(exceptionRef.get());
                AbstractVcsHelper.getInstance(project).showErrors(Collections.singletonList(exceptionRef.get()), VcsBundle.message("message.title.annotate"));
            }
            if (!fileAnnotationRef.isNull()) {
                AnnotateToggleAction.doAnnotate(editor, project, null, fileAnnotationRef.get(), data.vcs);
            }
        }
    };
    ProgressManager.getInstance().run(annotateTask);
}
Also used : Task(com.intellij.openapi.progress.Task) AnnotationProviderEx(com.intellij.vcs.AnnotationProviderEx) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Aggregations

FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)28 VcsAnnotationLocalChangesListener (com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener)16 Test (org.junit.Test)16 Change (com.intellij.openapi.vcs.changes.Change)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 VcsException (com.intellij.openapi.vcs.VcsException)7 File (java.io.File)7 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Task (com.intellij.openapi.progress.Task)3 Ref (com.intellij.openapi.util.Ref)3 FilePath (com.intellij.openapi.vcs.FilePath)3 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)3 AnnotationProvider (com.intellij.openapi.vcs.annotate.AnnotationProvider)3 List (java.util.List)3 AnnotateOperation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation)2 Annotation (com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotation)2 ActionManager (com.intellij.openapi.actionSystem.ActionManager)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)2