Mercurial > hg
comparison hgext/mq.py @ 24826:9b02b678888e stable
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.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 20 Apr 2015 18:13:44 -0500 |
parents | f1eaf03dd608 |
children | 58308ddea208 |
comparison
equal
deleted
inserted
replaced
24825:7f9655f37163 | 24826:9b02b678888e |
---|---|
820 self.savedirty() | 820 self.savedirty() |
821 return ret | 821 return ret |
822 except AbortNoCleanup: | 822 except AbortNoCleanup: |
823 tr.close() | 823 tr.close() |
824 self.savedirty() | 824 self.savedirty() |
825 return 2, repo.dirstate.p1() | 825 raise |
826 except: # re-raises | 826 except: # re-raises |
827 try: | 827 try: |
828 tr.abort() | 828 tr.abort() |
829 finally: | 829 finally: |
830 repo.invalidate() | 830 repo.invalidate() |
878 if tobackup: | 878 if tobackup: |
879 touched = patchmod.changedfiles(self.ui, repo, pf) | 879 touched = patchmod.changedfiles(self.ui, repo, pf) |
880 touched = set(touched) & tobackup | 880 touched = set(touched) & tobackup |
881 if touched and keepchanges: | 881 if touched and keepchanges: |
882 raise AbortNoCleanup( | 882 raise AbortNoCleanup( |
883 _("local changes found, refresh first")) | 883 _("conflicting local changes found"), |
884 hint=_("did you forget to qrefresh?")) | |
884 self.backup(repo, touched, copy=True) | 885 self.backup(repo, touched, copy=True) |
885 tobackup = tobackup - touched | 886 tobackup = tobackup - touched |
886 (patcherr, files, fuzz) = self.patch(repo, pf) | 887 (patcherr, files, fuzz) = self.patch(repo, pf) |
887 if all_files is not None: | 888 if all_files is not None: |
888 all_files.update(files) | 889 all_files.update(files) |
1415 if mergeq: | 1416 if mergeq: |
1416 ret = self.mergepatch(repo, mergeq, s, diffopts) | 1417 ret = self.mergepatch(repo, mergeq, s, diffopts) |
1417 else: | 1418 else: |
1418 ret = self.apply(repo, s, list, all_files=all_files, | 1419 ret = self.apply(repo, s, list, all_files=all_files, |
1419 tobackup=tobackup, keepchanges=keepchanges) | 1420 tobackup=tobackup, keepchanges=keepchanges) |
1421 except AbortNoCleanup: | |
1422 raise | |
1420 except: # re-raises | 1423 except: # re-raises |
1421 self.ui.warn(_('cleaning up working directory...')) | 1424 self.ui.warn(_('cleaning up working directory...')) |
1422 node = repo.dirstate.p1() | 1425 node = repo.dirstate.p1() |
1423 hg.revert(repo, node, None) | 1426 hg.revert(repo, node, None) |
1424 # only remove unknown files that we know we touched or | 1427 # only remove unknown files that we know we touched or |