changeset 14565:3cacc232f27f

patch: stop updating changed files set in applydiff() This information is more correctly returned by backends. The extra updated file removed from test-mq-merge.t output came from changes from git patches being counted before being really applied in some cases.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 11 Jun 2011 14:14:13 +0200
parents 65f4512e40e4
children d0c2cc11e611
files mercurial/patch.py tests/test-mq-merge.t
diffstat 2 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Sat Jun 11 14:14:11 2011 +0200
+++ b/mercurial/patch.py	Sat Jun 11 14:14:13 2011 +0200
@@ -1193,21 +1193,20 @@
         gp = gitpatches.pop()[2]
         yield 'file', ('a/' + gp.path, 'b/' + gp.path, None, gp)
 
-def applydiff(ui, fp, changed, backend, store, strip=1, eolmode='strict'):
+def applydiff(ui, fp, backend, store, strip=1, eolmode='strict'):
     """Reads a patch from fp and tries to apply it.
 
-    The dict 'changed' is filled in with all of the filenames changed
-    by the patch. Returns 0 for a clean patch, -1 if any rejects were
-    found and 1 if there was any fuzz.
+    Returns 0 for a clean patch, -1 if any rejects were found and 1 if
+    there was any fuzz.
 
     If 'eolmode' is 'strict', the patch content and patched file are
     read in binary mode. Otherwise, line endings are ignored when
     patching then normalized according to 'eolmode'.
     """
-    return _applydiff(ui, fp, patchfile, backend, store, changed, strip=strip,
+    return _applydiff(ui, fp, patchfile, backend, store, strip=strip,
                       eolmode=eolmode)
 
-def _applydiff(ui, fp, patcher, backend, store, changed, strip=1,
+def _applydiff(ui, fp, patcher, backend, store, strip=1,
                eolmode='strict'):
 
     def pstrip(p):
@@ -1222,10 +1221,8 @@
             if not current_file:
                 continue
             ret = current_file.apply(values)
-            if ret >= 0:
-                changed.add(current_file.fname)
-                if ret > 0:
-                    err = 1
+            if ret > 0:
+                err = 1
         elif state == 'file':
             if current_file:
                 rejects += current_file.close()
@@ -1236,7 +1233,6 @@
                 path = pstrip(gp.path)
                 if gp.oldpath:
                     copysource = pstrip(gp.oldpath)
-                changed.add(path)
                 if gp.op == 'RENAME':
                     backend.unlink(copysource)
                 if not first_hunk:
@@ -1354,7 +1350,7 @@
     except TypeError:
         fp = patchobj
     try:
-        ret = applydiff(ui, fp, files, backend, store, strip=strip,
+        ret = applydiff(ui, fp, backend, store, strip=strip,
                         eolmode=eolmode)
     finally:
         if fp != patchobj:
--- a/tests/test-mq-merge.t	Sat Jun 11 14:14:11 2011 +0200
+++ b/tests/test-mq-merge.t	Sat Jun 11 14:14:13 2011 +0200
@@ -130,7 +130,7 @@
   patch failed, unable to continue (try -v)
   patch failed, rejects left in working dir
   patch didn't work out, merging patcha
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   0 files updated, 2 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   applying patcha2