# HG changeset patch # User Artem Tikhomirov # Date 1340032002 -7200 # Node ID d78cb5ca3053dd757cc8fd998f5b7a8e1f96c43c # Parent 909306e412e215cfa041c0f76f1e825dfb9d43f3 Get rid of ambiguity in method name diff -r 909306e412e2 -r d78cb5ca3053 cmdline/org/tmatesoft/hg/console/Manifest.java --- a/cmdline/org/tmatesoft/hg/console/Manifest.java Mon Jun 18 16:54:00 2012 +0200 +++ b/cmdline/org/tmatesoft/hg/console/Manifest.java Mon Jun 18 17:06:42 2012 +0200 @@ -83,6 +83,6 @@ } }; int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev"); - new HgManifestCommand(hgRepo).dirs(false).revision(rev).execute(h); + new HgManifestCommand(hgRepo).dirs(false).changeset(rev).execute(h); } } diff -r 909306e412e2 -r d78cb5ca3053 src/org/tmatesoft/hg/core/HgLogCommand.java --- a/src/org/tmatesoft/hg/core/HgLogCommand.java Mon Jun 18 16:54:00 2012 +0200 +++ b/src/org/tmatesoft/hg/core/HgLogCommand.java Mon Jun 18 17:06:42 2012 +0200 @@ -37,6 +37,7 @@ import org.tmatesoft.hg.repo.HgDataFile; import org.tmatesoft.hg.repo.HgInternals; import org.tmatesoft.hg.repo.HgInvalidControlFileException; +import org.tmatesoft.hg.repo.HgInvalidRevisionException; import org.tmatesoft.hg.repo.HgInvalidStateException; import org.tmatesoft.hg.repo.HgParentChildMap; import org.tmatesoft.hg.repo.HgRepository; @@ -168,7 +169,7 @@ try { final int csetRevIndex = repo.getChangelog().getRevisionIndex(nid); return range(csetRevIndex, csetRevIndex); - } catch (HgRuntimeException ex) { + } catch (HgInvalidRevisionException ex) { throw new HgBadArgumentException("Can't find revision", ex).setRevision(nid); } } diff -r 909306e412e2 -r d78cb5ca3053 src/org/tmatesoft/hg/core/HgManifestCommand.java --- a/src/org/tmatesoft/hg/core/HgManifestCommand.java Mon Jun 18 16:54:00 2012 +0200 +++ b/src/org/tmatesoft/hg/core/HgManifestCommand.java Mon Jun 18 17:06:42 2012 +0200 @@ -26,6 +26,7 @@ import java.util.List; import org.tmatesoft.hg.internal.PathPool; +import org.tmatesoft.hg.repo.HgInvalidRevisionException; import org.tmatesoft.hg.repo.HgManifest; import org.tmatesoft.hg.repo.HgRepository; import org.tmatesoft.hg.repo.HgManifest.Flags; @@ -76,12 +77,39 @@ return this; } - public HgManifestCommand revision(int rev) { - startRev = endRev = rev; - return this; + /** + * Select changeset for the command using revision index + * @param csetRevisionIndex index of changeset revision + * @return this for convenience. + */ + public HgManifestCommand changeset(int csetRevisionIndex) { + return range(csetRevisionIndex, csetRevisionIndex); } - // FIXME add changeset(Nodeid), perhaps rename revision(int) to changeset(int), and add changeset(int) to HgLogCommand (and, perhaps, others) + /** + * Select changeset for the command + * + * @param nid changeset revision + * @return this for convenience + * @throws HgBadArgumentException if failed to find supplied changeset revision + */ + public HgManifestCommand changeset(Nodeid nid) throws HgBadArgumentException { + // XXX also see HgLogCommand#changeset(Nodeid) + try { + final int csetRevIndex = repo.getChangelog().getRevisionIndex(nid); + return range(csetRevIndex, csetRevIndex); + } catch (HgInvalidRevisionException ex) { + throw new HgBadArgumentException("Can't find revision", ex).setRevision(nid); + } + } + + /** + * @deprecated confusing whether it's changeset or manifest own revision index in use, use {@link #changeset(int)} instead + */ + @Deprecated + public HgManifestCommand revision(int rev) { + return changeset(rev); + } public HgManifestCommand dirs(boolean include) { // XXX whether directories with directories only are include or not diff -r 909306e412e2 -r d78cb5ca3053 src/org/tmatesoft/hg/core/HgStatusCommand.java --- a/src/org/tmatesoft/hg/core/HgStatusCommand.java Mon Jun 18 16:54:00 2012 +0200 +++ b/src/org/tmatesoft/hg/core/HgStatusCommand.java Mon Jun 18 17:06:42 2012 +0200 @@ -136,12 +136,12 @@ /** * Shorthand for {@link #base(int) cmd.base(BAD_REVISION)}{@link #change(int) .revision(revision)} * - * @param revision compare given revision against its parent + * @param changesetRevisionIndex compare given revision against its parent * @return this for convenience */ - public HgStatusCommand change(int revision) { + public HgStatusCommand change(int changesetRevisionIndex) { base(BAD_REVISION); - return revision(revision); + return revision(changesetRevisionIndex); } /** diff -r 909306e412e2 -r d78cb5ca3053 test/org/tmatesoft/hg/test/TestManifest.java --- a/test/org/tmatesoft/hg/test/TestManifest.java Mon Jun 18 16:54:00 2012 +0200 +++ b/test/org/tmatesoft/hg/test/TestManifest.java Mon Jun 18 17:06:42 2012 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 TMate Software Ltd + * Copyright (c) 2011-2012 TMate Software Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -103,7 +103,7 @@ manifestParser.reset(); eh.run("hg", "manifest", "--debug", "--rev", String.valueOf(rev == TIP ? -1 : rev)); revisions.clear(); - new HgManifestCommand(repo).revision(rev).execute(handler); + new HgManifestCommand(repo).changeset(rev).execute(handler); report("manifest " + (rev == TIP ? "TIP:" : "--rev " + rev)); }