Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revset.py @ 11944:df52ff0980fe
revset: predicate to avoid lookup errors
A query like
head() and (descendants("bad") and not descendants("fix"))
(testing if repo heads are affected by a bug) will abort with a
RepoLookupError if either badrev or fixrev aren't found inside
the repository, which is not very informative.
The new predicate returns an empty set for lookup errors, so
head() and (descendants(present("bad")) and not descendants(present("fix")))
will behave as wanted even if those revisions are not found.
author | Wagner Bruna <wbruna@softwareexpress.com.br> |
---|---|
date | Fri, 13 Aug 2010 13:11:41 -0300 |
parents | 73112cb2a6d7 |
children | 6f833fc3ccab |
line wrap: on
line diff
--- a/mercurial/revset.py Fri Aug 13 13:16:34 2010 -0400 +++ b/mercurial/revset.py Fri Aug 13 13:11:41 2010 -0300 @@ -378,6 +378,12 @@ l.reverse() return l +def present(repo, subset, x): + try: + return getset(repo, subset, x) + except error.RepoLookupError: + return [] + def sort(repo, subset, x): l = getargs(x, 1, 2, _("sort wants one or two arguments")) keys = "rev" @@ -481,6 +487,7 @@ "p1": p1, "p2": p2, "parents": parents, + "present": present, "removes": removes, "reverse": reverse, "roots": roots,