changeset 253:1874d11054e5

HgLogCommand.changeset(Nodeid) to ease command configuration
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 15 Aug 2011 18:59:05 +0200
parents a6d19adc2636
children a620f0663a37
files cmdline/org/tmatesoft/hg/console/Main.java src/org/tmatesoft/hg/core/HgLogCommand.java
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java	Mon Aug 15 18:51:41 2011 +0200
+++ b/cmdline/org/tmatesoft/hg/console/Main.java	Mon Aug 15 18:59:05 2011 +0200
@@ -163,15 +163,12 @@
 		// hg parents cmd
 		final Pair<Nodeid, Nodeid> wcParents = hgRepo.getWorkingCopyParents();
 		ChangesetDumpHandler dump = new ChangesetDumpHandler(hgRepo);
-		final HgChangelog clog = hgRepo.getChangelog();
 		HgLogCommand cmd = new HgLogCommand(hgRepo);
 		if (wcParents.hasFirst()) {
-			int x = clog.getLocalRevision(wcParents.first());
-			cmd.range(x, x).execute(dump); // FIXME HgLogCommand shall support Nodeid as revisions
+			cmd.changeset(wcParents.first()).execute(dump);
 		}
 		if (wcParents.hasSecond()) {
-			int x = clog.getLocalRevision(wcParents.second());
-			cmd.range(x, x).execute(dump);
+			cmd.changeset(wcParents.second()).execute(dump);
 		}
 		System.out.println("Branch:" + hgRepo.getWorkingCopyBranchName());
 	}
--- a/src/org/tmatesoft/hg/core/HgLogCommand.java	Mon Aug 15 18:51:41 2011 +0200
+++ b/src/org/tmatesoft/hg/core/HgLogCommand.java	Mon Aug 15 18:59:05 2011 +0200
@@ -142,6 +142,18 @@
 	}
 	
 	/**
+	 * Select specific changeset
+	 * 
+	 * @param nid changeset revision
+	 * @return <code>this</code> for convenience
+	 */
+	public HgLogCommand changeset(Nodeid nid) {
+		// XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions.
+		final int csetLocal = repo.getChangelog().getLocalRevision(nid);
+		return range(csetLocal, csetLocal);
+	}
+	
+	/**
 	 * Visit history of a given file only.
 	 * @param file path relative to repository root. Pass <code>null</code> to reset.
 	 * @param followCopyRename true to report changesets of the original file(-s), if copy/rename ever occured to the file.