Mercurial > hg-stable
changeset 3374:fd43ff3b4442
Use line length field when extracting git binary patches
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 12 Oct 2006 13:39:14 -0700 |
parents | 9851f46d6ecc |
children | 58202386deb7 |
files | mercurial/patch.py |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Thu Oct 12 13:24:09 2006 -0700 +++ b/mercurial/patch.py Thu Oct 12 13:39:14 2006 -0700 @@ -191,18 +191,22 @@ def dogitpatch(patchname, gitpatches, cwd=None): """Preprocess git patch so that vanilla patch can handle it""" def extractbin(fp): - line = fp.readline() + line = fp.readline().rstrip() while line and not line.startswith('literal '): - line = fp.readline() + line = fp.readline().rstrip() if not line: return - size = int(line[8:].rstrip()) + size = int(line[8:]) dec = [] - line = fp.readline() + line = fp.readline().rstrip() while line: - line = line[1:-1] - dec.append(base85.b85decode(line)) - line = fp.readline() + l = line[0] + if l <= 'Z' and l >= 'A': + l = ord(l) - ord('A') + 1 + else: + l = ord(l) - ord('a') + 27 + dec.append(base85.b85decode(line[1:])[:l]) + line = fp.readline().rstrip() text = zlib.decompress(''.join(dec)) if len(text) != size: raise util.Abort(_('binary patch is %d bytes, not %d') %