Search in sources :

Example 41 with Revision

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

the class RevisionsAndDiffsTest method testIncludingVersionBeforeFirstChangeAfterPurge.

public void testIncludingVersionBeforeFirstChangeAfterPurge() throws IOException {
    Clock.setTime(10);
    VirtualFile f = createFile("file.txt", "one");
    loadContent(f);
    Clock.setTime(20);
    setContent(f, "two");
    getVcs().getChangeListInTests().purgeObsolete(5);
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(2, rr.size());
    assertContent("two", rr.get(0).findEntry());
    assertContent("one", rr.get(1).findEntry());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision)

Example 42 with Revision

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

the class RevisionsAndDiffsTest method testCurrentRevisionForDirectoryAfterPurge.

public void testCurrentRevisionForDirectoryAfterPurge() throws Exception {
    Clock.setTime(10);
    VirtualFile f = createDirectory("dir");
    getVcs().getChangeListInTests().purgeObsolete(0);
    List<Revision> rr = getRevisionsFor(f);
    assertEquals(1, rr.size());
    Revision r = rr.get(0);
    assertNull(r.getLabel());
    assertNull(r.getChangeSetName());
    // directory has no timestamp
    assertEquals(-1, r.getTimestamp());
    Entry e = r.findEntry();
    assertEquals("dir", e.getName());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Entry(com.intellij.history.core.tree.Entry) Revision(com.intellij.history.core.revisions.Revision)

Example 43 with Revision

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

the class DifferenceReverterTest method revertChange.

private void revertChange(int change, int... diffsIndices) throws IOException {
    List<Revision> revs = getRevisionsFor(myRoot);
    Revision leftRev = revs.get(change + 1);
    Revision rightRev = revs.get(change);
    List<Difference> diffs = leftRev.getDifferencesWith(rightRev);
    List<Difference> toRevert = new ArrayList<>();
    for (int i : diffsIndices) {
        toRevert.add(diffs.get(i));
    }
    if (diffsIndices.length == 0)
        toRevert = diffs;
    new DifferenceReverter(myProject, getVcs(), myGateway, toRevert, leftRev).revert();
}
Also used : Revision(com.intellij.history.core.revisions.Revision) ArrayList(java.util.ArrayList) Difference(com.intellij.history.core.revisions.Difference)

Example 44 with Revision

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

the class SelectionCalculatorTest method testSelectionForVeryOldRevisionTakenBackward.

@Test
public void testSelectionForVeryOldRevisionTakenBackward() throws FilesTooBigForDiffException {
    List<Revision> rr = createRevisions("ghi\nabc\ndef", "abc\nghi\ndef", "abc\ndef\nghi");
    SelectionCalculator c = new SelectionCalculator(gw, rr, 0, 1);
    Block b2 = c.getSelectionFor(rr.get(2), new NullProgress());
    Block b1 = c.getSelectionFor(rr.get(1), new NullProgress());
    Block b0 = c.getSelectionFor(rr.get(0), new NullProgress());
    assertBlock(0, 2, "abc\ndef", b0);
    assertBlock(0, 3, "abc\nghi\ndef", b1);
    assertBlock(1, 3, "abc\ndef", b2);
}
Also used : Revision(com.intellij.history.core.revisions.Revision) Block(com.intellij.diff.Block) 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