Search in sources :

Example 11 with VcsAnnotationLocalChangesListener

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

the class SvnAnnotationIsClosedTest method testClosedByExternalCommit.

@Test
public void testClosedByExternalCommit() 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();
    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);
    checkin();
    myWorkingCopyDir.refresh(false, true);
    imitateEvent(myWorkingCopyDir);
    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) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) Test(org.junit.Test)

Example 12 with VcsAnnotationLocalChangesListener

use of com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener 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 13 with VcsAnnotationLocalChangesListener

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

the class SvnAnnotationIsClosedTest method testClosedByUpdateWithExternals.

@Test
public void testClosedByUpdateWithExternals() throws Exception {
    prepareExternal();
    final File sourceFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "s1.txt");
    final File externalFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "external" + File.separator + "t12.txt");
    final LocalFileSystem lfs = LocalFileSystem.getInstance();
    final VirtualFile vf1 = lfs.refreshAndFindFileByIoFile(sourceFile);
    final VirtualFile vf2 = lfs.refreshAndFindFileByIoFile(externalFile);
    Assert.assertNotNull(vf1);
    Assert.assertNotNull(vf2);
    VcsTestUtil.editFileInCommand(myProject, vf1, "test externals 123" + System.currentTimeMillis());
    VcsTestUtil.editFileInCommand(myProject, vf2, "test externals 123" + System.currentTimeMillis());
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    final Change change1 = myChangeListManager.getChange(vf1);
    final Change change2 = myChangeListManager.getChange(vf2);
    Assert.assertNotNull(change1);
    Assert.assertNotNull(change2);
    final File sourceDir = new File(myWorkingCopyDir.getPath(), "source");
    final File externalDir = new File(myWorkingCopyDir.getPath(), "source/external");
    // #3
    runInAndVerifyIgnoreOutput("ci", "-m", "test", sourceDir.getPath());
    // #4
    runInAndVerifyIgnoreOutput("ci", "-m", "test", externalDir.getPath());
    VcsTestUtil.editFileInCommand(myProject, vf2, "test externals 12344444" + System.currentTimeMillis());
    // #5
    runInAndVerifyIgnoreOutput("ci", "-m", "test", externalDir.getPath());
    final SvnDiffProvider diffProvider = (SvnDiffProvider) myVcs.getDiffProvider();
    assertRevision(vf1, diffProvider, 3);
    assertRevision(vf2, diffProvider, 5);
    runInAndVerifyIgnoreOutput("up", "-r", "4", sourceDir.getPath());
    runInAndVerifyIgnoreOutput("up", "-r", "4", externalDir.getPath());
    assertRevision(vf1, diffProvider, 3);
    assertRevision(vf2, diffProvider, 4);
    // then annotate both
    final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
    final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), vf1);
    annotation.setCloser(() -> {
        myIsClosed = true;
        listener.unregisterAnnotation(vf1, annotation);
    });
    listener.registerAnnotation(vf1, annotation);
    final FileAnnotation annotation1 = createTestAnnotation(myVcs.getAnnotationProvider(), vf2);
    annotation1.setCloser(() -> {
        myIsClosed1 = true;
        listener.unregisterAnnotation(vf1, annotation1);
    });
    listener.registerAnnotation(vf1, annotation1);
    //up
    runInAndVerifyIgnoreOutput("up", sourceDir.getPath());
    imitateEvent(lfs.refreshAndFindFileByIoFile(sourceDir));
    imitateEvent(lfs.refreshAndFindFileByIoFile(externalDir));
    myChangeListManager.ensureUpToDate(false);
    // wait for after-events like annotations recalculation
    myChangeListManager.ensureUpToDate(false);
    // zipper updater
    sleep(100);
    //verify(runSvn("up", "-r", "3", externalDir.getPath()));
    assertRevision(vf1, diffProvider, 3);
    assertRevision(vf2, diffProvider, 5);
    Assert.assertTrue(myIsClosed1);
    // in source is not closed..
    Assert.assertFalse(myIsClosed);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsAnnotationLocalChangesListener(com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Change(com.intellij.openapi.vcs.changes.Change) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) SvnDiffProvider(org.jetbrains.idea.svn.SvnDiffProvider) Test(org.junit.Test)

Example 14 with VcsAnnotationLocalChangesListener

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

the class SvnAnnotationIsClosedTest method testClosedByUpdateInIdea.

@Test
public void testClosedByUpdateInIdea() 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();
    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);
    myDirtyScopeManager.markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    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 15 with VcsAnnotationLocalChangesListener

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

the class SvnAnnotationIsClosedTest method testClosedByUpdateWithExternals.

