Mercurial > hg4j
comparison cmdline/org/tmatesoft/hg/console/Log.java @ 80:4222b04f34ee
Follow history of a file
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Tue, 25 Jan 2011 03:54:32 +0100 |
| parents | c677e1593919 |
| children | 61eedab3eb3e |
comparison
equal
deleted
inserted
replaced
| 79:5f9635c01681 | 80:4222b04f34ee |
|---|---|
| 82 for (String fname : cmdLineOpts.files) { | 82 for (String fname : cmdLineOpts.files) { |
| 83 HgDataFile f1 = hgRepo.getFileNode(fname); | 83 HgDataFile f1 = hgRepo.getFileNode(fname); |
| 84 System.out.println("History of the file: " + f1.getPath()); | 84 System.out.println("History of the file: " + f1.getPath()); |
| 85 String normalizesName = hgRepo.getPathHelper().rewrite(fname); | 85 String normalizesName = hgRepo.getPathHelper().rewrite(fname); |
| 86 if (cmdLineOpts.limit == -1) { | 86 if (cmdLineOpts.limit == -1) { |
| 87 cmd.file(Path.create(normalizesName)).execute(dump); | 87 cmd.file(Path.create(normalizesName), true).execute(dump); |
| 88 } else { | 88 } else { |
| 89 int[] r = new int[] { 0, f1.getRevisionCount() }; | 89 int[] r = new int[] { 0, f1.getRevisionCount() }; |
| 90 if (fixRange(r, dump.reverseOrder, cmdLineOpts.limit) == 0) { | 90 if (fixRange(r, dump.reverseOrder, cmdLineOpts.limit) == 0) { |
| 91 System.out.println("No changes"); | 91 System.out.println("No changes"); |
| 92 continue; | 92 continue; |
| 93 } | 93 } |
| 94 cmd.range(r[0], r[1]).file(Path.create(normalizesName)).execute(dump); | 94 cmd.range(r[0], r[1]).file(Path.create(normalizesName), true).execute(dump); |
| 95 } | 95 } |
| 96 dump.complete(); | 96 dump.complete(); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 // | 99 // |
| 113 int rv = start_end[1] - start_end[0]; | 113 int rv = start_end[1] - start_end[0]; |
| 114 start_end[1]--; // range needs index, not length | 114 start_end[1]--; // range needs index, not length |
| 115 return rv; | 115 return rv; |
| 116 } | 116 } |
| 117 | 117 |
| 118 private static final class Dump implements LogCommand.Handler { | 118 private static final class Dump implements LogCommand.FileHistoryHandler { |
| 119 // params | 119 // params |
| 120 boolean complete = false; // roughly --debug | 120 boolean complete = false; // roughly --debug |
| 121 boolean reverseOrder = false; | 121 boolean reverseOrder = false; |
| 122 boolean verbose = true; // roughly -v | 122 boolean verbose = true; // roughly -v |
| 123 // own | 123 // own |
| 128 | 128 |
| 129 public Dump(HgRepository hgRepo) { | 129 public Dump(HgRepository hgRepo) { |
| 130 repo = hgRepo; | 130 repo = hgRepo; |
| 131 tip = hgRepo.getChangelog().getRevisionCount() - 1; | 131 tip = hgRepo.getChangelog().getRevisionCount() - 1; |
| 132 } | 132 } |
| 133 | |
| 134 public void copy(FileRevision from, FileRevision to) { | |
| 135 System.out.printf("Got notified that %s(%s) was originally known as %s(%s)\n", to.getPath(), to.getRevision(), from.getPath(), from.getRevision()); | |
| 136 } | |
| 133 | 137 |
| 134 public void next(Cset changeset) { | 138 public void next(Cset changeset) { |
| 135 final String s = print(changeset); | 139 final String s = print(changeset); |
| 136 if (reverseOrder) { | 140 if (reverseOrder) { |
| 141 // XXX in fact, need to insert s into l according to changeset.getRevision() | |
| 142 // because when file history is being followed, revisions of the original file (with smaller revNumber) | |
| 143 // are reported *after* revisions of present file and with addFirst appear above them | |
| 137 l.addFirst(s); | 144 l.addFirst(s); |
| 138 } else { | 145 } else { |
| 139 System.out.print(s); | 146 System.out.print(s); |
| 140 } | 147 } |
| 141 } | 148 } |
