Mercurial > hg4j
diff test/org/tmatesoft/hg/test/TestBlame.java @ 548:ab21ac7dd833
Line-by-line annotation API and support code in place
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 18 Feb 2013 19:58:51 +0100 |
parents | cd78e8b9d7bc |
children | 83afa680555d |
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestBlame.java Mon Feb 18 19:58:10 2013 +0100 +++ b/test/org/tmatesoft/hg/test/TestBlame.java Mon Feb 18 19:58:51 2013 +0100 @@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; +import static org.tmatesoft.hg.repo.HgRepository.TIP; import java.io.ByteArrayOutputStream; import java.io.PrintStream; @@ -67,25 +68,26 @@ public void testFileAnnotate() throws Exception { HgRepository repo = new HgLookup().detectFromWorkingDir(); final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java"; - final int[] checkChangesets = new int[] { 539 , 536, 531 }; HgDataFile df = repo.getFileNode(fname); - AnnotateFacility af = new AnnotateFacility(); - FileAnnotateInspector fa = new FileAnnotateInspector(); - for (int cs : checkChangesets) { - af.annotateChange(df, cs, new FileAnnotation(fa)); - } - OutputParser.Stub op = new OutputParser.Stub(); ExecHelper eh = new ExecHelper(op, null); - eh.run("hg", "annotate", "-r", String.valueOf(checkChangesets[0]), fname); - - String[] hgAnnotateLines = splitLines(op.result()); - assertTrue("[sanity]", hgAnnotateLines.length > 0); - assertEquals("Number of lines reported by native annotate and our impl", hgAnnotateLines.length, fa.lineRevisions.length); - for (int i = 0; i < fa.lineRevisions.length; i++) { - int hgAnnotateRevIndex = Integer.parseInt(hgAnnotateLines[i].substring(0, hgAnnotateLines[i].indexOf(':'))); - assertEquals(String.format("Revision mismatch for line %d", i+1), hgAnnotateRevIndex, fa.lineRevisions[i]); + for (int startChangeset : new int[] { 539, 541/*, TIP */}) { + FileAnnotateInspector fa = new FileAnnotateInspector(); + new AnnotateFacility().annotate(df, startChangeset, fa); + + + op.reset(); + eh.run("hg", "annotate", "-r", startChangeset == TIP ? "tip" : String.valueOf(startChangeset), fname); + + String[] hgAnnotateLines = splitLines(op.result()); + assertTrue("[sanity]", hgAnnotateLines.length > 0); + assertEquals("Number of lines reported by native annotate and our impl", hgAnnotateLines.length, fa.lineRevisions.length); + + for (int i = 0; i < fa.lineRevisions.length; i++) { + int hgAnnotateRevIndex = Integer.parseInt(hgAnnotateLines[i].substring(0, hgAnnotateLines[i].indexOf(':'))); + assertEquals(String.format("Revision mismatch for line %d", i+1), hgAnnotateRevIndex, fa.lineRevisions[i]); + } } }