Skip to content
Snippets Groups Projects
Commit 94621656 authored by Augie Fackler's avatar Augie Fackler
Browse files

mdiff: use slice instead of index on bytestr when checking single bytes

This is portable to Python 3.

Differential Revision: https://phab.mercurial-scm.org/D1992
parent c0a6733f
No related branches found
No related tags found
No related merge requests found
......@@ -275,7 +275,7 @@
headerlines = []
hunks = (None, ['Binary file %s has changed\n' % fn1]),
elif not a:
without_newline = b[-1] != '\n'
without_newline = b[-1:] != '\n'
b = splitnewlines(b)
if a is None:
l1 = '--- /dev/null%s' % datetag(epoch)
......@@ -291,7 +291,7 @@
hunklines.append(_missing_newline_marker)
hunks = (hunkrange, hunklines),
elif not b:
without_newline = a[-1] != '\n'
without_newline = a[-1:] != '\n'
a = splitnewlines(a)
l1 = "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1))
if b is None:
......@@ -384,5 +384,5 @@
# a newline, print only one marker. That's the only case in
# which the hunk can end in a shared line without a newline.
skip = False
if t1[-1] != '\n' and astart + alen == len(l1) + 1:
if t1[-1:] != '\n' and astart + alen == len(l1) + 1:
for i in xrange(len(hunklines) - 1, -1, -1):
......@@ -388,7 +388,7 @@
for i in xrange(len(hunklines) - 1, -1, -1):
if hunklines[i][0] in ('-', ' '):
if hunklines[i][0] == ' ':
if hunklines[i][0:1] in ('-', ' '):
if hunklines[i][0:1] == ' ':
skip = True
hunklines[i] += '\n'
hunklines.insert(i + 1, _missing_newline_marker)
break
......@@ -391,6 +391,6 @@
skip = True
hunklines[i] += '\n'
hunklines.insert(i + 1, _missing_newline_marker)
break
if not skip and t2[-1] != '\n' and bstart + blen == len(l2) + 1:
if not skip and t2[-1:] != '\n' and bstart + blen == len(l2) + 1:
for i in xrange(len(hunklines) - 1, -1, -1):
......@@ -396,5 +396,5 @@
for i in xrange(len(hunklines) - 1, -1, -1):
if hunklines[i][0] == '+':
if hunklines[i][0:1] == '+':
hunklines[i] += '\n'
hunklines.insert(i + 1, _missing_newline_marker)
break
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment