simplemerge: return number of conflicts, not just 1

Summary: Any nonzero return value is considered a failure here. Let's return the number of failed hunks so it can be used in the next diff.

Reviewed By: quark-zju

Differential Revision: D9806278

fbshipit-source-id: cdbcb2bfef2ec77555ffced3f38254ffea80c1be
This commit is contained in:
Phil Cohen 2018-09-21 16:23:31 -07:00 committed by Facebook Github Bot
parent 25d9c831b1
commit 67bcc4880c

View File

@ -102,6 +102,7 @@ class Merge3Text(object):
"""Return merge in cvs-like form.
"""
self.conflicts = False
self.conflictscount = 0
newline = "\n"
if len(self.a) > 0:
if self.a[0].endswith("\r\n"):
@ -137,6 +138,7 @@ class Merge3Text(object):
yield self.b[i]
else:
self.conflicts = True
self.conflictscount += 1
if start_marker is not None:
yield start_marker + newline
for i in range(t[3], t[4]):
@ -432,6 +434,8 @@ def simplemerge(ui, localctx, basectx, otherctx, **opts):
"""Performs the simplemerge algorithm.
The merged result is written into `localctx`.
Returns the number of conflicts.
"""
opts = pycompat.byteskwargs(opts)
@ -486,4 +490,4 @@ def simplemerge(ui, localctx, basectx, otherctx, **opts):
localctx.write(mergedtext, flags)
if m3.conflicts and not mode == "union":
return 1
return m3.conflictscount