Mercurial > hg
diff mercurial/revset.py @ 11493:cc4e2a7ca23f
Merge with stable
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Fri, 02 Jul 2010 11:30:57 +0200 |
parents | 6b836d5c8c9e |
children | ebaf117c2642 |
line wrap: on
line diff
--- a/mercurial/revset.py Mon Jun 21 17:02:48 2010 -0300 +++ b/mercurial/revset.py Fri Jul 02 11:30:57 2010 +0200 @@ -111,10 +111,6 @@ # operator methods -def negate(repo, subset, x): - return getset(repo, subset, - ('string', '-' + getstring(x, _("can't negate that")))) - def stringset(repo, subset, x): x = repo[x].rev() if x == -1 and len(subset) == len(repo): @@ -129,11 +125,24 @@ return stringset(repo, subset, x) def rangeset(repo, subset, x, y): - m = getset(repo, subset, x)[0] - n = getset(repo, subset, y)[-1] + m = getset(repo, subset, x) + if not m: + m = getset(repo, range(len(repo)), x) + + n = getset(repo, subset, y) + if not n: + n = getset(repo, range(len(repo)), y) + + if not m or not n: + return [] + m, n = m[0], n[-1] + if m < n: - return range(m, n + 1) - return range(m, n - 1, -1) + r = range(m, n + 1) + else: + r = range(m, n - 1, -1) + s = set(subset) + return [x for x in r if x in s] def andset(repo, subset, x, y): return getset(repo, getset(repo, subset, x), y) @@ -222,11 +231,15 @@ def ancestors(repo, subset, x): args = getset(repo, range(len(repo)), x) + if not args: + return [] s = set(repo.changelog.ancestors(*args)) | set(args) return [r for r in subset if r in s] def descendants(repo, subset, x): args = getset(repo, range(len(repo)), x) + if not args: + return [] s = set(repo.changelog.descendants(*args)) | set(args) return [r for r in subset if r in s] @@ -422,7 +435,6 @@ repo.ui.popbuffer() cl = repo.changelog o = set([cl.rev(r) for r in repo.changelog.nodesbetween(o, None)[0]]) - print 'out', dest, o return [r for r in subset if r in o] def tagged(repo, subset, x): @@ -466,7 +478,6 @@ } methods = { - "negate": negate, "range": rangeset, "string": stringset, "symbol": symbolset, @@ -499,6 +510,9 @@ return optimize(('range', ('string', '0'), x[1]), small) elif op == 'rangepost': return optimize(('range', x[1], ('string', 'tip')), small) + elif op == 'negate': + return optimize(('string', + '-' + getstring(x[1], _("can't negate that"))), small) elif op in 'string symbol negate': return smallbonus, x # single revisions are small elif op == 'and' or op == 'dagrange':