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();
}
}
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());
}
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());
}
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());
}
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();
}
Aggregations