Mercurial > hg
comparison mercurial/pure/mpatch.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 | 89a2afe31e82 |
comparison
equal
deleted
inserted
replaced
43076:2372284d9457 | 43077:687b865b95ad |
---|---|
95 end = pos + plen | 95 end = pos + plen |
96 last = 0 | 96 last = 0 |
97 while pos < end: | 97 while pos < end: |
98 m.seek(pos) | 98 m.seek(pos) |
99 try: | 99 try: |
100 p1, p2, l = struct.unpack(">lll", m.read(12)) | 100 p1, p2, l = struct.unpack(b">lll", m.read(12)) |
101 except struct.error: | 101 except struct.error: |
102 raise mpatchError("patch cannot be decoded") | 102 raise mpatchError(b"patch cannot be decoded") |
103 _pull(new, frags, p1 - last) # what didn't change | 103 _pull(new, frags, p1 - last) # what didn't change |
104 _pull([], frags, p2 - p1) # what got deleted | 104 _pull([], frags, p2 - p1) # what got deleted |
105 new.append((l, pos + 12)) # what got added | 105 new.append((l, pos + 12)) # what got added |
106 pos += l + 12 | 106 pos += l + 12 |
107 last = p2 | 107 last = p2 |
118 binend = len(delta) | 118 binend = len(delta) |
119 data = 12 | 119 data = 12 |
120 | 120 |
121 while data <= binend: | 121 while data <= binend: |
122 decode = delta[bin : bin + 12] | 122 decode = delta[bin : bin + 12] |
123 start, end, length = struct.unpack(">lll", decode) | 123 start, end, length = struct.unpack(b">lll", decode) |
124 if start > end: | 124 if start > end: |
125 break | 125 break |
126 bin = data + length | 126 bin = data + length |
127 data = bin + 12 | 127 data = bin + 12 |
128 outlen += start - last | 128 outlen += start - last |
129 last = end | 129 last = end |
130 outlen += length | 130 outlen += length |
131 | 131 |
132 if bin != binend: | 132 if bin != binend: |
133 raise mpatchError("patch cannot be decoded") | 133 raise mpatchError(b"patch cannot be decoded") |
134 | 134 |
135 outlen += orig - last | 135 outlen += orig - last |
136 return outlen | 136 return outlen |