comparison cmdline/org/tmatesoft/hg/console/Main.java @ 516:0ae5768081aa

Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 18 Dec 2012 18:57:03 +0100
parents e6c8b9b654b2
children 0be5be8d57e9
comparison
equal deleted inserted replaced
515:e6c8b9b654b2 516:0ae5768081aa
172 } 172 }
173 173
174 private void buildFileLog() throws Exception { 174 private void buildFileLog() throws Exception {
175 final long start = System.nanoTime(); 175 final long start = System.nanoTime();
176 HgLogCommand cmd = new HgLogCommand(hgRepo); 176 HgLogCommand cmd = new HgLogCommand(hgRepo);
177 cmd.file("file1b.txt", true); 177 cmd.file("file1b.txt", true, true);
178 final int[] count = new int[] { 0 }; 178 final int[] count = new int[] { 0 };
179 class MyHandler implements HgChangesetTreeHandler, Adaptable { 179 class MyHandler implements HgChangesetTreeHandler, Adaptable {
180 public void treeElement(HgChangesetTreeHandler.TreeElement entry) { 180 public void treeElement(HgChangesetTreeHandler.TreeElement entry) {
181 StringBuilder sb = new StringBuilder(); 181 StringBuilder sb = new StringBuilder();
182 HashSet<Nodeid> test = new HashSet<Nodeid>(entry.childRevisions()); 182 HashSet<Nodeid> test = new HashSet<Nodeid>(entry.childRevisions());
189 final Pair<Nodeid, Nodeid> parents = entry.parentRevisions(); 189 final Pair<Nodeid, Nodeid> parents = entry.parentRevisions();
190 final boolean isJoin = !parents.first().isNull() && !parents.second().isNull(); 190 final boolean isJoin = !parents.first().isNull() && !parents.second().isNull();
191 final boolean isFork = entry.children().size() > 1; 191 final boolean isFork = entry.children().size() > 1;
192 final HgChangeset cset = entry.changeset(); 192 final HgChangeset cset = entry.changeset();
193 System.out.printf("%d:%s - %s (%s)\n", cset.getRevisionIndex(), cset.getNodeid().shortNotation(), cset.getComment(), cset.getPhase()); 193 System.out.printf("%d:%s - %s (%s)\n", cset.getRevisionIndex(), cset.getNodeid().shortNotation(), cset.getComment(), cset.getPhase());
194 System.out.printf("Known as %s (file rev:%s)\n", entry.file().getPath(), entry.fileRevision().shortNotation()); 194 System.out.printf("\tKnown as %s (file rev:%s)\n", entry.file().getPath(), entry.fileRevision().shortNotation());
195 if (!isJoin && !isFork && !entry.children().isEmpty()) { 195 if (!isJoin && !isFork && !entry.children().isEmpty()) {
196 HgChangeset p1 = entry.parents().first();
197 HgChangeset p2 = entry.parents().second();
198 System.out.printf("\tp1:%d, p2:%d\n", p1 == null ? -1 : p1.getRevisionIndex(), p2 == null ? -1 : p2.getRevisionIndex());
196 System.out.printf("\t=> %s\n", sb); 199 System.out.printf("\t=> %s\n", sb);
197 } 200 }
198 if (isJoin) { 201 if (isJoin) {
199 HgChangeset p1 = entry.parents().first(); 202 HgChangeset p1 = entry.parents().first();
200 HgChangeset p2 = entry.parents().second(); 203 HgChangeset p2 = entry.parents().second();