comparison test/org/tmatesoft/hg/test/TestBlame.java @ 709:497e697636fc

Report merged lines as changed block if possible, not as a sequence of added/deleted blocks. To facilitate access to merge parent lines AddBlock got mergeLineAt() method that reports index of the line in the second parent (if any), while insertedAt() has been changed to report index in the first parent always
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 21 Aug 2013 16:23:27 +0200
parents 7839ff0bfd78
children
comparison
equal deleted inserted replaced
708:4ffc17c0b534 709:497e697636fc
375 errorCollector.assertEquals("Line text", hgLineText, hg4jResult.getLine(i).trim()); 375 errorCollector.assertEquals("Line text", hgLineText, hg4jResult.getLine(i).trim());
376 errorCollector.assertEquals("Line in origin", hgFirstAppLine, hg4jResult.getOriginLine(i)); 376 errorCollector.assertEquals("Line in origin", hgFirstAppLine, hg4jResult.getOriginLine(i));
377 } 377 }
378 } 378 }
379 379
380 private void ccc() throws Throwable { 380 private void ddd() throws Throwable {
381 HgRepository repo = new HgLookup().detect("/home/artem/hg/hgtest-annotate-merge/"); 381 // HgRepository repo = new HgLookup().detect("/home/artem/hg/blame-merge/");
382 HgDataFile df = repo.getFileNode("file.txt"); 382 HgRepository repo = new HgLookup().detect("/home/artem/hg/junit-test-repos/test-annotate3/");
383 DiffOutInspector dump = new DiffOutInspector(System.out); 383 final DiffOutInspector insp = new DiffOutInspector(System.out);
384 dump.needRevisions(true); 384 insp.needRevisions(true);
385 HgDiffCommand diffCmd = new HgDiffCommand(repo); 385 new HgDiffCommand(repo).file(Path.create("file1")).executeParentsAnnotate(insp);
386 diffCmd.file(df);
387 diffCmd.range(0, 8).order(NewToOld);
388 diffCmd.executeAnnotate(dump);
389 // af.annotateSingleRevision(df, 113, dump);
390 // System.out.println();
391 // af.annotate(df, TIP, new LineDumpInspector(true), HgIterateDirection.NewToOld);
392 // System.out.println();
393 // af.annotate(df, TIP, new LineDumpInspector(false), HgIterateDirection.NewToOld);
394 // System.out.println();
395 /*
396 OutputParser.Stub op = new OutputParser.Stub();
397 eh = new ExecHelper(op, repo.getWorkingDir());
398 for (int cs : new int[] { 24, 46, 49, 52, 59, 62, 64, TIP}) {
399 doLineAnnotateTest(df, cs, op);
400 }
401 errorCollector.verify();
402 */
403 ForwardAnnotateInspector insp = new ForwardAnnotateInspector();
404 diffCmd.range(0, 8).order(insp.iterateDirection());
405 diffCmd.executeAnnotate(insp);
406 AnnotateInspector fa = new AnnotateInspector().fill(8, insp);
407 for (int i = 0; i < fa.changesets.size(); i++) {
408 final String line = fa.lines.get(i);
409 System.out.printf("%d: %s", fa.changesets.get(i), line == null ? "null\n" : line);
410 }
411 } 386 }
412 387
413 public static void main(String[] args) throws Throwable { 388 public static void main(String[] args) throws Throwable {
414 TestBlame tt = new TestBlame(); 389 TestBlame tt = new TestBlame();
415 tt.ccc(); 390 tt.ddd();
416 } 391 }
417 392
418 private static class DiffOutInspector implements HgBlameInspector { 393 private static class DiffOutInspector implements HgBlameInspector {
419 private final PrintStream out; 394 private final PrintStream out;
420 private boolean dumpRevs; 395 private boolean dumpRevs;