diff cmdline/org/tmatesoft/hg/console/Main.java @ 254:a620f0663a37

Collect tags for a file - improve performance of 'sparse' manifest reads
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 16 Aug 2011 04:03:29 +0200
parents 1874d11054e5
children c6450b0b1fd5
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java	Mon Aug 15 18:59:05 2011 +0200
+++ b/cmdline/org/tmatesoft/hg/console/Main.java	Tue Aug 16 04:03:29 2011 +0200
@@ -18,6 +18,7 @@
 
 import static org.tmatesoft.hg.repo.HgRepository.TIP;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -33,6 +34,7 @@
 import org.tmatesoft.hg.internal.ByteArrayChannel;
 import org.tmatesoft.hg.internal.DigestHelper;
 import org.tmatesoft.hg.internal.PathGlobMatcher;
+import org.tmatesoft.hg.internal.RelativePathRewrite;
 import org.tmatesoft.hg.repo.HgBranches;
 import org.tmatesoft.hg.repo.HgChangelog;
 import org.tmatesoft.hg.repo.HgDataFile;
@@ -46,8 +48,11 @@
 import org.tmatesoft.hg.repo.HgSubrepoLocation.Kind;
 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector;
 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
+import org.tmatesoft.hg.util.FileIterator;
+import org.tmatesoft.hg.util.FileWalker;
 import org.tmatesoft.hg.util.Pair;
 import org.tmatesoft.hg.util.Path;
+import org.tmatesoft.hg.util.PathRewrite;
 
 /**
  * Various debug dumps. 
@@ -72,10 +77,11 @@
 
 	public static void main(String[] args) throws Exception {
 		Main m = new Main(args);
+		m.testTreeTraversal();
 //		m.testRevisionMap();
 //		m.testSubrepos();
 //		m.testReadWorkingCopy();
-		m.testParents();
+//		m.testParents();
 //		m.testEffectiveFileLog();
 //		m.testCatAtCsetRevision();
 //		m.testMergeState();
@@ -91,6 +97,19 @@
 //		m.bunchOfTests();
 	}
 	
+	private void testTreeTraversal() throws Exception {
+		File repoRoot = hgRepo.getWorkingDir();
+		Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(repoRoot), hgRepo.getToRepoPathHelper()));
+		FileWalker w =  new FileWalker(repoRoot, pathSrc);
+		int count = 0;
+		final long start = System.currentTimeMillis();
+		while (w.hasNext()) {
+			count++;
+			w.next();
+		}
+		System.out.printf("Traversal of %d files took %d ms", count, System.currentTimeMillis() - start);
+	}
+	
 	/*
 	 * cpython repo with 70715 revisions.
 	 	3 revisions - 80 ms vs 250 ms (250ms init)