Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 317:09628675bcee
Rework file history build approach to match rest of the API
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 29 Sep 2011 03:20:28 +0200 |
parents | 3f40262153a4 |
children | a674b8590362 |
comparison
equal
deleted
inserted
replaced
316:ee6b467c1a5f | 317:09628675bcee |
---|---|
84 System.out.println("REPO:" + hgRepo.getLocation()); | 84 System.out.println("REPO:" + hgRepo.getLocation()); |
85 } | 85 } |
86 | 86 |
87 public static void main(String[] args) throws Exception { | 87 public static void main(String[] args) throws Exception { |
88 Main m = new Main(args); | 88 Main m = new Main(args); |
89 // m.buildFileLog(); | 89 m.buildFileLog(); |
90 // m.testConsoleLog(); | 90 // m.testConsoleLog(); |
91 // m.testTreeTraversal(); | 91 // m.testTreeTraversal(); |
92 // m.testRevisionMap(); | 92 // m.testRevisionMap(); |
93 // m.testSubrepos(); | 93 // m.testSubrepos(); |
94 // m.testReadWorkingCopy(); | 94 // m.testReadWorkingCopy(); |
95 // m.testParents(); | 95 // m.testParents(); |
96 // m.testEffectiveFileLog(); | 96 // m.testEffectiveFileLog(); |
97 // m.testCatAtCsetRevision(); | 97 // m.testCatAtCsetRevision(); |
98 // m.testMergeState(); | 98 // m.testMergeState(); |
99 // m.testFileStatus(); | 99 // m.testFileStatus(); |
100 m.dumpBranches(); | 100 // m.dumpBranches(); |
101 // m.inflaterLengthException(); | 101 // m.inflaterLengthException(); |
102 // m.dumpIgnored(); | 102 // m.dumpIgnored(); |
103 // m.dumpDirstate(); | 103 // m.dumpDirstate(); |
104 // m.testStatusInternals(); | 104 // m.testStatusInternals(); |
105 // m.catCompleteHistory(); | 105 // m.catCompleteHistory(); |
108 // m.bunchOfTests(); | 108 // m.bunchOfTests(); |
109 } | 109 } |
110 | 110 |
111 private void buildFileLog() { | 111 private void buildFileLog() { |
112 final HgDataFile fn = hgRepo.getFileNode("file1"); | 112 final HgDataFile fn = hgRepo.getFileNode("file1"); |
113 HgDataFile.HistoryWalker hw = fn.history(); | 113 HgChangelog.TreeInspector insp = new HgChangelog.TreeInspector() { |
114 while (hw.hasNext()) { | 114 |
115 hw.next(); | 115 public void next(Nodeid changesetRevision, Pair<Nodeid, Nodeid> parentChangesets, Collection<Nodeid> childChangesets) { |
116 StringBuilder sb = new StringBuilder(); | 116 StringBuilder sb = new StringBuilder(); |
117 Collection<Nodeid> children = hw.childChangesets(); | 117 for (Nodeid cc : childChangesets) { |
118 for (Nodeid cc : children) { | 118 sb.append(cc.shortNotation()); |
119 sb.append(cc.shortNotation()); | 119 sb.append(", "); |
120 sb.append(", "); | 120 } |
121 } | 121 final boolean isJoin = !parentChangesets.first().isNull() && !parentChangesets.second().isNull(); |
122 if (hw.isJoin()) { | 122 final boolean isFork = childChangesets.size() > 1; |
123 final Pair<Nodeid, Nodeid> parents = hw.parentChangesets(); | 123 if (isJoin) { |
124 System.out.printf("join[(%s, %s) => %s]\n", parents.first().shortNotation(), parents.second().shortNotation(), hw.changesetRevision().shortNotation()); | 124 System.out.printf("join[(%s, %s) => %s]\n", parentChangesets.first().shortNotation(), parentChangesets.second().shortNotation(), changesetRevision.shortNotation()); |
125 } | 125 } |
126 if (hw.isFork()) { | 126 if (isFork) { |
127 System.out.printf("fork[%s => %s]\n", hw.changesetRevision().shortNotation(), sb); | 127 System.out.printf("fork[%s => %s]\n", changesetRevision.shortNotation(), sb); |
128 } | 128 } |
129 if (!hw.isFork() && !hw.isJoin() && !children.isEmpty()) { | 129 if (!isFork && !isJoin && !childChangesets.isEmpty()) { |
130 System.out.printf("%s => %s\n", hw.changesetRevision().shortNotation(), sb); | 130 System.out.printf("%s => %s\n", changesetRevision.shortNotation(), sb); |
131 } | 131 } |
132 } | 132 } |
133 }; | |
134 fn.history(insp); | |
133 } | 135 } |
134 | 136 |
135 private void buildFileLogOld() { | 137 private void buildFileLogOld() { |
136 final HgDataFile fn = hgRepo.getFileNode("file1"); | 138 final HgDataFile fn = hgRepo.getFileNode("file1"); |
137 final int[] fileChangesetRevisions = new int[fn.getRevisionCount()]; | 139 final int[] fileChangesetRevisions = new int[fn.getRevisionCount()]; |