Mercurial > hg-stable
changeset 12618:0ae35296fbf4
revsets: introduce revsingle helper
revsingle returns a context for the last revision of the supplied revspec
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 07 Oct 2010 18:24:29 -0500 |
parents | 2063d36b406e |
children | 7178f6fedb9d |
files | mercurial/cmdutil.py mercurial/commands.py |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Thu Oct 07 18:05:04 2010 -0500 +++ b/mercurial/cmdutil.py Thu Oct 07 18:24:29 2010 -0500 @@ -111,6 +111,15 @@ limit = None return limit +def revsingle(repo, revspec, default=None): + if not revspec: + return repo[default] + + l = revrange(repo, [revspec]) + if len(l) < 1: + raise util.Abort("empty revision set") + return repo[l[-1]] + def revpair(repo, revs): if not revs: return repo.dirstate.parents()[0], None
--- a/mercurial/commands.py Thu Oct 07 18:05:04 2010 -0500 +++ b/mercurial/commands.py Thu Oct 07 18:24:29 2010 -0500 @@ -634,7 +634,7 @@ Returns 0 on success. """ - ctx = repo[opts.get('rev')] + ctx = cmdutil.revsingle(repo, opts.get('rev')) err = 1 m = cmdutil.match(repo, (file1,) + pats, opts) for abs in ctx.walk(m):