comparison test/org/tmatesoft/hg/test/TestBlame.java @ 568:8ed4f4f4f0a6

Blame facility refactored, get ready for follow/no-follow support
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 10 Apr 2013 15:45:53 +0200
parents 6fbca6506bb5
children 36853bb80a35
comparison
equal deleted inserted replaced
567:88f04c7cfedb 568:8ed4f4f4f0a6
68 HgRepository repo = new HgLookup().detectFromWorkingDir(); 68 HgRepository repo = new HgLookup().detectFromWorkingDir();
69 final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java"; 69 final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java";
70 final int checkChangeset = 539; 70 final int checkChangeset = 539;
71 HgDataFile df = repo.getFileNode(fname); 71 HgDataFile df = repo.getFileNode(fname);
72 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 72 ByteArrayOutputStream bos = new ByteArrayOutputStream();
73 new HgBlameFacility().annotateSingleRevision(df, checkChangeset, new DiffOutInspector(new PrintStream(bos))); 73 new HgBlameFacility(df).annotateSingleRevision(checkChangeset, new DiffOutInspector(new PrintStream(bos)));
74 LineGrepOutputParser gp = new LineGrepOutputParser("^@@.+"); 74 LineGrepOutputParser gp = new LineGrepOutputParser("^@@.+");
75 ExecHelper eh = new ExecHelper(gp, null); 75 ExecHelper eh = new ExecHelper(gp, null);
76 eh.run("hg", "diff", "-c", String.valueOf(checkChangeset), "-U", "0", fname); 76 eh.run("hg", "diff", "-c", String.valueOf(checkChangeset), "-U", "0", fname);
77 // 77 //
78 String[] apiResult = splitLines(bos.toString()); 78 String[] apiResult = splitLines(bos.toString());
139 139
140 @Test 140 @Test
141 public void testComplexHistoryAnnotate() throws Exception { 141 public void testComplexHistoryAnnotate() throws Exception {
142 HgRepository repo = Configuration.get().find("test-annotate"); 142 HgRepository repo = Configuration.get().find("test-annotate");
143 HgDataFile df = repo.getFileNode("file1"); 143 HgDataFile df = repo.getFileNode("file1");
144 HgBlameFacility af = new HgBlameFacility(); 144 HgBlameFacility af = new HgBlameFacility(df);
145 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 145 ByteArrayOutputStream bos = new ByteArrayOutputStream();
146 DiffOutInspector dump = new DiffOutInspector(new PrintStream(bos)); 146 DiffOutInspector dump = new DiffOutInspector(new PrintStream(bos));
147 af.annotate(df, TIP, dump, HgIterateDirection.OldToNew); 147 af.annotate(TIP, dump, HgIterateDirection.OldToNew);
148 LinkedList<String> apiResult = new LinkedList<String>(Arrays.asList(splitLines(bos.toString()))); 148 LinkedList<String> apiResult = new LinkedList<String>(Arrays.asList(splitLines(bos.toString())));
149 149
150 /* 150 /*
151 * FIXME this is an ugly hack to deal with the way `hg diff -c <mergeRev>` describes the change 151 * FIXME this is an ugly hack to deal with the way `hg diff -c <mergeRev>` describes the change
152 * and our merge handling approach. For merged revision m, and lines changed both in p1 and p2 152 * and our merge handling approach. For merged revision m, and lines changed both in p1 and p2
225 private void aaa() throws Exception { 225 private void aaa() throws Exception {
226 HgRepository repo = new HgLookup().detectFromWorkingDir(); 226 HgRepository repo = new HgLookup().detectFromWorkingDir();
227 final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java"; 227 final String fname = "src/org/tmatesoft/hg/internal/PatchGenerator.java";
228 final int checkChangeset = 539; 228 final int checkChangeset = 539;
229 HgDataFile df = repo.getFileNode(fname); 229 HgDataFile df = repo.getFileNode(fname);
230 HgBlameFacility af = new HgBlameFacility(); 230 HgBlameFacility af = new HgBlameFacility(df);
231 DiffOutInspector dump = new DiffOutInspector(System.out); 231 DiffOutInspector dump = new DiffOutInspector(System.out);
232 System.out.println("541 -> 543"); 232 System.out.println("541 -> 543");
233 af.annotateSingleRevision(df, 543, dump); 233 af.annotateSingleRevision(543, dump);
234 System.out.println("539 -> 541"); 234 System.out.println("539 -> 541");
235 af.annotateSingleRevision(df, 541, dump); 235 af.annotateSingleRevision(541, dump);
236 System.out.println("536 -> 539"); 236 System.out.println("536 -> 539");
237 af.annotateSingleRevision(df, checkChangeset, dump); 237 af.annotateSingleRevision(checkChangeset, dump);
238 System.out.println("531 -> 536"); 238 System.out.println("531 -> 536");
239 af.annotateSingleRevision(df, 536, dump); 239 af.annotateSingleRevision(536, dump);
240 System.out.println(" -1 -> 531"); 240 System.out.println(" -1 -> 531");
241 af.annotateSingleRevision(df, 531, dump); 241 af.annotateSingleRevision(531, dump);
242 242
243 FileAnnotateInspector fai = new FileAnnotateInspector(); 243 FileAnnotateInspector fai = new FileAnnotateInspector();
244 FileAnnotation.annotate(df, 541, fai); 244 FileAnnotation.annotate(df, 541, fai);
245 for (int i = 0; i < fai.lineRevisions.length; i++) { 245 for (int i = 0; i < fai.lineRevisions.length; i++) {
246 System.out.printf("%3d: LINE %d\n", fai.lineRevisions[i], i+1); 246 System.out.printf("%3d: LINE %d\n", fai.lineRevisions[i], i+1);
250 private void bbb() throws Exception { 250 private void bbb() throws Exception {
251 HgRepository repo = new HgLookup().detectFromWorkingDir(); 251 HgRepository repo = new HgLookup().detectFromWorkingDir();
252 final String fname = "src/org/tmatesoft/hg/repo/HgManifest.java"; 252 final String fname = "src/org/tmatesoft/hg/repo/HgManifest.java";
253 final int checkChangeset = 415; 253 final int checkChangeset = 415;
254 HgDataFile df = repo.getFileNode(fname); 254 HgDataFile df = repo.getFileNode(fname);
255 HgBlameFacility af = new HgBlameFacility(); 255 HgBlameFacility af = new HgBlameFacility(df);
256 DiffOutInspector dump = new DiffOutInspector(System.out); 256 DiffOutInspector dump = new DiffOutInspector(System.out);
257 // System.out.println("413 -> 415"); 257 // System.out.println("413 -> 415");
258 // af.diff(df, 413, 415, dump); 258 // af.diff(df, 413, 415, dump);
259 // System.out.println("408 -> 415"); 259 // System.out.println("408 -> 415");
260 // af.diff(df, 408, 415, dump); 260 // af.diff(df, 408, 415, dump);
261 // System.out.println("Combined (with merge):"); 261 // System.out.println("Combined (with merge):");
262 // dump.needRevisions(true); 262 // dump.needRevisions(true);
263 // af.annotateChange(df, checkChangeset, dump); 263 // af.annotateChange(df, checkChangeset, dump);
264 dump.needRevisions(true); 264 dump.needRevisions(true);
265 af.annotate(df, checkChangeset, dump, HgIterateDirection.OldToNew); 265 af.annotate(checkChangeset, dump, HgIterateDirection.OldToNew);
266 } 266 }
267 267
268 private void ccc() throws Throwable { 268 private void ccc() throws Throwable {
269 HgRepository repo = new HgLookup().detect("/home/artem/hg/hgtest-annotate-merge/"); 269 HgRepository repo = new HgLookup().detect("/home/artem/hg/hgtest-annotate-merge/");
270 HgDataFile df = repo.getFileNode("file.txt"); 270 HgDataFile df = repo.getFileNode("file.txt");
271 HgBlameFacility af = new HgBlameFacility(); 271 HgBlameFacility af = new HgBlameFacility(df);
272 DiffOutInspector dump = new DiffOutInspector(System.out); 272 DiffOutInspector dump = new DiffOutInspector(System.out);
273 dump.needRevisions(true); 273 dump.needRevisions(true);
274 af.annotate(df, 8, dump, HgIterateDirection.NewToOld); 274 af.annotate(8, dump, HgIterateDirection.NewToOld);
275 // af.annotateSingleRevision(df, 113, dump); 275 // af.annotateSingleRevision(df, 113, dump);
276 // System.out.println(); 276 // System.out.println();
277 // af.annotate(df, TIP, new LineDumpInspector(true), HgIterateDirection.NewToOld); 277 // af.annotate(df, TIP, new LineDumpInspector(true), HgIterateDirection.NewToOld);
278 // System.out.println(); 278 // System.out.println();
279 // af.annotate(df, TIP, new LineDumpInspector(false), HgIterateDirection.NewToOld); 279 // af.annotate(df, TIP, new LineDumpInspector(false), HgIterateDirection.NewToOld);