Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revset.py @ 32703: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 |
line wrap: on
line diff
--- a/mercurial/revset.py Sun Jun 04 16:08:50 2017 -0700 +++ b/mercurial/revset.py Sat Aug 20 18:15:19 2016 +0900 @@ -474,6 +474,11 @@ :hg:`help revisions.patterns`. """ getbi = repo.revbranchcache().branchinfo + def getbranch(r): + try: + return getbi(r)[0] + except error.WdirUnsupported: + return repo[r].branch() try: b = getstring(x, '') @@ -486,21 +491,21 @@ # note: falls through to the revspec case if no branch with # this name exists and pattern kind is not specified explicitly if pattern in repo.branchmap(): - return subset.filter(lambda r: matcher(getbi(r)[0]), + return subset.filter(lambda r: matcher(getbranch(r)), condrepr=('<branch %r>', b)) if b.startswith('literal:'): raise error.RepoLookupError(_("branch '%s' does not exist") % pattern) else: - return subset.filter(lambda r: matcher(getbi(r)[0]), + return subset.filter(lambda r: matcher(getbranch(r)), condrepr=('<branch %r>', b)) s = getset(repo, fullreposet(repo), x) b = set() for r in s: - b.add(getbi(r)[0]) + b.add(getbranch(r)) c = s.__contains__ - return subset.filter(lambda r: c(r) or getbi(r)[0] in b, + return subset.filter(lambda r: c(r) or getbranch(r) in b, condrepr=lambda: '<branch %r>' % sorted(b)) @predicate('bumped()', safe=True)