--- a/hgext3rd/evolve/obshistory.py Tue Mar 17 19:37:08 2020 +0700
+++ b/hgext3rd/evolve/obshistory.py Mon Jan 13 16:32:25 2020 +0700
@@ -213,28 +213,40 @@
'''
pass
-def patchavailable(node, repo, successors):
+def patchavailable(node, repo, candidates, successive=True):
if node not in repo:
return False, b"context is not local"
- if len(successors) == 0:
- return False, b"no successors"
- elif len(successors) > 1:
- return False, b"too many successors (%d)" % len(successors)
-
- succ = successors[0]
+ if len(candidates) == 0:
+ if successive:
+ msg = b"no successors"
+ else:
+ msg = b"no predecessors"
+ return False, msg
+ elif len(candidates) > 1:
+ if successive:
+ msg = b"too many successors (%d)"
+ else:
+ msg = b"too many predecessors (%d)"
+ return False, msg % len(candidates)
- if succ not in repo:
- return False, b"successor is unknown locally"
+ cand = candidates[0]
- # Check that both node and succ have the same parents
+ if cand not in repo:
+ if successive:
+ msg = b"successor is unknown locally"
+ else:
+ msg = b"predecessor is unknown locally"
+ return False, msg
+
+ # Check that both node and cand have the same parents
nodep1, nodep2 = repo[node].p1(), repo[node].p2()
- succp1, succp2 = repo[succ].p1(), repo[succ].p2()
+ candp1, candp2 = repo[cand].p1(), repo[cand].p2()
- if nodep1 != succp1 or nodep2 != succp2:
+ if nodep1 != candp1 or nodep2 != candp2:
return False, b"changesets rebased"
- return True, succ
+ return True, cand
def getmarkerdescriptionpatch(repo, basedesc, succdesc):
# description are stored without final new line,