Mercurial > hg4j
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 233:1d389c0cb0a5
Optimize file history walk not to iterat over whole changelog for sparse and distant revisions
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 03 Jun 2011 04:50:09 +0200 |
parents | b7347daa50e3 |
children | fd845a53f53d |
comparison
equal
deleted
inserted
replaced
232:b7347daa50e3 | 233:1d389c0cb0a5 |
---|---|
21 import java.util.ArrayList; | 21 import java.util.ArrayList; |
22 import java.util.Collections; | 22 import java.util.Collections; |
23 import java.util.List; | 23 import java.util.List; |
24 import java.util.Map; | 24 import java.util.Map; |
25 | 25 |
26 import org.tmatesoft.hg.core.HgLogCommand; | |
26 import org.tmatesoft.hg.core.HgLogCommand.FileRevision; | 27 import org.tmatesoft.hg.core.HgLogCommand.FileRevision; |
27 import org.tmatesoft.hg.core.HgCatCommand; | 28 import org.tmatesoft.hg.core.HgCatCommand; |
28 import org.tmatesoft.hg.core.HgFileRevision; | 29 import org.tmatesoft.hg.core.HgFileRevision; |
29 import org.tmatesoft.hg.core.HgManifestCommand; | 30 import org.tmatesoft.hg.core.HgManifestCommand; |
30 import org.tmatesoft.hg.core.Nodeid; | 31 import org.tmatesoft.hg.core.Nodeid; |
31 import org.tmatesoft.hg.internal.ByteArrayChannel; | 32 import org.tmatesoft.hg.internal.ByteArrayChannel; |
32 import org.tmatesoft.hg.internal.DigestHelper; | 33 import org.tmatesoft.hg.internal.DigestHelper; |
33 import org.tmatesoft.hg.internal.PathGlobMatcher; | 34 import org.tmatesoft.hg.internal.PathGlobMatcher; |
34 import org.tmatesoft.hg.repo.HgBranches; | 35 import org.tmatesoft.hg.repo.HgBranches; |
36 import org.tmatesoft.hg.repo.HgChangelog; | |
35 import org.tmatesoft.hg.repo.HgDataFile; | 37 import org.tmatesoft.hg.repo.HgDataFile; |
36 import org.tmatesoft.hg.repo.HgInternals; | 38 import org.tmatesoft.hg.repo.HgInternals; |
37 import org.tmatesoft.hg.repo.HgManifest; | 39 import org.tmatesoft.hg.repo.HgManifest; |
38 import org.tmatesoft.hg.repo.HgMergeState; | 40 import org.tmatesoft.hg.repo.HgMergeState; |
39 import org.tmatesoft.hg.repo.HgRepository; | 41 import org.tmatesoft.hg.repo.HgRepository; |
40 import org.tmatesoft.hg.repo.HgStatusCollector; | 42 import org.tmatesoft.hg.repo.HgStatusCollector; |
41 import org.tmatesoft.hg.repo.HgStatusInspector; | 43 import org.tmatesoft.hg.repo.HgStatusInspector; |
42 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; | 44 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; |
45 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | |
43 import org.tmatesoft.hg.util.Path; | 46 import org.tmatesoft.hg.util.Path; |
44 | 47 |
45 /** | 48 /** |
46 * Various debug dumps. | 49 * Various debug dumps. |
47 * | 50 * |
63 System.out.println("REPO:" + hgRepo.getLocation()); | 66 System.out.println("REPO:" + hgRepo.getLocation()); |
64 } | 67 } |
65 | 68 |
66 public static void main(String[] args) throws Exception { | 69 public static void main(String[] args) throws Exception { |
67 Main m = new Main(args); | 70 Main m = new Main(args); |
68 m.testCatAtCsetRevision(); | 71 m.testEffectiveFileLog(); |
72 // m.testCatAtCsetRevision(); | |
69 // m.testMergeState(); | 73 // m.testMergeState(); |
70 // m.testFileStatus(); | 74 // m.testFileStatus(); |
71 // m.dumpBranches(); | 75 // m.dumpBranches(); |
72 // m.inflaterLengthException(); | 76 // m.inflaterLengthException(); |
73 // m.dumpIgnored(); | 77 // m.dumpIgnored(); |
77 // m.dumpCompleteManifestLow(); | 81 // m.dumpCompleteManifestLow(); |
78 // m.dumpCompleteManifestHigh(); | 82 // m.dumpCompleteManifestHigh(); |
79 // m.bunchOfTests(); | 83 // m.bunchOfTests(); |
80 } | 84 } |
81 | 85 |
86 private void testEffectiveFileLog() { | |
87 for (String fname : cmdLineOpts.getList("")) { | |
88 System.out.println(fname); | |
89 HgDataFile fn = hgRepo.getFileNode(fname); | |
90 if (fn.exists()) { | |
91 fn.history(new HgChangelog.Inspector() { | |
92 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { | |
93 System.out.printf("%d:%s\n", revisionNumber, nodeid); | |
94 } | |
95 }); | |
96 } | |
97 } | |
98 } | |
99 | |
82 // TODO as test in TestCat | 100 // TODO as test in TestCat |
83 private void testCatAtCsetRevision() throws Exception { | 101 private void testCatAtCsetRevision() throws Exception { |
84 HgCatCommand cmd = new HgCatCommand(hgRepo); | 102 HgCatCommand cmd = new HgCatCommand(hgRepo); |
85 cmd.file(Path.create("src/org/tmatesoft/hg/internal/RevlogStream.java")); | 103 cmd.file(Path.create("src/org/tmatesoft/hg/internal/RevlogStream.java")); |
86 cmd.changeset(Nodeid.fromAscii("08db726a0fb7914ac9d27ba26dc8bbf6385a0554")); | 104 cmd.changeset(Nodeid.fromAscii("08db726a0fb7914ac9d27ba26dc8bbf6385a0554")); |
110 private void testFileStatus() { | 128 private void testFileStatus() { |
111 // final Path path = Path.create("src/org/tmatesoft/hg/util/"); | 129 // final Path path = Path.create("src/org/tmatesoft/hg/util/"); |
112 // final Path path = Path.create("src/org/tmatesoft/hg/internal/Experimental.java"); | 130 // final Path path = Path.create("src/org/tmatesoft/hg/internal/Experimental.java"); |
113 // final Path path = Path.create("missing-dir/"); | 131 // final Path path = Path.create("missing-dir/"); |
114 // HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, path); | 132 // HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, path); |
115 HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("missing-dir/**/*")); | 133 HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("mi**")); |
116 wcsc.walk(TIP, new StatusDump()); | 134 wcsc.walk(TIP, new StatusDump()); |
117 } | 135 } |
118 | 136 |
119 private void dumpBranches() { | 137 private void dumpBranches() { |
120 HgBranches b = hgRepo.getBranches(); | 138 HgBranches b = hgRepo.getBranches(); |