Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
11428:8b452fe4bf50 | 11493:cc4e2a7ca23f |
---|---|
109 raise error.ParseError(_("missing argument")) | 109 raise error.ParseError(_("missing argument")) |
110 return methods[x[0]](repo, subset, *x[1:]) | 110 return methods[x[0]](repo, subset, *x[1:]) |
111 | 111 |
112 # operator methods | 112 # operator methods |
113 | 113 |
114 def negate(repo, subset, x): | |
115 return getset(repo, subset, | |
116 ('string', '-' + getstring(x, _("can't negate that")))) | |
117 | |
118 def stringset(repo, subset, x): | 114 def stringset(repo, subset, x): |
119 x = repo[x].rev() | 115 x = repo[x].rev() |
120 if x == -1 and len(subset) == len(repo): | 116 if x == -1 and len(subset) == len(repo): |
121 return [-1] | 117 return [-1] |
122 if x in subset: | 118 if x in subset: |
127 if x in symbols: | 123 if x in symbols: |
128 raise error.ParseError(_("can't use %s here") % x) | 124 raise error.ParseError(_("can't use %s here") % x) |
129 return stringset(repo, subset, x) | 125 return stringset(repo, subset, x) |
130 | 126 |
131 def rangeset(repo, subset, x, y): | 127 def rangeset(repo, subset, x, y): |
132 m = getset(repo, subset, x)[0] | 128 m = getset(repo, subset, x) |
133 n = getset(repo, subset, y)[-1] | 129 if not m: |
130 m = getset(repo, range(len(repo)), x) | |
131 | |
132 n = getset(repo, subset, y) | |
133 if not n: | |
134 n = getset(repo, range(len(repo)), y) | |
135 | |
136 if not m or not n: | |
137 return [] | |
138 m, n = m[0], n[-1] | |
139 | |
134 if m < n: | 140 if m < n: |
135 return range(m, n + 1) | 141 r = range(m, n + 1) |
136 return range(m, n - 1, -1) | 142 else: |
143 r = range(m, n - 1, -1) | |
144 s = set(subset) | |
145 return [x for x in r if x in s] | |
137 | 146 |
138 def andset(repo, subset, x, y): | 147 def andset(repo, subset, x, y): |
139 return getset(repo, getset(repo, subset, x), y) | 148 return getset(repo, getset(repo, subset, x), y) |
140 | 149 |
141 def orset(repo, subset, x, y): | 150 def orset(repo, subset, x, y): |
220 raise error.ParseError(_("ancestor arguments must be single revisions")) | 229 raise error.ParseError(_("ancestor arguments must be single revisions")) |
221 return [repo[a[0]].ancestor(repo[b[0]]).rev()] | 230 return [repo[a[0]].ancestor(repo[b[0]]).rev()] |
222 | 231 |
223 def ancestors(repo, subset, x): | 232 def ancestors(repo, subset, x): |
224 args = getset(repo, range(len(repo)), x) | 233 args = getset(repo, range(len(repo)), x) |
234 if not args: | |
235 return [] | |
225 s = set(repo.changelog.ancestors(*args)) | set(args) | 236 s = set(repo.changelog.ancestors(*args)) | set(args) |
226 return [r for r in subset if r in s] | 237 return [r for r in subset if r in s] |
227 | 238 |
228 def descendants(repo, subset, x): | 239 def descendants(repo, subset, x): |
229 args = getset(repo, range(len(repo)), x) | 240 args = getset(repo, range(len(repo)), x) |
241 if not args: | |
242 return [] | |
230 s = set(repo.changelog.descendants(*args)) | set(args) | 243 s = set(repo.changelog.descendants(*args)) | set(args) |
231 return [r for r in subset if r in s] | 244 return [r for r in subset if r in s] |
232 | 245 |
233 def follow(repo, subset, x): | 246 def follow(repo, subset, x): |
234 getargs(x, 0, 0, _("follow takes no arguments")) | 247 getargs(x, 0, 0, _("follow takes no arguments")) |
420 repo.ui.pushbuffer() | 433 repo.ui.pushbuffer() |
421 o = discovery.findoutgoing(repo, other) | 434 o = discovery.findoutgoing(repo, other) |
422 repo.ui.popbuffer() | 435 repo.ui.popbuffer() |
423 cl = repo.changelog | 436 cl = repo.changelog |
424 o = set([cl.rev(r) for r in repo.changelog.nodesbetween(o, None)[0]]) | 437 o = set([cl.rev(r) for r in repo.changelog.nodesbetween(o, None)[0]]) |
425 print 'out', dest, o | |
426 return [r for r in subset if r in o] | 438 return [r for r in subset if r in o] |
427 | 439 |
428 def tagged(repo, subset, x): | 440 def tagged(repo, subset, x): |
429 getargs(x, 0, 0, _("tagged takes no arguments")) | 441 getargs(x, 0, 0, _("tagged takes no arguments")) |
430 cl = repo.changelog | 442 cl = repo.changelog |
464 "tagged": tagged, | 476 "tagged": tagged, |
465 "user": author, | 477 "user": author, |
466 } | 478 } |
467 | 479 |
468 methods = { | 480 methods = { |
469 "negate": negate, | |
470 "range": rangeset, | 481 "range": rangeset, |
471 "string": stringset, | 482 "string": stringset, |
472 "symbol": symbolset, | 483 "symbol": symbolset, |
473 "and": andset, | 484 "and": andset, |
474 "or": orset, | 485 "or": orset, |
497 return optimize(('func', ('symbol', 'descendants'), x[1]), small) | 508 return optimize(('func', ('symbol', 'descendants'), x[1]), small) |
498 elif op == 'rangepre': | 509 elif op == 'rangepre': |
499 return optimize(('range', ('string', '0'), x[1]), small) | 510 return optimize(('range', ('string', '0'), x[1]), small) |
500 elif op == 'rangepost': | 511 elif op == 'rangepost': |
501 return optimize(('range', x[1], ('string', 'tip')), small) | 512 return optimize(('range', x[1], ('string', 'tip')), small) |
513 elif op == 'negate': | |
514 return optimize(('string', | |
515 '-' + getstring(x[1], _("can't negate that"))), small) | |
502 elif op in 'string symbol negate': | 516 elif op in 'string symbol negate': |
503 return smallbonus, x # single revisions are small | 517 return smallbonus, x # single revisions are small |
504 elif op == 'and' or op == 'dagrange': | 518 elif op == 'and' or op == 'dagrange': |
505 wa, ta = optimize(x[1], True) | 519 wa, ta = optimize(x[1], True) |
506 wb, tb = optimize(x[2], True) | 520 wb, tb = optimize(x[2], True) |