changeset 11021:c47a1cfad572

patch: minor cleanup of _applydiff
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 26 Apr 2010 13:21:03 +0200
parents dd157720a8ee
children 0429d0d49f92
files mercurial/patch.py
diffstat 1 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Mon Apr 26 13:21:02 2010 +0200
+++ b/mercurial/patch.py	Mon Apr 26 13:21:03 2010 +0200
@@ -1153,8 +1153,8 @@
     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 @@
         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 @@
                                            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