changeset 8875:801cacf46e62

mq: fix error message for qpush inexistent-patch (issue1702)
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Sun, 21 Jun 2009 17:34:33 +0200
parents 74baf78202e8
children e4e22a310b62
files hgext/mq.py tests/test-mq-qpush-fail tests/test-mq-qpush-fail.out
diffstat 3 files changed, 28 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Sun Jun 21 16:54:57 2009 +0200
+++ b/hgext/mq.py	Sun Jun 21 17:34:33 2009 +0200
@@ -543,6 +543,8 @@
 
     def _apply(self, repo, series, list=False, update_status=True,
                strict=False, patchdir=None, merge=None, all_files={}):
+        '''returns (error, hash)
+        error = 1 for unable to read, 2 for patch failed, 3 for patch fuzz'''
         # TODO unify with commands.py
         if not patchdir:
             patchdir = self.path
@@ -559,7 +561,7 @@
             try:
                 ph = patchheader(self.join(patchname))
             except:
-                self.ui.warn(_("Unable to read %s\n") % patchname)
+                self.ui.warn(_("unable to read %s\n") % patchname)
                 err = 1
                 break
 
@@ -607,12 +609,12 @@
 
             if patcherr:
                 self.ui.warn(_("patch failed, rejects left in working dir\n"))
-                err = 1
+                err = 2
                 break
 
             if fuzz and strict:
                 self.ui.warn(_("fuzz found when applying patch, stopping\n"))
-                err = 1
+                err = 3
                 break
         return (err, n)
 
@@ -953,6 +955,7 @@
                 end = start + 1
             else:
                 end = self.series.index(patch, start) + 1
+
             s = self.series[start:end]
             all_files = {}
             try:
@@ -972,13 +975,15 @@
                         util.unlink(repo.wjoin(f))
                 self.ui.warn(_('done\n'))
                 raise
+
             top = self.applied[-1].name
-            if ret[0]:
-                self.ui.write(_("errors during apply, please fix and "
-                                "refresh %s\n") % top)
+            if ret[0] and ret[0] > 1:
+                msg = _("errors during apply, please fix and refresh %s\n")
+                self.ui.write(msg % top)
             else:
                 self.ui.write(_("now at: %s\n") % top)
             return ret[0]
+
         finally:
             wlock.release()
 
--- a/tests/test-mq-qpush-fail	Sun Jun 21 16:54:57 2009 +0200
+++ b/tests/test-mq-qpush-fail	Sun Jun 21 17:34:33 2009 +0200
@@ -45,3 +45,12 @@
 
 echo '% bar should be gone; other unknown/ignored files should still be around'
 hg status -A
+
+echo '% preparing qpush of a missing patch'
+hg qpop -a
+hg qpush
+rm .hg/patches/patch2
+echo '% now we expect the push to fail, but it should NOT complain about patch1'
+hg qpush
+
+true # happy ending
--- a/tests/test-mq-qpush-fail.out	Sun Jun 21 16:54:57 2009 +0200
+++ b/tests/test-mq-qpush-fail.out	Sun Jun 21 17:34:33 2009 +0200
@@ -19,3 +19,11 @@
 ? untracked-file
 I .hgignore
 C foo
+% preparing qpush of a missing patch
+no patches applied
+applying patch1
+now at: patch1
+% now we expect the push to fail, but it should NOT complain about patch1
+applying patch2
+unable to read patch2
+now at: patch1