diff src/org/tmatesoft/hg/core/HgCatCommand.java @ 683:98ff1fb49abe

Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 24 Jul 2013 16:40:15 +0200
parents 78a9e26e670d
children b286222158be
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/HgCatCommand.java	Mon Jul 22 22:47:06 2013 +0200
+++ b/src/org/tmatesoft/hg/core/HgCatCommand.java	Wed Jul 24 16:40:15 2013 +0200
@@ -23,6 +23,7 @@
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
+import org.tmatesoft.hg.internal.CsetParamKeeper;
 import org.tmatesoft.hg.repo.HgDataFile;
 import org.tmatesoft.hg.repo.HgRepository;
 import org.tmatesoft.hg.repo.HgRuntimeException;
@@ -74,7 +75,7 @@
 	 * although possible, makes little sense (command would fail if executed).  
  	 * @return <code>this</code> for convenience
 	 */
-	public HgCatCommand revision(int fileRevisionIndex) {
+	public HgCatCommand revision(int fileRevisionIndex) { // TODO [2.0 API break] shall throw HgBadArgumentException, like other commands do
 		if (wrongRevisionIndex(fileRevisionIndex)) {
 			throw new IllegalArgumentException(String.valueOf(fileRevisionIndex));
 		}
@@ -130,6 +131,18 @@
 	}
 
 	/**
+	 * Select file by changeset
+	 * @see #changeset(Nodeid) 
+	 * @param revisionIndex index of changelog revision
+	 * @return <code>this</code> for convenience
+	 * @throws HgBadArgumentException if failed to find supplied changeset revision
+	 */
+	public HgCatCommand changeset(int revisionIndex) throws HgBadArgumentException {
+		int ri = new CsetParamKeeper(repo).set(revisionIndex).get();
+		return changeset(repo.getChangelog().getRevision(ri));
+	}
+
+	/**
 	 * Runs the command with current set of parameters and pipes data to provided sink.
 	 * 
 	 * @param sink output channel to write data to.