Commit 292de4cc authored by Anton Shestakov's avatar Anton Shestakov
Browse files

obshistory: make patchavailable() handle predecessors too

parent ee5ad9739ed1
Pipeline #5296 passed with stage
in 5 minutes and 21 seconds
......@@ -213,7 +213,7 @@
'''
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"
......@@ -217,10 +217,16 @@
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)
......@@ -226,4 +232,3 @@
if succ not in repo:
return False, b"successor is unknown locally"
cand = candidates[0]
......@@ -229,3 +234,10 @@
# 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()
......@@ -231,3 +243,3 @@
nodep1, nodep2 = repo[node].p1(), repo[node].p2()
succp1, succp2 = repo[succ].p1(), repo[succ].p2()
candp1, candp2 = repo[cand].p1(), repo[cand].p2()
......@@ -233,4 +245,4 @@
if nodep1 != succp1 or nodep2 != succp2:
if nodep1 != candp1 or nodep2 != candp2:
return False, b"changesets rebased"
......@@ -235,6 +247,6 @@
return False, b"changesets rebased"
return True, succ
return True, cand
def getmarkerdescriptionpatch(repo, basedesc, succdesc):
# description are stored without final new line,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment