# HG changeset patch # User Mads Kiilerich # Date 2010-04-26 11:21:03 # Node ID c47a1cfad57215d88153b7d90b341e8d87252cc2 # Parent dd157720a8ee89708ca187d2ea3a48f633c72f7d patch: minor cleanup of _applydiff diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1153,8 +1153,8 @@ def _applydiff(ui, fp, patcher, copyfn, rejects = 0 err = 0 current_file = None - gitpatches = None - opener = util.opener(os.getcwd()) + cwd = os.getcwd() + opener = util.opener(cwd) def closefile(): if not current_file: @@ -1166,8 +1166,7 @@ def _applydiff(ui, fp, patcher, copyfn, if state == 'hunk': if not current_file: continue - current_hunk = values - ret = current_file.apply(current_hunk) + ret = current_file.apply(values) if ret >= 0: changed.setdefault(current_file.fname, None) if ret > 0: @@ -1186,13 +1185,11 @@ def _applydiff(ui, fp, patcher, copyfn, missing=missing, eolmode=eolmode) except PatchError, err: ui.warn(str(err) + '\n') - current_file, current_hunk = None, None + current_file = None rejects += 1 continue elif state == 'git': - gitpatches = values - cwd = os.getcwd() - for gp in gitpatches: + for gp in values: if gp.op in ('COPY', 'RENAME'): copyfn(gp.oldpath, gp.path, cwd) changed[gp.path] = gp