Mercurial > hg
changeset 42441:43c8f72184f4
revset: fix merge() to fall back to changectx API if wdir specified
I have a code which basically runs "0:wdir() & <user-revset>", and it crashed
if merge() were passed in.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 09 Jun 2019 22:23:41 +0900 |
parents | d279e4f453c4 |
children | c1bf63ac30c5 |
files | mercurial/revset.py tests/test-revset.t |
diffstat | 2 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Sun Jun 09 22:18:22 2019 +0900 +++ b/mercurial/revset.py Sun Jun 09 22:23:41 2019 +0900 @@ -1362,8 +1362,12 @@ getargs(x, 0, 0, _("merge takes no arguments")) cl = repo.changelog nullrev = node.nullrev - return subset.filter(lambda r: cl.parentrevs(r)[1] != nullrev, - condrepr='<merge>') + def ismerge(r): + try: + return cl.parentrevs(r)[1] != nullrev + except error.WdirUnsupported: + return bool(repo[r].p2()) + return subset.filter(ismerge, condrepr='<merge>') @predicate('branchpoint()', safe=True) def branchpoint(repo, subset, x):
--- a/tests/test-revset.t Sun Jun 09 22:18:22 2019 +0900 +++ b/tests/test-revset.t Sun Jun 09 22:23:41 2019 +0900 @@ -2076,6 +2076,17 @@ $ log 'parents(merge())' 4 5 + + $ hg merge 7 + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + $ log '0:wdir() & merge()' + 6 + 2147483647 + $ hg update -qC . + $ log '0:wdir() & merge()' + 6 + $ log 'p1(branchpoint())' 0 2