comparison 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
comparison
equal deleted inserted replaced
682:f568330dd9c0 683:98ff1fb49abe
21 import static org.tmatesoft.hg.repo.HgRepository.TIP; 21 import static org.tmatesoft.hg.repo.HgRepository.TIP;
22 22
23 import java.io.IOException; 23 import java.io.IOException;
24 import java.nio.ByteBuffer; 24 import java.nio.ByteBuffer;
25 25
26 import org.tmatesoft.hg.internal.CsetParamKeeper;
26 import org.tmatesoft.hg.repo.HgDataFile; 27 import org.tmatesoft.hg.repo.HgDataFile;
27 import org.tmatesoft.hg.repo.HgRepository; 28 import org.tmatesoft.hg.repo.HgRepository;
28 import org.tmatesoft.hg.repo.HgRuntimeException; 29 import org.tmatesoft.hg.repo.HgRuntimeException;
29 import org.tmatesoft.hg.util.Adaptable; 30 import org.tmatesoft.hg.util.Adaptable;
30 import org.tmatesoft.hg.util.ByteChannel; 31 import org.tmatesoft.hg.util.ByteChannel;
72 * 73 *
73 * @param fileRevisionIndex - revision local index, non-negative, or one of predefined constants. Note, use of {@link HgRepository#BAD_REVISION}, 74 * @param fileRevisionIndex - revision local index, non-negative, or one of predefined constants. Note, use of {@link HgRepository#BAD_REVISION},
74 * although possible, makes little sense (command would fail if executed). 75 * although possible, makes little sense (command would fail if executed).
75 * @return <code>this</code> for convenience 76 * @return <code>this</code> for convenience
76 */ 77 */
77 public HgCatCommand revision(int fileRevisionIndex) { 78 public HgCatCommand revision(int fileRevisionIndex) { // TODO [2.0 API break] shall throw HgBadArgumentException, like other commands do
78 if (wrongRevisionIndex(fileRevisionIndex)) { 79 if (wrongRevisionIndex(fileRevisionIndex)) {
79 throw new IllegalArgumentException(String.valueOf(fileRevisionIndex)); 80 throw new IllegalArgumentException(String.valueOf(fileRevisionIndex));
80 } 81 }
81 revisionIndex = fileRevisionIndex; 82 revisionIndex = fileRevisionIndex;
82 revision = null; 83 revision = null;
125 revisionIndex = BAD_REVISION; 126 revisionIndex = BAD_REVISION;
126 revision = null; 127 revision = null;
127 cset = nodeid; 128 cset = nodeid;
128 // TODO [2.0 API break] shall use CsetParamKeeper instead, but Exception thrown would break the API 129 // TODO [2.0 API break] shall use CsetParamKeeper instead, but Exception thrown would break the API
129 return this; 130 return this;
131 }
132
133 /**
134 * Select file by changeset
135 * @see #changeset(Nodeid)
136 * @param revisionIndex index of changelog revision
137 * @return <code>this</code> for convenience
138 * @throws HgBadArgumentException if failed to find supplied changeset revision
139 */
140 public HgCatCommand changeset(int revisionIndex) throws HgBadArgumentException {
141 int ri = new CsetParamKeeper(repo).set(revisionIndex).get();
142 return changeset(repo.getChangelog().getRevision(ri));
130 } 143 }
131 144
132 /** 145 /**
133 * Runs the command with current set of parameters and pipes data to provided sink. 146 * Runs the command with current set of parameters and pipes data to provided sink.
134 * 147 *