patch.py: don't mark files as changed unless they have actually been changed
authorBryan O'Sullivan <bos@serpentine.com>
Tue, 17 Jul 2007 09:39:30 -0700
changeset 4899 1b7bbc4349e7
parent 4898 bc905a6c0e76
child 4900 e56c7e05c7e6
patch.py: don't mark files as changed unless they have actually been changed
mercurial/patch.py
--- a/mercurial/patch.py	Tue Jul 17 09:39:30 2007 -0700
+++ b/mercurial/patch.py	Tue Jul 17 09:39:30 2007 -0700
@@ -828,8 +828,10 @@
             if x.startswith('\ '):
                 current_hunk.fix_newline()
             ret = current_file.apply(current_hunk, reverse)
-            if ret > 0:
-                err = 1
+            if ret >= 0:
+                changed.setdefault(current_file.fname, (None, None))
+                if ret > 0:
+                    err = 1
             current_hunk = None
             gitworkdone = False
         if ((sourcefile or state == BFILE) and ((not context and x[0] == '@') or
@@ -850,7 +852,6 @@
                     current_file = selectfile(afile, bfile, current_hunk,
                                               strip, reverse)
                     current_file = patchfile(ui, current_file)
-                changed.setdefault(current_file.fname, (None, None))
         elif state == BFILE and x.startswith('GIT binary patch'):
             current_hunk = binhunk(changed[bfile[2:]][1])
             if not current_file:
@@ -917,8 +918,10 @@
     if current_hunk:
         if current_hunk.complete():
             ret = current_file.apply(current_hunk, reverse)
-            if ret > 0:
-                err = 1
+            if ret >= 0:
+                changed.setdefault(current_file.fname, (None, None))
+                if ret > 0:
+                    err = 1
         else:
             fname = current_file and current_file.fname or None
             raise PatchError(_("malformed patch %s %s") % (fname,