# HG changeset patch # User Patrick Mezard # Date 2011-05-19 20:44:01 # Node ID e1b4a7a7263a5a3c5f919c51d2a33ce9c55fe505 # Parent c2ef8cc507489ceb6b98fa816a7357c489c2f112 patch: reindent code diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1149,22 +1149,23 @@ def iterhunks(fp): yield 'file', (afile, bfile, h, gp and gp.mode or None) yield 'hunk', h elif x.startswith('diff --git'): - # check for git diff, scanning the whole patch file if needed m = gitre.match(x) - if m: - if not git: - git = True - gitpatches = scangitpatch(lr, x) - for gp in gitpatches: - 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 - if gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') or gp.mode: - afile = bfile - newfile = True + if not m: + continue + if not git: + # scan whole input for git metadata + git = True + gitpatches = scangitpatch(lr, x) + for gp in gitpatches: + 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 + if gp.op in ('COPY', 'DELETE', 'RENAME', 'ADD') or gp.mode: + afile = bfile + newfile = True elif x.startswith('---'): # check for a unified diff l2 = lr.readline()