Mercurial > jhg
changeset 457:d78cb5ca3053
Get rid of ambiguity in method name
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 18 Jun 2012 17:06:42 +0200 |
parents | 909306e412e2 |
children | c95cd5994ba2 |
files | cmdline/org/tmatesoft/hg/console/Manifest.java src/org/tmatesoft/hg/core/HgLogCommand.java src/org/tmatesoft/hg/core/HgManifestCommand.java src/org/tmatesoft/hg/core/HgStatusCommand.java test/org/tmatesoft/hg/test/TestManifest.java |
diffstat | 5 files changed, 40 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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); } }
--- 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); } }
--- 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 <code>this</code> 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 <code>this</code> 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
--- 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 <code>this</code> for convenience */ - public HgStatusCommand change(int revision) { + public HgStatusCommand change(int changesetRevisionIndex) { base(BAD_REVISION); - return revision(revision); + return revision(changesetRevisionIndex); } /**
--- 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)); }