Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 328:a674b8590362
Move file tree history to upper API level
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 05 Oct 2011 07:13:57 +0200 |
| parents | 09628675bcee |
| children | 863356c2847e |
comparison
equal
deleted
inserted
replaced
| 327:3f09b8c19142 | 328:a674b8590362 |
|---|---|
| 20 | 20 |
| 21 import java.io.File; | 21 import java.io.File; |
| 22 import java.util.ArrayList; | 22 import java.util.ArrayList; |
| 23 import java.util.Collection; | 23 import java.util.Collection; |
| 24 import java.util.Collections; | 24 import java.util.Collections; |
| 25 import java.util.HashSet; | |
| 25 import java.util.List; | 26 import java.util.List; |
| 26 import java.util.Map; | 27 import java.util.Map; |
| 27 | 28 |
| 28 import org.junit.Assert; | 29 import org.junit.Assert; |
| 29 import org.tmatesoft.hg.core.HgBadStateException; | 30 import org.tmatesoft.hg.core.HgBadStateException; |
| 30 import org.tmatesoft.hg.core.HgCatCommand; | 31 import org.tmatesoft.hg.core.HgCatCommand; |
| 32 import org.tmatesoft.hg.core.HgChangeset; | |
| 33 import org.tmatesoft.hg.core.HgChangesetTreeHandler; | |
| 31 import org.tmatesoft.hg.core.HgDataStreamException; | 34 import org.tmatesoft.hg.core.HgDataStreamException; |
| 32 import org.tmatesoft.hg.core.HgFileInformer; | 35 import org.tmatesoft.hg.core.HgFileInformer; |
| 33 import org.tmatesoft.hg.core.HgFileRevision; | 36 import org.tmatesoft.hg.core.HgFileRevision; |
| 34 import org.tmatesoft.hg.core.HgLogCommand; | 37 import org.tmatesoft.hg.core.HgLogCommand; |
| 35 import org.tmatesoft.hg.core.HgManifestCommand; | 38 import org.tmatesoft.hg.core.HgManifestCommand; |
| 106 // m.dumpCompleteManifestLow(); | 109 // m.dumpCompleteManifestLow(); |
| 107 // m.dumpCompleteManifestHigh(); | 110 // m.dumpCompleteManifestHigh(); |
| 108 // m.bunchOfTests(); | 111 // m.bunchOfTests(); |
| 109 } | 112 } |
| 110 | 113 |
| 111 private void buildFileLog() { | 114 private void buildFileLog() throws Exception { |
| 112 final HgDataFile fn = hgRepo.getFileNode("file1"); | 115 HgLogCommand cmd = new HgLogCommand(hgRepo); |
| 113 HgChangelog.TreeInspector insp = new HgChangelog.TreeInspector() { | 116 cmd.file("file1", false); |
| 114 | 117 cmd.execute(new HgChangesetTreeHandler() { |
| 115 public void next(Nodeid changesetRevision, Pair<Nodeid, Nodeid> parentChangesets, Collection<Nodeid> childChangesets) { | 118 public void next(org.tmatesoft.hg.core.HgChangesetTreeHandler.TreeElement entry) { |
| 116 StringBuilder sb = new StringBuilder(); | 119 StringBuilder sb = new StringBuilder(); |
| 117 for (Nodeid cc : childChangesets) { | 120 HashSet<Nodeid> test = new HashSet<Nodeid>(entry.childRevisions()); |
| 118 sb.append(cc.shortNotation()); | 121 for (HgChangeset cc : entry.children()) { |
| 122 sb.append(cc.getRevision()); | |
| 123 sb.append(':'); | |
| 124 sb.append(cc.getNodeid().shortNotation()); | |
| 119 sb.append(", "); | 125 sb.append(", "); |
| 120 } | 126 } |
| 121 final boolean isJoin = !parentChangesets.first().isNull() && !parentChangesets.second().isNull(); | 127 final Pair<Nodeid, Nodeid> parents = entry.parentRevisions(); |
| 122 final boolean isFork = childChangesets.size() > 1; | 128 final boolean isJoin = !parents.first().isNull() && !parents.second().isNull(); |
| 129 final boolean isFork = entry.children().size() > 1; | |
| 130 final HgChangeset cset = entry.changeset(); | |
| 131 System.out.printf("%d:%s - %s\n", cset.getRevision(), cset.getNodeid().shortNotation(), cset.getComment()); | |
| 132 if (!isJoin && !isFork && !entry.children().isEmpty()) { | |
| 133 System.out.printf("\t=> %s\n", sb); | |
| 134 } | |
| 123 if (isJoin) { | 135 if (isJoin) { |
| 124 System.out.printf("join[(%s, %s) => %s]\n", parentChangesets.first().shortNotation(), parentChangesets.second().shortNotation(), changesetRevision.shortNotation()); | 136 HgChangeset p1 = entry.parents().first(); |
| 137 HgChangeset p2 = entry.parents().second(); | |
| 138 System.out.printf("\tjoin <= (%d:%s, %d:%s)", p1.getRevision(), p1.getNodeid().shortNotation(), p2.getRevision(), p2.getNodeid().shortNotation()); | |
| 139 if (isFork) { | |
| 140 System.out.print(", "); | |
| 141 } | |
| 125 } | 142 } |
| 126 if (isFork) { | 143 if (isFork) { |
| 127 System.out.printf("fork[%s => %s]\n", changesetRevision.shortNotation(), sb); | 144 if (!isJoin) { |
| 128 } | 145 System.out.print('\t'); |
| 129 if (!isFork && !isJoin && !childChangesets.isEmpty()) { | 146 } |
| 130 System.out.printf("%s => %s\n", changesetRevision.shortNotation(), sb); | 147 System.out.printf("fork => [%s]", sb); |
| 131 } | 148 } |
| 132 } | 149 if (isJoin || isFork) { |
| 133 }; | 150 System.out.println(); |
| 134 fn.history(insp); | 151 } |
| 152 } | |
| 153 }); | |
| 135 } | 154 } |
| 136 | 155 |
| 137 private void buildFileLogOld() { | 156 private void buildFileLogOld() { |
| 138 final HgDataFile fn = hgRepo.getFileNode("file1"); | 157 final HgDataFile fn = hgRepo.getFileNode("file1"); |
| 139 final int[] fileChangesetRevisions = new int[fn.getRevisionCount()]; | 158 final int[] fileChangesetRevisions = new int[fn.getRevisionCount()]; |
