Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Main.java @ 479:59b7c817bc4d
Methods from Main graduated as tests
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 12 Jul 2012 20:02:49 +0200 |
parents | e74580e24feb |
children | a458f9fb00ce |
comparison
equal
deleted
inserted
replaced
478:e74580e24feb | 479:59b7c817bc4d |
---|---|
14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.console; | 17 package org.tmatesoft.hg.console; |
18 | 18 |
19 import static org.junit.Assert.*; | |
19 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 20 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
20 import static org.tmatesoft.hg.repo.HgRepository.WORKING_COPY; | 21 import static org.tmatesoft.hg.repo.HgRepository.WORKING_COPY; |
21 import static org.tmatesoft.hg.util.LogFacility.Severity.*; | 22 import static org.tmatesoft.hg.util.LogFacility.Severity.*; |
22 | 23 |
23 import java.io.File; | 24 import java.io.File; |
26 import java.util.Collection; | 27 import java.util.Collection; |
27 import java.util.Collections; | 28 import java.util.Collections; |
28 import java.util.HashSet; | 29 import java.util.HashSet; |
29 import java.util.List; | 30 import java.util.List; |
30 import java.util.Map; | 31 import java.util.Map; |
31 | 32 import java.util.regex.Pattern; |
32 import org.junit.Assert; | 33 |
33 import org.tmatesoft.hg.core.HgManifestHandler; | 34 import org.tmatesoft.hg.core.HgManifestHandler; |
34 import org.tmatesoft.hg.core.HgCallbackTargetException; | 35 import org.tmatesoft.hg.core.HgCallbackTargetException; |
35 import org.tmatesoft.hg.core.HgCatCommand; | 36 import org.tmatesoft.hg.core.HgCatCommand; |
36 import org.tmatesoft.hg.core.HgChangeset; | 37 import org.tmatesoft.hg.core.HgChangeset; |
37 import org.tmatesoft.hg.core.HgChangesetFileSneaker; | 38 import org.tmatesoft.hg.core.HgChangesetFileSneaker; |
42 import org.tmatesoft.hg.core.HgManifestCommand; | 43 import org.tmatesoft.hg.core.HgManifestCommand; |
43 import org.tmatesoft.hg.core.Nodeid; | 44 import org.tmatesoft.hg.core.Nodeid; |
44 import org.tmatesoft.hg.internal.BasicSessionContext; | 45 import org.tmatesoft.hg.internal.BasicSessionContext; |
45 import org.tmatesoft.hg.internal.ByteArrayChannel; | 46 import org.tmatesoft.hg.internal.ByteArrayChannel; |
46 import org.tmatesoft.hg.internal.DigestHelper; | 47 import org.tmatesoft.hg.internal.DigestHelper; |
48 import org.tmatesoft.hg.internal.IntMap; | |
47 import org.tmatesoft.hg.internal.PathGlobMatcher; | 49 import org.tmatesoft.hg.internal.PathGlobMatcher; |
48 import org.tmatesoft.hg.internal.PhasesHelper; | 50 import org.tmatesoft.hg.internal.PhasesHelper; |
49 import org.tmatesoft.hg.internal.RelativePathRewrite; | 51 import org.tmatesoft.hg.internal.RelativePathRewrite; |
50 import org.tmatesoft.hg.internal.RevisionDescendants; | 52 import org.tmatesoft.hg.internal.RevisionDescendants; |
51 import org.tmatesoft.hg.internal.StreamLogFacility; | 53 import org.tmatesoft.hg.internal.StreamLogFacility; |
71 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind; | 73 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind; |
72 import org.tmatesoft.hg.repo.ext.MqManager; | 74 import org.tmatesoft.hg.repo.ext.MqManager; |
73 import org.tmatesoft.hg.repo.ext.MqManager.PatchRecord; | 75 import org.tmatesoft.hg.repo.ext.MqManager.PatchRecord; |
74 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; | 76 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; |
75 import org.tmatesoft.hg.repo.HgRevisionMap; | 77 import org.tmatesoft.hg.repo.HgRevisionMap; |
78 import org.tmatesoft.hg.test.ExecHelper; | |
79 import org.tmatesoft.hg.test.OutputParser; | |
76 import org.tmatesoft.hg.util.FileWalker; | 80 import org.tmatesoft.hg.util.FileWalker; |
77 import org.tmatesoft.hg.util.LogFacility; | 81 import org.tmatesoft.hg.util.LogFacility; |
78 import org.tmatesoft.hg.util.Pair; | 82 import org.tmatesoft.hg.util.Pair; |
79 import org.tmatesoft.hg.util.Path; | 83 import org.tmatesoft.hg.util.Path; |
80 import org.tmatesoft.hg.util.PathRewrite; | 84 import org.tmatesoft.hg.util.PathRewrite; |
103 System.out.println("REPO:" + hgRepo.getLocation()); | 107 System.out.println("REPO:" + hgRepo.getLocation()); |
104 } | 108 } |
105 | 109 |
106 public static void main(String[] args) throws Exception { | 110 public static void main(String[] args) throws Exception { |
107 Main m = new Main(args); | 111 Main m = new Main(args); |
108 // m.checkWalkFileRevisions(); | |
109 // m.buildFileLog(); | 112 // m.buildFileLog(); |
110 // m.testConsoleLog(); | 113 // m.testConsoleLog(); |
111 // m.testTreeTraversal(); | 114 // m.testTreeTraversal(); |
112 // m.testRevisionMap(); | 115 // m.testRevisionMap(); |
113 // m.testSubrepos(); | 116 // m.testSubrepos(); |
114 // m.testReadWorkingCopy(); | 117 // m.testReadWorkingCopy(); |
115 // m.testParents(); | 118 // m.testParents(); |
116 // m.testEffectiveFileLog(); | 119 // m.testEffectiveFileLog(); |
117 // m.testCatAtCsetRevision(); | |
118 // m.testMergeState(); | 120 // m.testMergeState(); |
119 // m.testFileStatus(); | 121 // m.testFileStatus(); |
120 // m.dumpBranches(); | 122 // m.dumpBranches(); |
121 // m.inflaterLengthException(); | 123 // m.inflaterLengthException(); |
122 // m.dumpIgnored(); | 124 // m.dumpIgnored(); |
124 // m.testStatusInternals(); | 126 // m.testStatusInternals(); |
125 // m.catCompleteHistory(); | 127 // m.catCompleteHistory(); |
126 // m.dumpCompleteManifestLow(); | 128 // m.dumpCompleteManifestLow(); |
127 // m.dumpCompleteManifestHigh(); | 129 // m.dumpCompleteManifestHigh(); |
128 // m.bunchOfTests(); | 130 // m.bunchOfTests(); |
129 } | |
130 | |
131 // hg4j repo | |
132 public void checkWalkFileRevisions() throws Exception { | |
133 // hg --debug manifest --rev 150 | grep cmdline/org/tmatesoft/hg/console/Main.java | |
134 hgRepo.getManifest().walkFileRevisions(Path.create("cmdline/org/tmatesoft/hg/console/Main.java"), new ManifestDump(), 100, 150, 200, 210, 300); | |
135 } | 131 } |
136 | 132 |
137 private void buildFileLog() throws Exception { | 133 private void buildFileLog() throws Exception { |
138 final long start = System.nanoTime(); | 134 final long start = System.nanoTime(); |
139 HgLogCommand cmd = new HgLogCommand(hgRepo); | 135 HgLogCommand cmd = new HgLogCommand(hgRepo); |
347 } | 343 } |
348 }); | 344 }); |
349 } | 345 } |
350 System.out.printf("Done: %d\n", System.currentTimeMillis() - start); | 346 System.out.printf("Done: %d\n", System.currentTimeMillis() - start); |
351 } | 347 } |
352 } | |
353 | |
354 // TODO as test in TestCat | |
355 private void testCatAtCsetRevision() throws Exception { | |
356 HgCatCommand cmd = new HgCatCommand(hgRepo); | |
357 final Path file = Path.create("src/org/tmatesoft/hg/internal/RevlogStream.java"); | |
358 cmd.file(file); | |
359 final Nodeid cset = Nodeid.fromAscii("08db726a0fb7914ac9d27ba26dc8bbf6385a0554"); | |
360 cmd.changeset(cset); | |
361 final ByteArrayChannel sink = new ByteArrayChannel(); | |
362 cmd.execute(sink); | |
363 System.out.println(sink.toArray().length); | |
364 HgChangesetFileSneaker i = new HgChangesetFileSneaker(hgRepo); | |
365 boolean result = i.changeset(cset).checkExists(file); | |
366 Assert.assertFalse(result); | |
367 Assert.assertFalse(i.exists()); | |
368 result = i.followRenames(true).checkExists(file); | |
369 Assert.assertTrue(result); | |
370 Assert.assertTrue(i.exists()); | |
371 HgCatCommand cmd2 = new HgCatCommand(hgRepo).revision(i.getFileRevision()); | |
372 final ByteArrayChannel sink2 = new ByteArrayChannel(); | |
373 cmd2.execute(sink2); | |
374 System.out.println(sink2.toArray().length); | |
375 Assert.assertEquals(sink.toArray().length, sink2.toArray().length); | |
376 } | 348 } |
377 | 349 |
378 private void testMergeState() throws Exception { | 350 private void testMergeState() throws Exception { |
379 final HgMergeState mergeState = hgRepo.getMergeState(); | 351 final HgMergeState mergeState = hgRepo.getMergeState(); |
380 mergeState.refresh(); | 352 mergeState.refresh(); |