Mercurial > hg-stable
changeset 3717:9e248cfd8b94
handle files with more than one git binary patch
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 27 Nov 2006 22:03:36 -0200 |
parents | ab5600428b08 |
children | 7db88b094b14 |
files | mercurial/patch.py tests/test-git-import tests/test-git-import.out |
diffstat | 3 files changed, 35 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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 - <<EOF +diff --git a/mbinary1 b/mbinary1 +new file mode 100644 +index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 +GIT binary patch +literal 4 +Lc\${NkU|;|M00aO5 + +diff --git a/mbinary2 b/mbinary2 +new file mode 100644 +index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490 +GIT binary patch +literal 5 +Mc\${NkU|\`?^000jF3jhEB + +EOF +hg manifest | grep mbinary
--- a/tests/test-git-import.out Mon Nov 27 22:03:31 2006 -0200 +++ b/tests/test-git-import.out Mon Nov 27 22:03:36 2006 -0200 @@ -58,3 +58,7 @@ applying patch from stdin foo 045c85ba38952325e126c70962cc0f9d9077bc67 644 binary +% many binary files +applying patch from stdin +045c85ba38952325e126c70962cc0f9d9077bc67 644 mbinary1 +a874b471193996e7cb034bb301cac7bdaf3e3f46 644 mbinary2