Mercurial > public > mercurial-scm > hg-stable
diff mercurial/diffhelper.py @ 43077:687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Done with
python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py')
black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**')
# skip-blame mass-reformatting only
Differential Revision: https://phab.mercurial-scm.org/D6972
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:48:39 -0400 |
parents | 57875cf423c9 |
children | 10f48720ef95 |
line wrap: on
line diff
--- a/mercurial/diffhelper.py Sun Oct 06 09:45:02 2019 -0400 +++ b/mercurial/diffhelper.py Sun Oct 06 09:48:39 2019 -0400 @@ -31,18 +31,18 @@ for i in pycompat.xrange(num): s = fp.readline() if not s: - raise error.ParseError(_('incomplete hunk')) - if s == "\\ No newline at end of file\n": + raise error.ParseError(_(b'incomplete hunk')) + if s == b"\\ No newline at end of file\n": fixnewline(hunk, a, b) continue - if s == '\n' or s == '\r\n': + if s == b'\n' or s == b'\r\n': # Some patches may be missing the control char # on empty lines. Supply a leading space. - s = ' ' + s + s = b' ' + s hunk.append(s) - if s.startswith('+'): + if s.startswith(b'+'): b.append(s[1:]) - elif s.startswith('-'): + elif s.startswith(b'-'): a.append(s) else: b.append(s[1:]) @@ -53,14 +53,14 @@ """Fix up the last lines of a and b when the patch has no newline at EOF""" l = hunk[-1] # tolerate CRLF in last line - if l.endswith('\r\n'): + if l.endswith(b'\r\n'): hline = l[:-2] else: hline = l[:-1] - if hline.startswith((' ', '+')): + if hline.startswith((b' ', b'+')): b[-1] = hline[1:] - if hline.startswith((' ', '-')): + if hline.startswith((b' ', b'-')): a[-1] = hline hunk[-1] = hline