mq: handle empty patches more gracefully (issue1501)
authorMatt Mackall <mpm@selenic.com>
Mon, 16 Feb 2009 17:37:23 -0600
changeset 7782 140429276b63
parent 7781 a45206455d85
child 7783 2c5b2abfb8be
mq: handle empty patches more gracefully (issue1501)
hgext/mq.py
tests/test-mq-qdelete.out
tests/test-mq.out
--- a/hgext/mq.py	Mon Feb 16 17:37:23 2009 -0600
+++ b/hgext/mq.py	Mon Feb 16 17:37:23 2009 -0600
@@ -551,9 +551,13 @@
                     message.append(_("\nimported patch %s") % patchname)
                 message = '\n'.join(message)
 
-            (patcherr, files, fuzz) = self.patch(repo, pf)
-            all_files.update(files)
-            patcherr = not patcherr
+            if ph.haspatch:
+                (patcherr, files, fuzz) = self.patch(repo, pf)
+                all_files.update(files)
+                patcherr = not patcherr
+            else:
+                self.ui.warn(_("patch %s is empty\n") % patchname)
+                patcherr, files, fuzz = 0, [], 0
 
             if merge and files:
                 # Mark as removed/merged and update dirstate parent info
@@ -583,12 +587,8 @@
                 self.applied.append(statusentry(hex(n), patchname))
 
             if patcherr:
-                if not ph.haspatch:
-                    self.ui.warn(_("patch %s is empty\n") % patchname)
-                    err = 0
-                else:
-                    self.ui.warn(_("patch failed, rejects left in working dir\n"))
-                    err = 1
+                self.ui.warn(_("patch failed, rejects left in working dir\n"))
+                err = 1
                 break
 
             if fuzz and strict:
--- a/tests/test-mq-qdelete.out	Mon Feb 16 17:37:23 2009 -0600
+++ b/tests/test-mq-qdelete.out	Mon Feb 16 17:37:23 2009 -0600
@@ -30,6 +30,7 @@
 now at: b
 abort: unknown revision 'c'!
 applying c
+patch c is empty
 now at: c
 c
 3 imported patch c
--- a/tests/test-mq.out	Mon Feb 16 17:37:23 2009 -0600
+++ b/tests/test-mq.out	Mon Feb 16 17:37:23 2009 -0600
@@ -486,8 +486,6 @@
 abort: local changes found, refresh first
 % apply force, should not discard changes with empty patch
 applying empty
-patch: **** Only garbage was found in the patch input.
-patch failed, unable to continue (try -v)
 patch empty is empty
 now at: empty
 diff -r bf5fc3f07a0a hello.txt