diff cmdline/org/tmatesoft/hg/console/Main.java @ 233:1d389c0cb0a5

Optimize file history walk not to iterat over whole changelog for sparse and distant revisions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 03 Jun 2011 04:50:09 +0200
parents b7347daa50e3
children fd845a53f53d
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java	Thu Jun 02 05:13:39 2011 +0200
+++ b/cmdline/org/tmatesoft/hg/console/Main.java	Fri Jun 03 04:50:09 2011 +0200
@@ -23,6 +23,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.tmatesoft.hg.core.HgLogCommand;
 import org.tmatesoft.hg.core.HgLogCommand.FileRevision;
 import org.tmatesoft.hg.core.HgCatCommand;
 import org.tmatesoft.hg.core.HgFileRevision;
@@ -32,6 +33,7 @@
 import org.tmatesoft.hg.internal.DigestHelper;
 import org.tmatesoft.hg.internal.PathGlobMatcher;
 import org.tmatesoft.hg.repo.HgBranches;
+import org.tmatesoft.hg.repo.HgChangelog;
 import org.tmatesoft.hg.repo.HgDataFile;
 import org.tmatesoft.hg.repo.HgInternals;
 import org.tmatesoft.hg.repo.HgManifest;
@@ -40,6 +42,7 @@
 import org.tmatesoft.hg.repo.HgStatusCollector;
 import org.tmatesoft.hg.repo.HgStatusInspector;
 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector;
+import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
 import org.tmatesoft.hg.util.Path;
 
 /**
@@ -65,7 +68,8 @@
 
 	public static void main(String[] args) throws Exception {
 		Main m = new Main(args);
-		m.testCatAtCsetRevision();
+		m.testEffectiveFileLog();
+//		m.testCatAtCsetRevision();
 //		m.testMergeState();
 //		m.testFileStatus();
 //		m.dumpBranches();
@@ -79,6 +83,20 @@
 //		m.bunchOfTests();
 	}
 	
+	private void testEffectiveFileLog() {
+		for (String fname : cmdLineOpts.getList("")) {
+			System.out.println(fname);
+			HgDataFile fn = hgRepo.getFileNode(fname);
+			if (fn.exists()) {
+				fn.history(new HgChangelog.Inspector() {
+					public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
+						System.out.printf("%d:%s\n", revisionNumber, nodeid);
+					}
+				});
+			}
+		}
+	}
+	
 	// TODO as test in TestCat
 	private void testCatAtCsetRevision() throws Exception {
 		HgCatCommand cmd = new HgCatCommand(hgRepo);
@@ -112,7 +130,7 @@
 //		final Path path = Path.create("src/org/tmatesoft/hg/internal/Experimental.java");
 //		final Path path = Path.create("missing-dir/");
 //		HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, path);
-		HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("missing-dir/**/*"));
+		HgWorkingCopyStatusCollector wcsc = HgWorkingCopyStatusCollector.create(hgRepo, new PathGlobMatcher("mi**"));
 		wcsc.walk(TIP, new StatusDump());
 	}