@Test
public void testClosedByUpdateWithExternals() throws Exception {
    prepareExternal();
    final File sourceFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "s1.txt");
    final File externalFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "external" + File.separator + "t12.txt");
    final LocalFileSystem lfs = LocalFileSystem.getInstance();
    final VirtualFile vf1 = lfs.refreshAndFindFileByIoFile(sourceFile);
    final VirtualFile vf2 = lfs.refreshAndFindFileByIoFile(externalFile);
    Assert.assertNotNull(vf1);
    Assert.assertNotNull(vf2);
    VcsTestUtil.editFileInCommand(myProject, vf1, "test externals 123" + System.currentTimeMillis());
    VcsTestUtil.editFileInCommand(myProject, vf2, "test externals 123" + System.currentTimeMillis());
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    myChangeListManager.ensureUpToDate(false);
    final Change change1 = myChangeListManager.getChange(vf1);
    final Change change2 = myChangeListManager.getChange(vf2);
    Assert.assertNotNull(change1);
    Assert.assertNotNull(change2);
    final File sourceDir = new File(myWorkingCopyDir.getPath(), "source");
    final File externalDir = new File(myWorkingCopyDir.getPath(), "source/external");
    // #3
    runInAndVerifyIgnoreOutput("ci", "-m", "test", sourceDir.getPath());
    // #4
    runInAndVerifyIgnoreOutput("ci", "-m", "test", externalDir.getPath());
    VcsTestUtil.editFileInCommand(myProject, vf2, "test externals 12344444" + System.currentTimeMillis());
    // #5
    runInAndVerifyIgnoreOutput("ci", "-m", "test", externalDir.getPath());
    final SvnDiffProvider diffProvider = (SvnDiffProvider) myVcs.getDiffProvider();
    assertRevision(vf1, diffProvider, 3);
    assertRevision(vf2, diffProvider, 5);
    runInAndVerifyIgnoreOutput("up", "-r", "4", sourceDir.getPath());
    runInAndVerifyIgnoreOutput("up", "-r", "4", externalDir.getPath());
    assertRevision(vf1, diffProvider, 3);
    assertRevision(vf2, diffProvider, 4);
    // then annotate both
    final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
    final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), vf1);
    annotation.setCloser(() -> {
        myIsClosed = true;
        listener.unregisterAnnotation(vf1, annotation);
    });
    listener.registerAnnotation(vf1, annotation);
    final FileAnnotation annotation1 = createTestAnnotation(myVcs.getAnnotationProvider(), vf2);
    annotation1.setCloser(() -> {
        myIsClosed1 = true;
        listener.unregisterAnnotation(vf1, annotation1);
    });
    listener.registerAnnotation(vf1, annotation1);
    //up
    runInAndVerifyIgnoreOutput("up", sourceDir.getPath());
    imitateEvent(lfs.refreshAndFindFileByIoFile(sourceDir));
    imitateEvent(lfs.refreshAndFindFileByIoFile(externalDir));
    myChangeListManager.ensureUpToDate(false);
    // wait for after-events like annotations recalculation
    myChangeListManager.ensureUpToDate(false);
    // zipper updater
    sleep(100);
    //verify(runSvn("up", "-r", "3", externalDir.getPath()));
    assertRevision(vf1, diffProvider, 3);
    assertRevision(vf2, diffProvider, 5);
    Assert.assertTrue(myIsClosed1);
    // in source is not closed..
    Assert.assertFalse(myIsClosed);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsAnnotationLocalChangesListener(com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Change(com.intellij.openapi.vcs.changes.Change) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Test(org.junit.Test)

Aggregations

VcsAnnotationLocalChangesListener (com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener)17 FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)16 Test (org.junit.Test)16 Change (com.intellij.openapi.vcs.changes.Change)10 VcsException (com.intellij.openapi.vcs.VcsException)4 LocalFileSystem (com.intellij.openapi.vfs.LocalFileSystem)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)4 ActionManager (com.intellij.openapi.actionSystem.ActionManager)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)2 VcsConfiguration (com.intellij.openapi.vcs.VcsConfiguration)2 VcsTestUtil (com.intellij.openapi.vcs.VcsTestUtil)2 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)2 VcsDirtyScopeManager (com.intellij.openapi.vcs.changes.VcsDirtyScopeManager)2 ProjectLevelVcsManagerEx (com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx)2 VcsRevisionDescription (com.intellij.openapi.vcs.history.VcsRevisionDescription)2 CommonUpdateProjectAction (com.intellij.openapi.vcs.update.CommonUpdateProjectAction)2