Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
11943:2d3cbcace897 | 11944:df52ff0980fe |
---|---|
376 def reverse(repo, subset, x): | 376 def reverse(repo, subset, x): |
377 l = getset(repo, subset, x) | 377 l = getset(repo, subset, x) |
378 l.reverse() | 378 l.reverse() |
379 return l | 379 return l |
380 | 380 |
381 def present(repo, subset, x): | |
382 try: | |
383 return getset(repo, subset, x) | |
384 except error.RepoLookupError: | |
385 return [] | |
386 | |
381 def sort(repo, subset, x): | 387 def sort(repo, subset, x): |
382 l = getargs(x, 1, 2, _("sort wants one or two arguments")) | 388 l = getargs(x, 1, 2, _("sort wants one or two arguments")) |
383 keys = "rev" | 389 keys = "rev" |
384 if len(l) == 2: | 390 if len(l) == 2: |
385 keys = getstring(l[1], _("sort spec must be a string")) | 391 keys = getstring(l[1], _("sort spec must be a string")) |
479 "modifies": modifies, | 485 "modifies": modifies, |
480 "outgoing": outgoing, | 486 "outgoing": outgoing, |
481 "p1": p1, | 487 "p1": p1, |
482 "p2": p2, | 488 "p2": p2, |
483 "parents": parents, | 489 "parents": parents, |
490 "present": present, | |
484 "removes": removes, | 491 "removes": removes, |
485 "reverse": reverse, | 492 "reverse": reverse, |
486 "roots": roots, | 493 "roots": roots, |
487 "sort": sort, | 494 "sort": sort, |
488 "tagged": tagged, | 495 "tagged": tagged, |