# HG changeset patch # User Patrick Mezard # Date 2011-05-19 20:44:01 # Node ID c2ef8cc507489ceb6b98fa816a7357c489c2f112 # Parent 7709cc9830255be66290f5ae02391c7dcd80a98a patch: unify iterhunks() afile/bfile handling git afile/bfile are extracted twice, once when reading a 'diff --git', and again when reading a unified hunk. The problem is not all git blocks have unified hunks (renames just have metadata) and they were not extracted the same way. This is what this patch unifies. diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1137,8 +1137,6 @@ def iterhunks(fp): gp = changed.get(bfile) if x.startswith('GIT binary patch'): h = binhunk(gp, lr) - afile = 'a/' + afile - bfile = 'b/' + bfile else: if context is None and x.startswith('***************'): context = True @@ -1154,15 +1152,16 @@ def iterhunks(fp): # check for git diff, scanning the whole patch file if needed m = gitre.match(x) if m: - afile, bfile = m.group(1, 2) if not git: git = True gitpatches = scangitpatch(lr, x) for gp in gitpatches: - changed[gp.path] = gp + changed['b/' + gp.path] = gp yield 'git', gitpatches + afile = 'a/' + m.group(1) + bfile = 'b/' + m.group(2) + gp = changed[bfile] # copy/rename + modify should modify target, not source - gp = changed[bfile] if gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') or gp.mode: afile = bfile newfile = True