Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 11467:6b836d5c8c9e stable
revset: make negate work for sort specs
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 30 Jun 2010 17:44:36 -0500 |
parents | 88abbb046e66 |
children | ebaf117c2642 |
comparison
equal
deleted
inserted
replaced
11466:ad27428c59ce | 11467:6b836d5c8c9e |
---|---|
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: |
480 "tagged": tagged, | 476 "tagged": tagged, |
481 "user": author, | 477 "user": author, |
482 } | 478 } |
483 | 479 |
484 methods = { | 480 methods = { |
485 "negate": negate, | |
486 "range": rangeset, | 481 "range": rangeset, |
487 "string": stringset, | 482 "string": stringset, |
488 "symbol": symbolset, | 483 "symbol": symbolset, |
489 "and": andset, | 484 "and": andset, |
490 "or": orset, | 485 "or": orset, |
513 return optimize(('func', ('symbol', 'descendants'), x[1]), small) | 508 return optimize(('func', ('symbol', 'descendants'), x[1]), small) |
514 elif op == 'rangepre': | 509 elif op == 'rangepre': |
515 return optimize(('range', ('string', '0'), x[1]), small) | 510 return optimize(('range', ('string', '0'), x[1]), small) |
516 elif op == 'rangepost': | 511 elif op == 'rangepost': |
517 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) | |
518 elif op in 'string symbol negate': | 516 elif op in 'string symbol negate': |
519 return smallbonus, x # single revisions are small | 517 return smallbonus, x # single revisions are small |
520 elif op == 'and' or op == 'dagrange': | 518 elif op == 'and' or op == 'dagrange': |
521 wa, ta = optimize(x[1], True) | 519 wa, ta = optimize(x[1], True) |
522 wb, tb = optimize(x[2], True) | 520 wb, tb = optimize(x[2], True) |