Search in sources :

Example 6 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class ActionsTest method testActionInsideCommandSurroundedWithSomeChanges.

public void testActionInsideCommandSurroundedWithSomeChanges() throws Exception {
    // see testActionInsideCommand comment
    final VirtualFile f = createFile("f.txt");
    CommandProcessor.getInstance().executeCommand(myProject, new RunnableAdapter() {

        @Override
        public void doRun() throws IOException {
            setContent(f, "file");
            setDocumentTextFor(f, "doc1");
            LocalHistoryAction a = LocalHistory.getInstance().startAction("action");
            setDocumentTextFor(f, "doc2");
            a.finish();
            saveDocument(f);
            setContent(f, "doc3");
        }
    }, "command", null);
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(4, rr.size());
    assertContent("doc3", rr.get(0).findEntry());
    assertContent("doc1", rr.get(1).findEntry());
    assertContent("", rr.get(2).findEntry());
    assertEquals("command", rr.get(1).getChangeSetName());
    assertNull(rr.get(2).getChangeSetName());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RunnableAdapter(com.intellij.history.utils.RunnableAdapter) Revision(com.intellij.history.core.revisions.Revision) LocalHistoryAction(com.intellij.history.LocalHistoryAction) IOException(java.io.IOException)

Example 7 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class BasicsTest method testPuttingSystemLabel.

public void testPuttingSystemLabel() throws IOException {
    VirtualFile f = createChildData(myRoot, "file.txt");
    assertEquals(2, getRevisionsFor(f).size());
    assertEquals(2, getRevisionsFor(myRoot).size());
    LocalHistory.getInstance().putSystemLabel(myProject, "label");
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(3, rr.size());
    assertEquals("label", rr.get(1).getLabel());
    rr = getRevisionsFor(myRoot);
    assertEquals(3, rr.size());
    assertEquals("label", rr.get(1).getLabel());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision)

Example 8 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class BasicsTest method testPuttingUserLabel.

public void testPuttingUserLabel() throws Exception {
    VirtualFile f = createChildData(myRoot, "f.txt");
    LocalHistory.getInstance().putUserLabel(myProject, "global");
    assertEquals(3, getRevisionsFor(f).size());
    assertEquals(3, getRevisionsFor(myRoot).size());
    LocalHistory.getInstance().putUserLabel(myProject, "file");
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(4, rr.size());
    assertEquals("file", rr.get(1).getLabel());
    assertEquals(-1, rr.get(1).getLabelColor());
    assertEquals("global", rr.get(2).getLabel());
    assertEquals(-1, rr.get(2).getLabelColor());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision)

Example 9 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class BasicsTest method testPuttingLabelWithUnsavedDocuments.

public void testPuttingLabelWithUnsavedDocuments() throws Exception {
    VirtualFile f = createChildData(myRoot, "f.txt");
    setContent(f, "1");
    setDocumentTextFor(f, "2");
    LocalHistory.getInstance().putSystemLabel(myProject, "label");
    setDocumentTextFor(f, "3");
    LocalHistory.getInstance().putUserLabel(myProject, "label");
    setDocumentTextFor(f, "4");
    LocalHistory.getInstance().putUserLabel(myProject, "label");
    List<Revision> rr = getRevisionsFor(f);
    // 5 changes + 3 labels
    assertEquals(9, rr.size());
    assertEquals("4", new String(rr.get(0).findEntry().getContent().getBytes()));
    assertEquals("4", new String(rr.get(1).findEntry().getContent().getBytes()));
    assertEquals("3", new String(rr.get(2).findEntry().getContent().getBytes()));
    assertEquals("3", new String(rr.get(3).findEntry().getContent().getBytes()));
    assertEquals("2", new String(rr.get(4).findEntry().getContent().getBytes()));
    assertEquals("2", new String(rr.get(5).findEntry().getContent().getBytes()));
    assertEquals("1", new String(rr.get(6).findEntry().getContent().getBytes()));
    assertEquals("", new String(rr.get(7).findEntry().getContent().getBytes()));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision)

Example 10 with Revision

use of com.intellij.history.core.revisions.Revision in project intellij-community by JetBrains.

the class PurgingTest method testLabelsAfterPurge.

@Test
public void testLabelsAfterPurge() throws IOException {
    Clock.setTime(1);
    VirtualFile file = createFile("file");
    Clock.setTime(2);
    LocalHistory.getInstance().putUserLabel(myProject, "1");
    getVcs().getChangeListInTests().purgeObsolete(1);
    List<Revision> rr = getRevisionsFor(file);
    assertEquals(2, rr.size());
    assertEquals("1", rr.get(1).getLabel());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision) Test(org.junit.Test)

Aggregations

Revision (com.intellij.history.core.revisions.Revision)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)29 Difference (com.intellij.history.core.revisions.Difference)7 Test (org.junit.Test)6 Entry (com.intellij.history.core.tree.Entry)5 Block (com.intellij.diff.Block)4 LocalHistoryAction (com.intellij.history.LocalHistoryAction)3 ArrayList (java.util.ArrayList)3 Module (com.intellij.openapi.module.Module)2 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)2 File (java.io.File)2 ChangeRevision (com.intellij.history.core.revisions.ChangeRevision)1 RecentChange (com.intellij.history.core.revisions.RecentChange)1 DifferenceReverter (com.intellij.history.integration.revertion.DifferenceReverter)1 DirectoryChangeModel (com.intellij.history.integration.ui.models.DirectoryChangeModel)1 SelectionCalculator (com.intellij.history.integration.ui.models.SelectionCalculator)1 RunnableAdapter (com.intellij.history.utils.RunnableAdapter)1 Change (com.intellij.openapi.vcs.changes.Change)1 IOException (java.io.IOException)1 Date (java.util.Date)1