comparison src/org/tmatesoft/hg/repo/HgManifest.java @ 425:48f993aa2f41

FIXMEs: exceptions, javadoc
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 28 Mar 2012 18:39:29 +0200
parents 6437d261048a
children 063b0663495a
comparison
equal deleted inserted replaced
424:6437d261048a 425:48f993aa2f41
42 import org.tmatesoft.hg.util.Path; 42 import org.tmatesoft.hg.util.Path;
43 import org.tmatesoft.hg.util.ProgressSupport; 43 import org.tmatesoft.hg.util.ProgressSupport;
44 44
45 45
46 /** 46 /**
47 * 47 * Representation of Mercurial manifest file (list of file names and their revisions in a particular changeset)
48 *
49 * @see http://mercurial.selenic.com/wiki/Manifest
48 * @author Artem Tikhomirov 50 * @author Artem Tikhomirov
49 * @author TMate Software Ltd. 51 * @author TMate Software Ltd.
50 */ 52 */
51 public class HgManifest extends Revlog { 53 public class HgManifest extends Revlog {
52 private RevisionMapper revisionMap; 54 private RevisionMapper revisionMap;
220 /** 222 /**
221 * Tells manifest revision number that corresponds to the given changeset. May return {@link HgRepository#BAD_REVISION} 223 * Tells manifest revision number that corresponds to the given changeset. May return {@link HgRepository#BAD_REVISION}
222 * if changeset has no associated manifest (cset records NULL nodeid for manifest). 224 * if changeset has no associated manifest (cset records NULL nodeid for manifest).
223 * @return manifest revision index, non-negative, or {@link HgRepository#BAD_REVISION}. 225 * @return manifest revision index, non-negative, or {@link HgRepository#BAD_REVISION}.
224 * @throws HgInvalidRevisionException if method argument specifies non-existent revision index 226 * @throws HgInvalidRevisionException if method argument specifies non-existent revision index
225 * @throws IllegalArgumentException if argument is not a revision index
226 * @throws HgInvalidControlFileException if access to revlog index/data entry failed 227 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
227 */ 228 */
228 /*package-local*/ int fromChangelog(int changesetRevisionIndex) throws HgInvalidRevisionException, HgInvalidControlFileException { 229 /*package-local*/ int fromChangelog(int changesetRevisionIndex) throws HgInvalidRevisionException, HgInvalidControlFileException {
229 if (HgInternals.wrongRevisionIndex(changesetRevisionIndex)) { 230 if (HgInternals.wrongRevisionIndex(changesetRevisionIndex)) {
230 throw new IllegalArgumentException(String.valueOf(changesetRevisionIndex)); 231 throw new HgInvalidRevisionException(changesetRevisionIndex);
231 } 232 }
232 if (changesetRevisionIndex == HgRepository.WORKING_COPY || changesetRevisionIndex == HgRepository.BAD_REVISION) { 233 if (changesetRevisionIndex == HgRepository.WORKING_COPY || changesetRevisionIndex == HgRepository.BAD_REVISION) {
233 throw new IllegalArgumentException("Can't use constants like WORKING_COPY or BAD_REVISION"); 234 throw new HgInvalidRevisionException("Can't use constants like WORKING_COPY or BAD_REVISION", null, changesetRevisionIndex);
234 } 235 }
235 // revisionNumber == TIP is processed by RevisionMapper 236 // revisionNumber == TIP is processed by RevisionMapper
236 if (revisionMap == null) { 237 if (revisionMap == null) {
237 revisionMap = new RevisionMapper(getRepo()); 238 revisionMap = new RevisionMapper(getRepo());
238 content.iterate(0, TIP, false, revisionMap); 239 content.iterate(0, TIP, false, revisionMap);
246 * 247 *
247 * @see HgChangesetFileSneaker 248 * @see HgChangesetFileSneaker
248 * @param changelogRevisionIndex local changeset index 249 * @param changelogRevisionIndex local changeset index
249 * @param file path to file in question 250 * @param file path to file in question
250 * @return file revision or <code>null</code> if manifest at specified revision doesn't list such file 251 * @return file revision or <code>null</code> if manifest at specified revision doesn't list such file
251 * @throws HgInvalidRevisionException if method argument specifies non-existent revision index 252 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
252 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
253 */ 253 */
254 public Nodeid getFileRevision(int changelogRevisionIndex, final Path file) throws HgInvalidRevisionException, HgInvalidControlFileException { 254 public Nodeid getFileRevision(int changelogRevisionIndex, final Path file) throws HgInvalidRevisionException, HgInvalidControlFileException {
255 // there's no need for HgDataFile to own this method, or get a delegate 255 // there's no need for HgDataFile to own this method, or get a delegate
256 // as most of HgDataFile API is using file revision indexes, and there's easy step from file revision index to 256 // as most of HgDataFile API is using file revision indexes, and there's easy step from file revision index to
257 // both file revision and changeset revision index. But there's no easy way to go from changesetRevisionIndex to 257 // both file revision and changeset revision index. But there's no easy way to go from changesetRevisionIndex to
279 * 279 *
280 * @see HgDataFile#getFlags(int) 280 * @see HgDataFile#getFlags(int)
281 * @param changesetRevIndex changeset revision index 281 * @param changesetRevIndex changeset revision index
282 * @param file path to look up 282 * @param file path to look up
283 * @return one of predefined enum values, or <code>null</code> if file was not known in the specified revision 283 * @return one of predefined enum values, or <code>null</code> if file was not known in the specified revision
284 * FIXME EXCEPTIONS 284 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
285 * @throws HgInvalidControlFileException
286 * @throws HgInvalidRevisionException
287 */ 285 */
288 public Flags getFileFlags(int changesetRevIndex, Path file) throws HgInvalidRevisionException, HgInvalidControlFileException { 286 public Flags getFileFlags(int changesetRevIndex, Path file) throws HgInvalidRevisionException, HgInvalidControlFileException {
289 int manifestRevIdx = fromChangelog(changesetRevIndex); 287 int manifestRevIdx = fromChangelog(changesetRevIndex);
290 IntMap<Flags> resMap = new IntMap<Flags>(2); 288 IntMap<Flags> resMap = new IntMap<Flags>(2);
291 content.iterate(manifestRevIdx, manifestRevIdx, true, new FileLookupInspector(encodingHelper, file, null, resMap)); 289 content.iterate(manifestRevIdx, manifestRevIdx, true, new FileLookupInspector(encodingHelper, file, null, resMap));