# HG changeset patch # User Matt Mackall # Date 1429571624 18000 # Node ID 9b02b678888ed7b600e94bca0613e800bbe29dee # Parent 7f9655f3716390df1484ebda60b38a2d191024b6 mq: avoid silent failure when single patch doesn't apply (issue4604) The error-handling here is quite byzantine. self._apply raises an AbortNoCleanup, but self.apply was swallowing the exception and returns 2. In self.push, we catch all exceptions.. and cleanup. We try to print a message to clean up.. but that relies on having a top-of-stack. Instead, we re-raise the abort in self.apply, and avoid cleanup on AbortNoCleanup in self.push by adding a trivial new except clause. We also modernize the now-visible abort message. diff -r 7f9655f37163 -r 9b02b678888e hgext/mq.py --- a/hgext/mq.py Mon Apr 20 17:16:05 2015 +0200 +++ b/hgext/mq.py Mon Apr 20 18:13:44 2015 -0500 @@ -822,7 +822,7 @@ except AbortNoCleanup: tr.close() self.savedirty() - return 2, repo.dirstate.p1() + raise except: # re-raises try: tr.abort() @@ -880,7 +880,8 @@ touched = set(touched) & tobackup if touched and keepchanges: raise AbortNoCleanup( - _("local changes found, refresh first")) + _("conflicting local changes found"), + hint=_("did you forget to qrefresh?")) self.backup(repo, touched, copy=True) tobackup = tobackup - touched (patcherr, files, fuzz) = self.patch(repo, pf) @@ -1417,6 +1418,8 @@ else: ret = self.apply(repo, s, list, all_files=all_files, tobackup=tobackup, keepchanges=keepchanges) + except AbortNoCleanup: + raise except: # re-raises self.ui.warn(_('cleaning up working directory...')) node = repo.dirstate.p1() diff -r 7f9655f37163 -r 9b02b678888e tests/test-mq-qpush-fail.t --- a/tests/test-mq-qpush-fail.t Mon Apr 20 17:16:05 2015 +0200 +++ b/tests/test-mq-qpush-fail.t Mon Apr 20 18:13:44 2015 -0500 @@ -344,25 +344,29 @@ $ echo b >> b $ hg qpush --keep-changes applying p3 - errors during apply, please fix and refresh p2 - [2] + abort: conflicting local changes found + (did you forget to qrefresh?) + [255] $ rm b $ hg qpush --keep-changes applying p3 - errors during apply, please fix and refresh p2 - [2] + abort: conflicting local changes found + (did you forget to qrefresh?) + [255] $ hg rm -A b $ hg qpush --keep-changes applying p3 - errors during apply, please fix and refresh p2 - [2] + abort: conflicting local changes found + (did you forget to qrefresh?) + [255] $ hg revert -aq b $ echo d > d $ hg add d $ hg qpush --keep-changes applying p3 - errors during apply, please fix and refresh p2 - [2] + abort: conflicting local changes found + (did you forget to qrefresh?) + [255] $ hg forget d $ rm d $ hg qpop @@ -372,8 +376,9 @@ $ hg qpush -a --keep-changes applying p2 applying p3 - errors during apply, please fix and refresh p2 - [2] + abort: conflicting local changes found + (did you forget to qrefresh?) + [255] $ hg qtop p2 $ hg parents --template "{rev} {desc}\n"