Search in sources :

Example 21 with Revision

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

the class SelectionCalculatorTest method testNormalizingLineEnds.

@Test
public void testNormalizingLineEnds() throws FilesTooBigForDiffException {
    List<Revision> rr = createRevisions("abc\ndef\nghi", "abc\r\ndef\r\nghi");
    SelectionCalculator c = new SelectionCalculator(gw, rr, 0, 1);
    Block b0 = c.getSelectionFor(rr.get(0), new NullProgress());
    Block b1 = c.getSelectionFor(rr.get(1), new NullProgress());
    assertBlock(0, 2, "abc\ndef", b0);
    assertBlock(0, 2, "abc\ndef", b1);
}
Also used : Revision(com.intellij.history.core.revisions.Revision) Block(com.intellij.diff.Block) Test(org.junit.Test)

Example 22 with Revision

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

the class RevisionsAndDiffsTest method testRevisions.

public void testRevisions() throws Exception {
    VirtualFile f = createFile("file.txt", "old");
    loadContent(f);
    setContent(f, "new");
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(3, rr.size());
    assertContent("new", rr.get(0).findEntry());
    assertContent("old", rr.get(1).findEntry());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision)

Example 23 with Revision

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

the class RevisionsAndDiffsTest method testRevisionsForFileCreatedWithSameNameAsDeletedOne.

public void testRevisionsForFileCreatedWithSameNameAsDeletedOne() throws IOException {
    VirtualFile f = createFile("file.txt", "old");
    loadContent(f);
    delete(f);
    f = createFile("file.txt", "new");
    loadContent(f);
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(4, rr.size());
    Entry e = rr.get(0).findEntry();
    assertEquals("file.txt", e.getName());
    assertContent("new", e);
    assertNull(rr.get(1).findEntry());
    e = rr.get(2).findEntry();
    assertEquals("file.txt", e.getName());
    assertContent("old", e);
    assertNull(rr.get(3).findEntry());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Entry(com.intellij.history.core.tree.Entry) Revision(com.intellij.history.core.revisions.Revision)

Example 24 with Revision

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

the class RevisionsAndDiffsTest method testRevisionsForFileCreatedInPlaceOfRenamedOne.

public void testRevisionsForFileCreatedInPlaceOfRenamedOne() throws IOException {
    VirtualFile f = createFile("file1.txt", "content1");
    loadContent(f);
    rename(f, "file2.txt");
    VirtualFile ff = createFile("file1.txt", "content2");
    loadContent(ff);
    List<Revision> rr = getRevisionsFor(ff);
    assertEquals(2, rr.size());
    Entry e = rr.get(0).findEntry();
    assertEquals("file1.txt", e.getName());
    assertContent("content2", e);
    rr = getRevisionsFor(f);
    assertEquals(3, rr.size());
    e = rr.get(0).findEntry();
    assertEquals("file2.txt", e.getName());
    assertContent("content1", e);
    e = rr.get(1).findEntry();
    assertEquals("file1.txt", e.getName());
    assertContent("content1", e);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Entry(com.intellij.history.core.tree.Entry) Revision(com.intellij.history.core.revisions.Revision)

Example 25 with Revision

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

the class PatchCreatorTest method createPatchBetweenRevisions.

private void createPatchBetweenRevisions(int left, int right, boolean reverse) throws Exception {
    List<Revision> rr = getRevisionsFor(myRoot);
    Revision l = rr.get(left);
    Revision r = rr.get(right);
    List<Difference> dd = l.getDifferencesWith(r);
    List<Change> cc = new ArrayList<>();
    for (Difference d : dd) {
        Change c = new Change(d.getLeftContentRevision(myGateway), d.getRightContentRevision(myGateway));
        cc.add(c);
    }
    PatchCreator.create(myProject, cc, patchFilePath, reverse, null);
}
Also used : Revision(com.intellij.history.core.revisions.Revision) ArrayList(java.util.ArrayList) Difference(com.intellij.history.core.revisions.Difference) Change(com.intellij.openapi.vcs.changes.Change)

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