Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 417:ccd7d25e5aea
New and better name for HgFileInformer - HgChangesetFileSneaker. Explain (comments) ties between HgManifest, HgDataFile, HgChangesetFileSneaker and reasons for method placement
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 22 Mar 2012 20:14:06 +0100 |
parents | d30083c80d52 |
children | 9c9c442b5f2e |
comparison
equal
deleted
inserted
replaced
416:d30083c80d52 | 417:ccd7d25e5aea |
---|---|
30 import org.junit.Assert; | 30 import org.junit.Assert; |
31 import org.tmatesoft.hg.core.HgBadStateException; | 31 import org.tmatesoft.hg.core.HgBadStateException; |
32 import org.tmatesoft.hg.core.HgCallbackTargetException; | 32 import org.tmatesoft.hg.core.HgCallbackTargetException; |
33 import org.tmatesoft.hg.core.HgCatCommand; | 33 import org.tmatesoft.hg.core.HgCatCommand; |
34 import org.tmatesoft.hg.core.HgChangeset; | 34 import org.tmatesoft.hg.core.HgChangeset; |
35 import org.tmatesoft.hg.core.HgChangesetFileSneaker; | |
35 import org.tmatesoft.hg.core.HgChangesetTreeHandler; | 36 import org.tmatesoft.hg.core.HgChangesetTreeHandler; |
36 import org.tmatesoft.hg.core.HgDataStreamException; | |
37 import org.tmatesoft.hg.core.HgException; | 37 import org.tmatesoft.hg.core.HgException; |
38 import org.tmatesoft.hg.core.HgFileInformer; | |
39 import org.tmatesoft.hg.core.HgFileRevision; | 38 import org.tmatesoft.hg.core.HgFileRevision; |
40 import org.tmatesoft.hg.core.HgLogCommand; | 39 import org.tmatesoft.hg.core.HgLogCommand; |
41 import org.tmatesoft.hg.core.HgManifestCommand; | 40 import org.tmatesoft.hg.core.HgManifestCommand; |
42 import org.tmatesoft.hg.core.Nodeid; | 41 import org.tmatesoft.hg.core.Nodeid; |
43 import org.tmatesoft.hg.internal.ByteArrayChannel; | 42 import org.tmatesoft.hg.internal.ByteArrayChannel; |
134 public void next(HgChangesetTreeHandler.TreeElement entry) { | 133 public void next(HgChangesetTreeHandler.TreeElement entry) { |
135 try { | 134 try { |
136 StringBuilder sb = new StringBuilder(); | 135 StringBuilder sb = new StringBuilder(); |
137 HashSet<Nodeid> test = new HashSet<Nodeid>(entry.childRevisions()); | 136 HashSet<Nodeid> test = new HashSet<Nodeid>(entry.childRevisions()); |
138 for (HgChangeset cc : entry.children()) { | 137 for (HgChangeset cc : entry.children()) { |
139 sb.append(cc.getRevision()); | 138 sb.append(cc.getRevisionIndex()); |
140 sb.append(':'); | 139 sb.append(':'); |
141 sb.append(cc.getNodeid().shortNotation()); | 140 sb.append(cc.getNodeid().shortNotation()); |
142 sb.append(", "); | 141 sb.append(", "); |
143 } | 142 } |
144 final Pair<Nodeid, Nodeid> parents = entry.parentRevisions(); | 143 final Pair<Nodeid, Nodeid> parents = entry.parentRevisions(); |
145 final boolean isJoin = !parents.first().isNull() && !parents.second().isNull(); | 144 final boolean isJoin = !parents.first().isNull() && !parents.second().isNull(); |
146 final boolean isFork = entry.children().size() > 1; | 145 final boolean isFork = entry.children().size() > 1; |
147 final HgChangeset cset = entry.changeset(); | 146 final HgChangeset cset = entry.changeset(); |
148 System.out.printf("%d:%s - %s\n", cset.getRevision(), cset.getNodeid().shortNotation(), cset.getComment()); | 147 System.out.printf("%d:%s - %s\n", cset.getRevisionIndex(), cset.getNodeid().shortNotation(), cset.getComment()); |
149 if (!isJoin && !isFork && !entry.children().isEmpty()) { | 148 if (!isJoin && !isFork && !entry.children().isEmpty()) { |
150 System.out.printf("\t=> %s\n", sb); | 149 System.out.printf("\t=> %s\n", sb); |
151 } | 150 } |
152 if (isJoin) { | 151 if (isJoin) { |
153 HgChangeset p1 = entry.parents().first(); | 152 HgChangeset p1 = entry.parents().first(); |
154 HgChangeset p2 = entry.parents().second(); | 153 HgChangeset p2 = entry.parents().second(); |
155 System.out.printf("\tjoin <= (%d:%s, %d:%s)", p1.getRevision(), p1.getNodeid().shortNotation(), p2.getRevision(), p2.getNodeid().shortNotation()); | 154 System.out.printf("\tjoin <= (%d:%s, %d:%s)", p1.getRevisionIndex(), p1.getNodeid().shortNotation(), p2.getRevisionIndex(), p2.getNodeid().shortNotation()); |
156 if (isFork) { | 155 if (isFork) { |
157 System.out.print(", "); | 156 System.out.print(", "); |
158 } | 157 } |
159 } | 158 } |
160 if (isFork) { | 159 if (isFork) { |
351 final Nodeid cset = Nodeid.fromAscii("08db726a0fb7914ac9d27ba26dc8bbf6385a0554"); | 350 final Nodeid cset = Nodeid.fromAscii("08db726a0fb7914ac9d27ba26dc8bbf6385a0554"); |
352 cmd.changeset(cset); | 351 cmd.changeset(cset); |
353 final ByteArrayChannel sink = new ByteArrayChannel(); | 352 final ByteArrayChannel sink = new ByteArrayChannel(); |
354 cmd.execute(sink); | 353 cmd.execute(sink); |
355 System.out.println(sink.toArray().length); | 354 System.out.println(sink.toArray().length); |
356 HgFileInformer i = new HgFileInformer(hgRepo); | 355 HgChangesetFileSneaker i = new HgChangesetFileSneaker(hgRepo); |
357 boolean result = i.changeset(cset).checkExists(file); | 356 boolean result = i.changeset(cset).checkExists(file); |
358 Assert.assertFalse(result); | 357 Assert.assertFalse(result); |
359 Assert.assertFalse(i.exists()); | 358 Assert.assertFalse(i.exists()); |
360 result = i.followRenames(true).checkExists(file); | 359 result = i.followRenames(true).checkExists(file); |
361 Assert.assertTrue(result); | 360 Assert.assertTrue(result); |