Search in sources :

Example 11 with Difference

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

the class DirectoryEntryTest method testCaseInsensitiveChildrenDiffProcessing.

@Test
public void testCaseInsensitiveChildrenDiffProcessing() {
    DirectoryEntry e1 = new DirectoryEntry("dir");
    Content content = c("content");
    final String name = "name";
    final String name_v2 = "NAME";
    final String name2 = "Name2";
    final String name2_v2 = "name2";
    e1.addChild(new FileEntry(name, content, -1, false));
    e1.addChild(new FileEntry(name2, content, -1, false));
    DirectoryEntry e2 = new DirectoryEntry("dir");
    e2.addChild(new FileEntry(name_v2, content, -1, false));
    e2.addChild(new FileEntry(name2_v2, content, -1, false));
    try {
        Paths.setCaseSensitive(false);
        List<Difference> differences = Entry.getDifferencesBetween(e1, e2);
        assertEquals(2, differences.size());
        assertEquals(name, differences.get(0).getLeft().getName());
        assertEquals(name_v2, differences.get(0).getRight().getName());
        assertEquals(name2, differences.get(1).getLeft().getName());
        assertEquals(name2_v2, differences.get(1).getRight().getName());
    } finally {
        Paths.useSystemCaseSensitivity();
    }
}
Also used : StoredContent(com.intellij.history.core.StoredContent) Content(com.intellij.history.core.Content) Difference(com.intellij.history.core.revisions.Difference) Test(org.junit.Test)

Example 12 with Difference

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

the class FileEntryTest method assertDifference.

private void assertDifference(List<Difference> dd, Entry left, Entry right) {
    assertEquals(1, dd.size());
    Difference d = dd.get(0);
    assertTrue(d.isFile());
    assertSame(left, d.getLeft());
    assertSame(right, d.getRight());
}
Also used : Difference(com.intellij.history.core.revisions.Difference)

Example 13 with Difference

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

the class RevisionsAndDiffsTest method testDoesNotIncludeNotModifiedDifferences.

public void testDoesNotIncludeNotModifiedDifferences() throws IOException {
    getVcs().beginChangeSet();
    VirtualFile dir = createDirectory("dir1");
    createFile("dir1/dir2/file.txt");
    createDirectory("dir1/dir3");
    getVcs().endChangeSet(null);
    createFile("dir1/dir3/file.txt");
    List<Revision> rr = getRevisionsFor(dir);
    Revision recent = rr.get(0);
    Revision prev = rr.get(1);
    List<Difference> dd = prev.getDifferencesWith(recent);
    assertEquals(1, dd.size());
    Difference d = dd.get(0);
    assertNull(d.getLeft());
    assertEquals(myRoot.getPath() + "/dir1/dir3/file.txt", d.getRight().getPath());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision) Difference(com.intellij.history.core.revisions.Difference)

Example 14 with Difference

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

the class RevisionsAndDiffsTest method testGettingDifferenceBetweenRevisions.

public void testGettingDifferenceBetweenRevisions() throws IOException {
    VirtualFile f = createFile("file.txt", "one");
    loadContent(f);
    setContent(f, "two");
    List<Revision> rr = getRevisionsFor(f);
    Revision recent = rr.get(0);
    Revision prev = rr.get(1);
    List<Difference> dd = prev.getDifferencesWith(recent);
    assertEquals(1, dd.size());
    Difference d = dd.get(0);
    assertContent("one", d.getLeft());
    assertContent("two", d.getRight());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Revision(com.intellij.history.core.revisions.Revision) Difference(com.intellij.history.core.revisions.Difference)

Example 15 with Difference

use of com.intellij.history.core.revisions.Difference 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)

Aggregations

Difference (com.intellij.history.core.revisions.Difference)15 Revision (com.intellij.history.core.revisions.Revision)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 ArrayList (java.util.ArrayList)4 Entry (com.intellij.history.core.tree.Entry)3 DirectoryChangeModel (com.intellij.history.integration.ui.models.DirectoryChangeModel)2 Change (com.intellij.openapi.vcs.changes.Change)2 Content (com.intellij.history.core.Content)1 StoredContent (com.intellij.history.core.StoredContent)1 DirectoryEntry (com.intellij.history.core.tree.DirectoryEntry)1 THashMap (gnu.trove.THashMap)1 THashSet (gnu.trove.THashSet)1 TIntObjectHashMap (gnu.trove.TIntObjectHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Test (org.junit.Test)1