Mercurial > hg > mercurial-source
changeset 16821:0946502fd3d5
revset: add pattern matching to 'branch' revset expression
author | Simon King <simon@simonking.org.uk> |
---|---|
date | Wed, 30 May 2012 23:13:33 +0100 (2012-05-30) |
parents | 20f55613fb2a |
children | da55d8a77390 |
files | mercurial/revset.py tests/test-revset.t |
diffstat | 2 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -325,14 +325,25 @@ """``branch(string or set)`` All changesets belonging to the given branch or the branches of the given changesets. + + If `string` starts with `re:`, the remainder of the name is treated as + a regular expression. To match a branch that actually starts with `re:`, + use the prefix `literal:`. """ try: b = getstring(x, '') - if b in repo.branchmap(): - return [r for r in subset if repo[r].branch() == b] except error.ParseError: # not a string, but another revspec, e.g. tip() pass + else: + kind, pattern, matcher = _stringmatcher(b) + if kind == 'literal': + # note: falls through to the revspec case if no branch with + # this name exists + if pattern in repo.branchmap(): + return [r for r in subset if matcher(repo[r].branch())] + else: + return [r for r in subset if matcher(repo[r].branch())] s = getset(repo, range(len(repo)), x) b = set()