Mercurial > hg
changeset 12716:c7e619e30ba3
revset: add id() and rev() to allow explicitly referring to changes by hash or rev
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 11 Oct 2010 09:44:19 -0500 |
parents | 33820dccbea4 |
children | 372abc799caa |
files | mercurial/help/revsets.txt mercurial/revset.py tests/test-revset.t |
diffstat | 3 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/help/revsets.txt Sun Oct 10 12:41:36 2010 -0500 +++ b/mercurial/help/revsets.txt Mon Oct 11 09:44:19 2010 -0500 @@ -94,6 +94,9 @@ ``heads(set)`` Members of set with no children in set. +``id(string)`` + Revision non-ambiguously specified by the given hex string prefix + ``keyword(string)`` Search commit message, user name, and names of changed files for string. @@ -133,6 +136,9 @@ ``removes(pattern)`` Changesets which remove files matching pattern. +``rev(number)`` + Revision with the given numeric identifier. + ``reverse(set)`` Reverse order of set.
--- a/mercurial/revset.py Sun Oct 10 12:41:36 2010 -0500 +++ b/mercurial/revset.py Mon Oct 11 09:44:19 2010 -0500 @@ -173,6 +173,23 @@ # functions +def node(repo, subset, x): + l = getargs(x, 1, 1, _("rev wants one argument")) + n = getstring(l[0], _("rev wants a string")) + if len(n) == 40: + rn = repo[n].rev() + else: + rn = repo.changelog.rev(repo.changelog._partialmatch(n)) + return [r for r in subset if r == rn] + +def rev(repo, subset, x): + l = getargs(x, 1, 1, _("rev wants one argument")) + try: + l = int(getstring(l[0], _("rev wants a number"))) + except ValueError: + raise error.ParseError(_("rev expects a number")) + return [r for r in subset if r == l] + def p1(repo, subset, x): ps = set() cl = repo.changelog @@ -501,6 +518,7 @@ "min": minrev, "merge": merge, "modifies": modifies, + "id": node, "outgoing": outgoing, "p1": p1, "p2": p2, @@ -508,6 +526,7 @@ "present": present, "removes": removes, "reverse": reverse, + "rev": rev, "roots": roots, "sort": sort, "tag": tag,