comparison src/org/tmatesoft/hg/internal/ForwardAnnotateInspector.java @ 680:58a6900f845d

Blame: alternative strategy to handle merge revisions: map(diff(p1->base->p2)) to understand merge intentions better
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 21 Jul 2013 17:15:34 +0200
parents 1c49c0cee540
children f1f095e42555
comparison
equal deleted inserted replaced
679:19f5167c2155 680:58a6900f845d
15 * contact TMate Software at support@hg4j.com 15 * contact TMate Software at support@hg4j.com
16 */ 16 */
17 package org.tmatesoft.hg.internal; 17 package org.tmatesoft.hg.internal;
18 18
19 import org.tmatesoft.hg.core.HgAnnotateCommand.Inspector; 19 import org.tmatesoft.hg.core.HgAnnotateCommand.Inspector;
20 import org.tmatesoft.hg.core.HgAnnotateCommand.LineInfo;
21 import org.tmatesoft.hg.core.HgBlameInspector; 20 import org.tmatesoft.hg.core.HgBlameInspector;
22 import org.tmatesoft.hg.core.HgCallbackTargetException; 21 import org.tmatesoft.hg.core.HgCallbackTargetException;
23 import org.tmatesoft.hg.core.HgDiffCommand;
24 import org.tmatesoft.hg.core.HgException;
25 import org.tmatesoft.hg.core.HgIterateDirection; 22 import org.tmatesoft.hg.core.HgIterateDirection;
26 import org.tmatesoft.hg.repo.HgLookup;
27 import org.tmatesoft.hg.repo.HgRepository;
28 import org.tmatesoft.hg.util.CancelSupport; 23 import org.tmatesoft.hg.util.CancelSupport;
29 import org.tmatesoft.hg.util.CancelledException; 24 import org.tmatesoft.hg.util.CancelledException;
30 import org.tmatesoft.hg.util.ProgressSupport; 25 import org.tmatesoft.hg.util.ProgressSupport;
31 26
32 /** 27 /**
139 } 134 }
140 } 135 }
141 originPos += originBlockLen; 136 originPos += originBlockLen;
142 } 137 }
143 } 138 }
144
145
146 public static void main(String[] args) throws HgCallbackTargetException, CancelledException, HgException {
147 HgRepository repo = new HgLookup().detect("/home/artem/hg/junit-test-repos/test-annotate/");
148 HgDiffCommand cmd = new HgDiffCommand(repo);
149 cmd.file(repo.getFileNode("file1")).order(HgIterateDirection.OldToNew);
150 final int cset = 8;
151 cmd.range(0, cset);
152 final ForwardAnnotateInspector c2 = new ForwardAnnotateInspector();
153 cmd.executeAnnotate(c2);
154 for (IntTuple t : c2.all.get(cset)) {
155 System.out.printf("Block %d lines from revision %d (starts with line %d in the origin)\n", t.at(0), t.at(1), 1+t.at(2));
156 }
157 c2.report(cset, new Inspector() {
158
159 public void next(LineInfo lineInfo) throws HgCallbackTargetException {
160 System.out.printf("%3d:%3d: %s", lineInfo.getChangesetIndex(), lineInfo.getOriginLineNumber(), new String(lineInfo.getContent()));
161 }
162 }, ProgressSupport.Factory.get(null), CancelSupport.Factory.get(null));
163 }
164 } 139 }