Mercurial > public > mercurial-scm > hg
diff mercurial/pure/bdiff.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 | 2372284d9457 |
children | 68aedad4c11c |
line wrap: on
line diff
--- a/mercurial/pure/bdiff.py Sun Oct 06 09:45:02 2019 -0400 +++ b/mercurial/pure/bdiff.py Sun Oct 06 09:48:39 2019 -0400 @@ -14,9 +14,9 @@ def splitnewlines(text): '''like str.splitlines, but only split on newlines.''' - lines = [l + '\n' for l in text.split('\n')] + lines = [l + b'\n' for l in text.split(b'\n')] if lines: - if lines[-1] == '\n': + if lines[-1] == b'\n': lines.pop() else: lines[-1] = lines[-1][:-1] @@ -60,8 +60,8 @@ b = bytes(b).splitlines(True) if not a: - s = "".join(b) - return s and (struct.pack(">lll", 0, 0, len(s)) + s) + s = b"".join(b) + return s and (struct.pack(b">lll", 0, 0, len(s)) + s) bin = [] p = [0] @@ -73,13 +73,13 @@ la = 0 lb = 0 for am, bm, size in d: - s = "".join(b[lb:bm]) + s = b"".join(b[lb:bm]) if am > la or s: - bin.append(struct.pack(">lll", p[la], p[am], len(s)) + s) + bin.append(struct.pack(b">lll", p[la], p[am], len(s)) + s) la = am + size lb = bm + size - return "".join(bin) + return b"".join(bin) def blocks(a, b): @@ -92,8 +92,8 @@ def fixws(text, allws): if allws: - text = re.sub('[ \t\r]+', '', text) + text = re.sub(b'[ \t\r]+', b'', text) else: - text = re.sub('[ \t\r]+', ' ', text) - text = text.replace(' \n', '\n') + text = re.sub(b'[ \t\r]+', b' ', text) + text = text.replace(b' \n', b'\n') return text