# HG changeset patch # User Yuya Nishihara # Date 2019-06-09 13:23:41 # Node ID 43c8f72184f4a95bab12a2b9d78a1acbc5834709 # Parent d279e4f453c4b3d05b70df0c1d2c2cf0046a45fc revset: fix merge() to fall back to changectx API if wdir specified I have a code which basically runs "0:wdir() & ", and it crashed if merge() were passed in. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1362,8 +1362,12 @@ def merge(repo, subset, x): 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='') + def ismerge(r): + try: + return cl.parentrevs(r)[1] != nullrev + except error.WdirUnsupported: + return bool(repo[r].p2()) + return subset.filter(ismerge, condrepr='') @predicate('branchpoint()', safe=True) def branchpoint(repo, subset, x): diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -2076,6 +2076,17 @@ itself isn't returned unless it is expli $ 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