comparison cmdline/org/tmatesoft/hg/console/Main.java @ 474:09f2d38ecf26

Tests for phases support
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 12 Jul 2012 15:36:21 +0200
parents 2a0b09eec376
children 0e34b8f3946a
comparison
equal deleted inserted replaced
473:5c09a9f2e073 474:09f2d38ecf26
155 System.out.printf("Queues: %s, active:%s\n", mqManager.getQueueNames(), mqManager.getActiveQueueName()); 155 System.out.printf("Queues: %s, active:%s\n", mqManager.getQueueNames(), mqManager.getActiveQueueName());
156 Assert.assertTrue(mqManager.getQueueNames().size() > 1); 156 Assert.assertTrue(mqManager.getQueueNames().size() > 1);
157 Assert.assertTrue(mqManager.getActiveQueueName().length() > 0); 157 Assert.assertTrue(mqManager.getActiveQueueName().length() > 0);
158 } 158 }
159 159
160
161 // -R ${system_property:user.home}/hg/test-phases/
162 // TODO as junit test
163 private void dumpPhases() throws Exception {
164 HgPhase[] result1 = new HgPhase[hgRepo.getChangelog().getRevisionCount()];
165 HgPhase[] result2 = new HgPhase[hgRepo.getChangelog().getRevisionCount()];
166 final long start1 = System.nanoTime();
167 HgParentChildMap<HgChangelog> pw = new HgParentChildMap<HgChangelog>(hgRepo.getChangelog());
168 pw.init();
169 final long start1bis = System.nanoTime();
170 PhasesHelper ph = new PhasesHelper(hgRepo, pw);
171 for (int i = 0, l = hgRepo.getChangelog().getLastRevision(); i <= l; i++) {
172 result1[i] = ph.getPhase(i, null);
173 }
174 final long start2 = System.nanoTime();
175 ph = new PhasesHelper(hgRepo);
176 for (int i = 0, l = hgRepo.getChangelog().getLastRevision(); i <= l; i++) {
177 result2[i] = ph.getPhase(i, null);
178 }
179 final long end = System.nanoTime();
180 System.out.printf("With ParentWalker(simulates log command for whole repo): %d ms (pw init: %,d ns)\n", (start2 - start1)/1000, start1bis - start1);
181 printPhases(result1);
182 System.out.printf("Without ParentWalker (simulates log command for single file): %d ms\n", (end - start2)/1000);
183 printPhases(result2);
184 }
185
186 private static void printPhases(HgPhase[] phase) {
187 for (int i = 0; i < phase.length; i++) {
188 System.out.printf("rev:%3d, phase:%s\n", i, phase[i]);
189 }
190 }
191
192 // hg4j repo 160 // hg4j repo
193 public void checkWalkFileRevisions() throws Exception { 161 public void checkWalkFileRevisions() throws Exception {
194 // hg --debug manifest --rev 150 | grep cmdline/org/tmatesoft/hg/console/Main.java 162 // hg --debug manifest --rev 150 | grep cmdline/org/tmatesoft/hg/console/Main.java
195 hgRepo.getManifest().walkFileRevisions(Path.create("cmdline/org/tmatesoft/hg/console/Main.java"), new ManifestDump(), 100, 150, 200, 210, 300); 163 hgRepo.getManifest().walkFileRevisions(Path.create("cmdline/org/tmatesoft/hg/console/Main.java"), new ManifestDump(), 100, 150, 200, 210, 300);
196 } 164 }