# HG changeset patch # User Dirkjan Ochtman # Date 1245598473 -7200 # Node ID 801cacf46e62d7281292915cbfcf92c19086ba22 # Parent 74baf78202e88bf50dcd3e5ddf0846bc8db6c5a0 mq: fix error message for qpush inexistent-patch (issue1702) diff -r 74baf78202e8 -r 801cacf46e62 hgext/mq.py --- 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() diff -r 74baf78202e8 -r 801cacf46e62 tests/test-mq-qpush-fail --- 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 diff -r 74baf78202e8 -r 801cacf46e62 tests/test-mq-qpush-fail.out --- 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