comparison test/org/tmatesoft/hg/test/TestBlame.java @ 552:45751456b471

Annotate file changes through few revisions, walking either direction (old to new and vice versa)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 20 Feb 2013 22:23:50 +0100
parents 83afa680555d
children 093a2022dad5
comparison
equal deleted inserted replaced
551:4ea0351ca878 552:45751456b471
28 28
29 import org.junit.Assert; 29 import org.junit.Assert;
30 import org.junit.Rule; 30 import org.junit.Rule;
31 import org.junit.Test; 31 import org.junit.Test;
32 import org.tmatesoft.hg.console.Bundle.Dump; 32 import org.tmatesoft.hg.console.Bundle.Dump;
33 import org.tmatesoft.hg.core.HgIterateDirection;
33 import org.tmatesoft.hg.internal.AnnotateFacility; 34 import org.tmatesoft.hg.internal.AnnotateFacility;
34 import org.tmatesoft.hg.internal.AnnotateFacility.AddBlock; 35 import org.tmatesoft.hg.internal.AnnotateFacility.AddBlock;
35 import org.tmatesoft.hg.internal.AnnotateFacility.Block; 36 import org.tmatesoft.hg.internal.AnnotateFacility.Block;
36 import org.tmatesoft.hg.internal.AnnotateFacility.ChangeBlock; 37 import org.tmatesoft.hg.internal.AnnotateFacility.ChangeBlock;
37 import org.tmatesoft.hg.internal.AnnotateFacility.DeleteBlock; 38 import org.tmatesoft.hg.internal.AnnotateFacility.DeleteBlock;
76 final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java"; 77 final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java";
77 HgDataFile df = repo.getFileNode(fname); 78 HgDataFile df = repo.getFileNode(fname);
78 OutputParser.Stub op = new OutputParser.Stub(); 79 OutputParser.Stub op = new OutputParser.Stub();
79 ExecHelper eh = new ExecHelper(op, null); 80 ExecHelper eh = new ExecHelper(op, null);
80 81
81 for (int startChangeset : new int[] { TIP, /*539, 541/ *, TIP */}) { 82 for (int startChangeset : new int[] { 539, 541 /*, TIP */}) {
82 FileAnnotateInspector fa = new FileAnnotateInspector(); 83 FileAnnotateInspector fa = new FileAnnotateInspector();
83 new AnnotateFacility().annotate(df, startChangeset, fa); 84 new AnnotateFacility().annotate(df, startChangeset, fa);
84 85
85 86
86 op.reset(); 87 op.reset();
140 af.annotateChange(df, 536, dump); 141 af.annotateChange(df, 536, dump);
141 System.out.println(" -1 -> 531"); 142 System.out.println(" -1 -> 531");
142 af.annotateChange(df, 531, dump); 143 af.annotateChange(df, 531, dump);
143 144
144 FileAnnotateInspector fai = new FileAnnotateInspector(); 145 FileAnnotateInspector fai = new FileAnnotateInspector();
145 af.annotate(df, TIP, fai); 146 af.annotate(df, 541, fai);
146 for (int i = 0; i < fai.lineRevisions.length; i++) { 147 for (int i = 0; i < fai.lineRevisions.length; i++) {
147 System.out.printf("%3d: LINE %d\n", fai.lineRevisions[i], i+1); 148 System.out.printf("%3d: LINE %d\n", fai.lineRevisions[i], i+1);
148 } 149 }
149 } 150 }
150 151
153 final String fname = "src/org/tmatesoft/hg/repo/HgManifest.java"; 154 final String fname = "src/org/tmatesoft/hg/repo/HgManifest.java";
154 final int checkChangeset = 415; 155 final int checkChangeset = 415;
155 HgDataFile df = repo.getFileNode(fname); 156 HgDataFile df = repo.getFileNode(fname);
156 AnnotateFacility af = new AnnotateFacility(); 157 AnnotateFacility af = new AnnotateFacility();
157 DiffOutInspector dump = new DiffOutInspector(System.out); 158 DiffOutInspector dump = new DiffOutInspector(System.out);
158 System.out.println("413 -> 415"); 159 // System.out.println("413 -> 415");
159 af.diff(df, 413, 415, dump); 160 // af.diff(df, 413, 415, dump);
160 System.out.println("408 -> 415"); 161 // System.out.println("408 -> 415");
161 af.diff(df, 408, 415, dump); 162 // af.diff(df, 408, 415, dump);
162 System.out.println("Combined (with merge):"); 163 // System.out.println("Combined (with merge):");
164 // dump.needRevisions(true);
165 // af.annotateChange(df, checkChangeset, dump);
163 dump.needRevisions(true); 166 dump.needRevisions(true);
164 af.annotateChange(df, checkChangeset, dump); 167 af.annotate(df, checkChangeset, dump, HgIterateDirection.OldToNew);
165 } 168 }
166 169
167 private void leftovers() throws Exception { 170 private void leftovers() throws Exception {
168 IntMap<String> linesOld = new IntMap<String>(100), linesNew = new IntMap<String>(100); 171 IntMap<String> linesOld = new IntMap<String>(100), linesNew = new IntMap<String>(100);
169 System.out.println("Changes to old revision:"); 172 System.out.println("Changes to old revision:");