changeset 124:cea84c5995e6

Changeset to access parent nodeids
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 15 Feb 2011 06:30:05 +0100
parents 4f509f5bc8cb
children 26ad21b250e4
files cmdline/org/tmatesoft/hg/console/Log.java src/org/tmatesoft/hg/core/Cset.java
diffstat 2 files changed, 25 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Log.java	Fri Feb 04 04:06:44 2011 +0100
+++ b/cmdline/org/tmatesoft/hg/console/Log.java	Tue Feb 15 06:30:05 2011 +0100
@@ -176,12 +176,14 @@
 				sb.append('\n');
 			}
 			if (complete) {
-				if (changelogWalker == null) {
-					changelogWalker = repo.getChangelog().new ParentWalker();
-					changelogWalker.init();
-				}
-				Nodeid p1 = changelogWalker.safeFirstParent(csetNodeid);
-				Nodeid p2 = changelogWalker.safeSecondParent(csetNodeid);
+//				if (changelogWalker == null) {
+//					changelogWalker = repo.getChangelog().new ParentWalker();
+//					changelogWalker.init();
+//				}
+//				Nodeid p1 = changelogWalker.safeFirstParent(csetNodeid);
+//				Nodeid p2 = changelogWalker.safeSecondParent(csetNodeid);
+				Nodeid p1 = cset.getFirstParentRevision();
+				Nodeid p2 = cset.getSecondParentRevision();
 				int p1x = p1 == Nodeid.NULL ? -1 : repo.getChangelog().getLocalRevision(p1);
 				int p2x = p2 == Nodeid.NULL ? -1 : repo.getChangelog().getLocalRevision(p2);
 				int mx = repo.getManifest().getLocalRevision(cset.getManifestRevision());
--- a/src/org/tmatesoft/hg/core/Cset.java	Fri Feb 04 04:06:44 2011 +0100
+++ b/src/org/tmatesoft/hg/core/Cset.java	Tue Feb 15 06:30:05 2011 +0100
@@ -117,6 +117,22 @@
 		return deletedFiles;
 	}
 
+	// XXX do I need boolean isMergeRevision()?
+	
+	public Nodeid getFirstParentRevision() {
+		// XXX may read once for both p1 and p2 
+		// or use ParentWalker to minimize reads even more.
+		byte[] p1 = new byte[20];
+		statusHelper.getRepo().getChangelog().parents(revNumber, new int[2], p1, null);
+		return Nodeid.fromBinary(p1, 0);
+	}
+	
+	public Nodeid getSecondParentRevision() {
+		byte[] p2 = new byte[20];
+		statusHelper.getRepo().getChangelog().parents(revNumber, new int[2], null, p2);
+		return Nodeid.fromBinary(p2, 0);
+	}
+
 	@Override
 	public Cset clone() {
 		try {
@@ -150,6 +166,7 @@
 			added.add(new FileRevision(repo, nid, s));
 		}
 		for (Path s : r.getRemoved()) {
+			// with Path from getRemoved, may just copy
 			deleted.add(s);
 		}
 		modified.trimToSize();