diff src/com/tmate/hgkit/ll/StatusCollector.java @ 56:576d6e8a09f6

Analog of 'hg status --change' command
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 17 Jan 2011 05:15:13 +0100
parents 05829a70b30b
children b771e94a4f7c
line wrap: on
line diff
--- a/src/com/tmate/hgkit/ll/StatusCollector.java	Mon Jan 17 04:45:09 2011 +0100
+++ b/src/com/tmate/hgkit/ll/StatusCollector.java	Mon Jan 17 05:15:13 2011 +0100
@@ -24,6 +24,10 @@
 	public StatusCollector(HgRepository hgRepo) {
 		this.repo = hgRepo;
 		cache = new HashMap<Integer, ManifestRevisionInspector>();
+		ManifestRevisionInspector emptyFakeState = new ManifestRevisionInspector(-1, -1);
+		emptyFakeState.begin(-1, null);
+		emptyFakeState.end(-1);
+		cache.put(-1, emptyFakeState);
 	}
 	
 	private ManifestRevisionInspector get(int rev) {
@@ -35,7 +39,17 @@
 		}
 		return i;
 	}
+	
+	// hg status --change <rev>
+	public void change(int rev, Inspector inspector) {
+		int[] parents = new int[2];
+		repo.getChangelog().parents(rev, parents, null, null);
+		walk(parents[0], rev, inspector);
+	}
 
+	// I assume revision numbers are the same for changelog and manifest - here 
+	// user would like to pass changelog revision numbers, and I use them directly to walk manifest.
+	// if this assumption is wrong, fix this (lookup manifest revisions from changeset).
 	public void walk(int rev1, int rev2, Inspector inspector) {
 		if (rev1 == rev2) {
 			throw new IllegalArgumentException();
@@ -198,6 +212,7 @@
 
 		/**
 		 * [minRev, maxRev]
+		 * [-1,-1] also accepted (for fake empty instance)
 		 * @param minRev - inclusive
 		 * @param maxRev - inclusive
 		 */