Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestBlame.java @ 629:5f52074707b2
Diff/blame methods as command, their residence in HgDataFile was a mistake
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 22 May 2013 16:46:15 +0200 |
parents | 6526d8adbc0f |
children | 72c979555cb8 |
comparison
equal
deleted
inserted
replaced
628:6526d8adbc0f | 629:5f52074707b2 |
---|---|
49 import org.tmatesoft.hg.internal.FileAnnotation; | 49 import org.tmatesoft.hg.internal.FileAnnotation; |
50 import org.tmatesoft.hg.internal.FileAnnotation.LineDescriptor; | 50 import org.tmatesoft.hg.internal.FileAnnotation.LineDescriptor; |
51 import org.tmatesoft.hg.internal.FileAnnotation.LineInspector; | 51 import org.tmatesoft.hg.internal.FileAnnotation.LineInspector; |
52 import org.tmatesoft.hg.internal.IntVector; | 52 import org.tmatesoft.hg.internal.IntVector; |
53 import org.tmatesoft.hg.repo.HgBlameInspector; | 53 import org.tmatesoft.hg.repo.HgBlameInspector; |
54 import org.tmatesoft.hg.repo.HgBlameInspector.BlockData; | |
55 import org.tmatesoft.hg.repo.HgChangelog; | 54 import org.tmatesoft.hg.repo.HgChangelog; |
56 import org.tmatesoft.hg.repo.HgDataFile; | 55 import org.tmatesoft.hg.repo.HgDataFile; |
57 import org.tmatesoft.hg.repo.HgLookup; | 56 import org.tmatesoft.hg.repo.HgLookup; |
58 import org.tmatesoft.hg.repo.HgRepository; | 57 import org.tmatesoft.hg.repo.HgRepository; |
59 import org.tmatesoft.hg.util.Path; | 58 import org.tmatesoft.hg.util.Path; |
137 public void testComplexHistoryAnnotate() throws Exception { | 136 public void testComplexHistoryAnnotate() throws Exception { |
138 HgRepository repo = Configuration.get().find("test-annotate"); | 137 HgRepository repo = Configuration.get().find("test-annotate"); |
139 HgDataFile df = repo.getFileNode("file1"); | 138 HgDataFile df = repo.getFileNode("file1"); |
140 ByteArrayOutputStream bos = new ByteArrayOutputStream(); | 139 ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
141 DiffOutInspector dump = new DiffOutInspector(new PrintStream(bos)); | 140 DiffOutInspector dump = new DiffOutInspector(new PrintStream(bos)); |
142 df.annotate(TIP, dump, HgIterateDirection.OldToNew); | 141 df.annotate(0, TIP, dump, HgIterateDirection.OldToNew); |
143 LinkedList<String> apiResult = new LinkedList<String>(Arrays.asList(splitLines(bos.toString()))); | 142 LinkedList<String> apiResult = new LinkedList<String>(Arrays.asList(splitLines(bos.toString()))); |
144 | 143 |
145 /* | 144 /* |
146 * FIXME this is an ugly hack to deal with the way `hg diff -c <mergeRev>` describes the change | 145 * FIXME this is an ugly hack to deal with the way `hg diff -c <mergeRev>` describes the change |
147 * and our merge handling approach. For merged revision m, and lines changed both in p1 and p2 | 146 * and our merge handling approach. For merged revision m, and lines changed both in p1 and p2 |
334 private void ccc() throws Throwable { | 333 private void ccc() throws Throwable { |
335 HgRepository repo = new HgLookup().detect("/home/artem/hg/hgtest-annotate-merge/"); | 334 HgRepository repo = new HgLookup().detect("/home/artem/hg/hgtest-annotate-merge/"); |
336 HgDataFile df = repo.getFileNode("file.txt"); | 335 HgDataFile df = repo.getFileNode("file.txt"); |
337 DiffOutInspector dump = new DiffOutInspector(System.out); | 336 DiffOutInspector dump = new DiffOutInspector(System.out); |
338 dump.needRevisions(true); | 337 dump.needRevisions(true); |
339 df.annotate(8, dump, HgIterateDirection.NewToOld); | 338 df.annotate(0, 8, dump, HgIterateDirection.NewToOld); |
340 // af.annotateSingleRevision(df, 113, dump); | 339 // af.annotateSingleRevision(df, 113, dump); |
341 // System.out.println(); | 340 // System.out.println(); |
342 // af.annotate(df, TIP, new LineDumpInspector(true), HgIterateDirection.NewToOld); | 341 // af.annotate(df, TIP, new LineDumpInspector(true), HgIterateDirection.NewToOld); |
343 // System.out.println(); | 342 // System.out.println(); |
344 // af.annotate(df, TIP, new LineDumpInspector(false), HgIterateDirection.NewToOld); | 343 // af.annotate(df, TIP, new LineDumpInspector(false), HgIterateDirection.NewToOld); |
464 private String[] lines; | 463 private String[] lines; |
465 | 464 |
466 FileAnnotateInspector() { | 465 FileAnnotateInspector() { |
467 } | 466 } |
468 | 467 |
469 public void line(int lineNumber, int changesetRevIndex, BlockData lineContent, LineDescriptor ld) { | 468 public void line(int lineNumber, int changesetRevIndex, HgBlameInspector.BlockData lineContent, LineDescriptor ld) { |
470 if (lineRevisions == null) { | 469 if (lineRevisions == null) { |
471 lineRevisions = new Integer[ld.totalLines()]; | 470 lineRevisions = new Integer[ld.totalLines()]; |
472 Arrays.fill(lineRevisions, NO_REVISION); | 471 Arrays.fill(lineRevisions, NO_REVISION); |
473 lines = new String[ld.totalLines()]; | 472 lines = new String[ld.totalLines()]; |
474 } | 473 } |