Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 32683:9f840d99054c
revset: add support for branch(wdir()) and wdir() & branch()
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 20 Aug 2016 18:15:19 +0900 |
parents | a3064fe3e495 |
children | af854b1b36f8 |
comparison
equal
deleted
inserted
replaced
32682:e696f597d02f | 32683:9f840d99054c |
---|---|
472 | 472 |
473 Pattern matching is supported for `string`. See | 473 Pattern matching is supported for `string`. See |
474 :hg:`help revisions.patterns`. | 474 :hg:`help revisions.patterns`. |
475 """ | 475 """ |
476 getbi = repo.revbranchcache().branchinfo | 476 getbi = repo.revbranchcache().branchinfo |
477 def getbranch(r): | |
478 try: | |
479 return getbi(r)[0] | |
480 except error.WdirUnsupported: | |
481 return repo[r].branch() | |
477 | 482 |
478 try: | 483 try: |
479 b = getstring(x, '') | 484 b = getstring(x, '') |
480 except error.ParseError: | 485 except error.ParseError: |
481 # not a string, but another revspec, e.g. tip() | 486 # not a string, but another revspec, e.g. tip() |
484 kind, pattern, matcher = util.stringmatcher(b) | 489 kind, pattern, matcher = util.stringmatcher(b) |
485 if kind == 'literal': | 490 if kind == 'literal': |
486 # note: falls through to the revspec case if no branch with | 491 # note: falls through to the revspec case if no branch with |
487 # this name exists and pattern kind is not specified explicitly | 492 # this name exists and pattern kind is not specified explicitly |
488 if pattern in repo.branchmap(): | 493 if pattern in repo.branchmap(): |
489 return subset.filter(lambda r: matcher(getbi(r)[0]), | 494 return subset.filter(lambda r: matcher(getbranch(r)), |
490 condrepr=('<branch %r>', b)) | 495 condrepr=('<branch %r>', b)) |
491 if b.startswith('literal:'): | 496 if b.startswith('literal:'): |
492 raise error.RepoLookupError(_("branch '%s' does not exist") | 497 raise error.RepoLookupError(_("branch '%s' does not exist") |
493 % pattern) | 498 % pattern) |
494 else: | 499 else: |
495 return subset.filter(lambda r: matcher(getbi(r)[0]), | 500 return subset.filter(lambda r: matcher(getbranch(r)), |
496 condrepr=('<branch %r>', b)) | 501 condrepr=('<branch %r>', b)) |
497 | 502 |
498 s = getset(repo, fullreposet(repo), x) | 503 s = getset(repo, fullreposet(repo), x) |
499 b = set() | 504 b = set() |
500 for r in s: | 505 for r in s: |
501 b.add(getbi(r)[0]) | 506 b.add(getbranch(r)) |
502 c = s.__contains__ | 507 c = s.__contains__ |
503 return subset.filter(lambda r: c(r) or getbi(r)[0] in b, | 508 return subset.filter(lambda r: c(r) or getbranch(r) in b, |
504 condrepr=lambda: '<branch %r>' % sorted(b)) | 509 condrepr=lambda: '<branch %r>' % sorted(b)) |
505 | 510 |
506 @predicate('bumped()', safe=True) | 511 @predicate('bumped()', safe=True) |
507 def bumped(repo, subset, x): | 512 def bumped(repo, subset, x): |
508 """Mutable changesets marked as successors of public changesets. | 513 """Mutable changesets marked as successors of public changesets. |