comparison cmdline/org/tmatesoft/hg/console/Main.java @ 433:be697c3e951e

Revlog.RevisionMap helper class got promoted as TLC, renamed to HgRevisionMap
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 30 Mar 2012 16:43:09 +0200
parents 12f668401613
children 6865eb742883
comparison
equal deleted inserted replaced
432:1fc0da631200 433:be697c3e951e
63 import org.tmatesoft.hg.repo.HgStatusCollector; 63 import org.tmatesoft.hg.repo.HgStatusCollector;
64 import org.tmatesoft.hg.repo.HgStatusInspector; 64 import org.tmatesoft.hg.repo.HgStatusInspector;
65 import org.tmatesoft.hg.repo.HgSubrepoLocation; 65 import org.tmatesoft.hg.repo.HgSubrepoLocation;
66 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind; 66 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind;
67 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; 67 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector;
68 import org.tmatesoft.hg.repo.HgRevisionMap;
68 import org.tmatesoft.hg.util.FileWalker; 69 import org.tmatesoft.hg.util.FileWalker;
69 import org.tmatesoft.hg.util.LogFacility; 70 import org.tmatesoft.hg.util.LogFacility;
70 import org.tmatesoft.hg.util.Pair; 71 import org.tmatesoft.hg.util.Pair;
71 import org.tmatesoft.hg.util.Path; 72 import org.tmatesoft.hg.util.Path;
72 import org.tmatesoft.hg.util.PathRewrite; 73 import org.tmatesoft.hg.util.PathRewrite;
286 Hence, with 20-30 ms per regular getLocalRevision, it pays off to use RevisionMap with at least 15-20 287 Hence, with 20-30 ms per regular getLocalRevision, it pays off to use RevisionMap with at least 15-20
287 queries 288 queries
288 */ 289 */
289 private void testRevisionMap() throws Exception { 290 private void testRevisionMap() throws Exception {
290 HgChangelog changelog = hgRepo.getChangelog(); 291 HgChangelog changelog = hgRepo.getChangelog();
291 HgChangelog.RevisionMap rmap = changelog.new RevisionMap().init(); // warm-up, ensure complete file read 292 HgRevisionMap<HgChangelog> rmap = new HgRevisionMap<HgChangelog>(changelog).init(); // warm-up, ensure complete file read
292 int tip = changelog.getLastRevision(); 293 int tip = changelog.getLastRevision();
293 // take 5 arbitrary revisions at 0, 1/4, 2/4, 3/4 and 4/4 294 // take 5 arbitrary revisions at 0, 1/4, 2/4, 3/4 and 4/4
294 final Nodeid[] revs = new Nodeid[5]; 295 final Nodeid[] revs = new Nodeid[5];
295 revs[4] = changelog.getRevision(0); 296 revs[4] = changelog.getRevision(0);
296 revs[3] = changelog.getRevision(tip / 4); 297 revs[3] = changelog.getRevision(tip / 4);
304 } 305 }
305 System.out.println(System.currentTimeMillis() - start); 306 System.out.println(System.currentTimeMillis() - start);
306 System.out.println(); 307 System.out.println();
307 // 308 //
308 start = System.currentTimeMillis(); 309 start = System.currentTimeMillis();
309 rmap = changelog.new RevisionMap().init(); 310 rmap = new HgRevisionMap<HgChangelog>(changelog).init();
310 long s2 = System.currentTimeMillis(); 311 long s2 = System.currentTimeMillis();
311 for (int i = 0; i < revs.length; i++) { 312 for (int i = 0; i < revs.length; i++) {
312 final int localRev = rmap.revisionIndex(revs[i]); 313 final int localRev = rmap.revisionIndex(revs[i]);
313 System.out.printf("%d:%s\n", localRev, revs[i]); 314 System.out.printf("%d:%s\n", localRev, revs[i]);
314 } 315 }