py3: update simplemerge conflict logic to use bytes

Summary: Patches are bytes, so the lines we add to them need to be bytes

Reviewed By: mitrandir77

Differential Revision: D19668850

fbshipit-source-id: cb521f71d927dbe1cbe3287be37123b609889846
This commit is contained in:
Durham Goode 2020-01-31 13:09:53 -08:00 committed by Facebook Github Bot
parent 4f35ef07bf
commit e985d51e02
2 changed files with 15 additions and 16 deletions

View File

@ -92,9 +92,9 @@ class Merge3Text(object):
name_a=None, name_a=None,
name_b=None, name_b=None,
name_base=None, name_base=None,
start_marker="<<<<<<<", start_marker=b"<<<<<<<",
mid_marker="=======", mid_marker=b"=======",
end_marker=">>>>>>>", end_marker=b">>>>>>>",
base_marker=None, base_marker=None,
localorother=None, localorother=None,
minimize=False, minimize=False,
@ -103,18 +103,18 @@ class Merge3Text(object):
""" """
self.conflicts = False self.conflicts = False
self.conflictscount = 0 self.conflictscount = 0
newline = "\n" newline = b"\n"
if len(self.a) > 0: if len(self.a) > 0:
if self.a[0].endswith("\r\n"): if self.a[0].endswith(b"\r\n"):
newline = "\r\n" newline = b"\r\n"
elif self.a[0].endswith("\r"): elif self.a[0].endswith(b"\r"):
newline = "\r" newline = b"\r"
if name_a and start_marker: if name_a and start_marker:
start_marker = start_marker + " " + name_a start_marker = start_marker + b" " + name_a
if name_b and end_marker: if name_b and end_marker:
end_marker = end_marker + " " + name_b end_marker = end_marker + b" " + name_b
if name_base and base_marker: if name_base and base_marker:
base_marker = base_marker + " " + name_base base_marker = base_marker + b" " + name_base
merge_regions = self.merge_regions() merge_regions = self.merge_regions()
if minimize: if minimize:
merge_regions = self.minimize(merge_regions) merge_regions = self.minimize(merge_regions)
@ -424,9 +424,9 @@ def _verifytext(text, path, ui, opts):
def _picklabels(defaults, overrides): def _picklabels(defaults, overrides):
if len(overrides) > 3: if len(overrides) > 3:
raise error.Abort(_("can only specify three labels.")) raise error.Abort(_("can only specify three labels."))
result = defaults[:] result = list((pycompat.encodeutf8(d) if d is not None else None) for d in defaults)
for i, override in enumerate(overrides): for i, override in enumerate(overrides):
result[i] = override result[i] = pycompat.encodeutf8(override)
return result return result
@ -470,11 +470,11 @@ def simplemerge(ui, localctx, basectx, otherctx, **opts):
extrakwargs["mid_marker"] = None extrakwargs["mid_marker"] = None
extrakwargs["end_marker"] = None extrakwargs["end_marker"] = None
elif name_base is not None: elif name_base is not None:
extrakwargs["base_marker"] = "|||||||" extrakwargs["base_marker"] = b"|||||||"
extrakwargs["name_base"] = name_base extrakwargs["name_base"] = name_base
extrakwargs["minimize"] = False extrakwargs["minimize"] = False
mergedtext = "" mergedtext = b""
for line in m3.merge_lines( for line in m3.merge_lines(
name_a=name_a, name_b=name_b, **pycompat.strkwargs(extrakwargs) name_a=name_a, name_b=name_b, **pycompat.strkwargs(extrakwargs)
): ):

View File

@ -1,4 +1,3 @@
#require py2
#chg-compatible #chg-compatible
$ disable treemanifest $ disable treemanifest