changeset 4899:1b7bbc4349e7

patch.py: don't mark files as changed unless they have actually been changed
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 17 Jul 2007 09:39:30 -0700
parents bc905a6c0e76
children e56c7e05c7e6
files mercurial/patch.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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,