# HG changeset patch # User Alexis S. L. Carvalho # Date 1164672216 7200 # Node ID 9e248cfd8b94bfa309e51c8f8d49e5ef0115a1b2 # Parent ab5600428b08aea75bbc212a7f4909552bcde549 handle files with more than one git binary patch diff -r ab5600428b08 -r 9e248cfd8b94 mercurial/patch.py --- a/mercurial/patch.py Mon Nov 27 22:03:31 2006 -0200 +++ b/mercurial/patch.py Mon Nov 27 22:03:36 2006 -0200 @@ -190,14 +190,18 @@ def dogitpatch(patchname, gitpatches, cwd=None): """Preprocess git patch so that vanilla patch can handle it""" def extractbin(fp): - line = fp.readline().rstrip() + i = [0] # yuck + def readline(): + i[0] += 1 + return fp.readline().rstrip() + line = readline() while line and not line.startswith('literal '): - line = fp.readline().rstrip() + line = readline() if not line: - return + return None, i[0] size = int(line[8:]) dec = [] - line = fp.readline().rstrip() + line = readline() while line: l = line[0] if l <= 'Z' and l >= 'A': @@ -205,12 +209,12 @@ else: l = ord(l) - ord('a') + 27 dec.append(base85.b85decode(line[1:])[:l]) - line = fp.readline().rstrip() + line = readline() text = zlib.decompress(''.join(dec)) if len(text) != size: raise util.Abort(_('binary patch is %d bytes, not %d') % (len(text), size)) - return text + return text, i[0] pf = file(patchname) pfline = 1 @@ -230,9 +234,10 @@ pfline += 1 if p.binary: - text = extractbin(pf) + text, delta = extractbin(pf) if not text: raise util.Abort(_('binary patch extraction failed')) + pfline += delta if not cwd: cwd = os.getcwd() absdst = os.path.join(cwd, p.path) diff -r ab5600428b08 -r 9e248cfd8b94 tests/test-git-import --- a/tests/test-git-import Mon Nov 27 22:03:31 2006 -0200 +++ b/tests/test-git-import Mon Nov 27 22:03:36 2006 -0200 @@ -162,3 +162,22 @@ EOF cat foo2 hg manifest | grep binary + +echo % many binary files +hg import -m multibinary - <