errors: introduce CanceledError and use it in a few places
This very similar to earlier patches (e.g. for `InputError`) and part
of https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan.
Differential Revision: https://phab.mercurial-scm.org/D9339
--- a/hgext/absorb.py Tue Nov 17 15:51:09 2020 -0800
+++ b/hgext/absorb.py Thu Oct 22 14:14:59 2020 -0700
@@ -1076,7 +1076,7 @@
b"apply changes (y/N)? $$ &Yes $$ &No", default=1
)
):
- raise error.Abort(_(b'absorb cancelled\n'))
+ raise error.CanceledError(_(b'absorb cancelled\n'))
state.apply()
if state.commit():
--- a/mercurial/commands.py Tue Nov 17 15:51:09 2020 -0800
+++ b/mercurial/commands.py Thu Oct 22 14:14:59 2020 -0700
@@ -5830,7 +5830,7 @@
if ui.promptchoice(
_(b're-merge all unresolved files (yn)?$$ &Yes $$ &No')
):
- raise error.Abort(_(b'user quit'))
+ raise error.CanceledError(_(b'user quit'))
if mark and not pats:
if ui.promptchoice(
_(
@@ -5838,7 +5838,7 @@
b'$$ &Yes $$ &No'
)
):
- raise error.Abort(_(b'user quit'))
+ raise error.CanceledError(_(b'user quit'))
if unmark and not pats:
if ui.promptchoice(
_(
@@ -5846,7 +5846,7 @@
b'$$ &Yes $$ &No'
)
):
- raise error.Abort(_(b'user quit'))
+ raise error.CanceledError(_(b'user quit'))
uipathfn = scmutil.getuipathfn(repo)
--- a/mercurial/crecord.py Tue Nov 17 15:51:09 2020 -0800
+++ b/mercurial/crecord.py Thu Oct 22 14:14:59 2020 -0700
@@ -1894,7 +1894,7 @@
elif keypressed in ["H", "KEY_SLEFT"]:
self.leftarrowshiftevent()
elif keypressed in ["q"]:
- raise error.Abort(_(b'user quit'))
+ raise error.CanceledError(_(b'user quit'))
elif keypressed in ['a']:
self.flipselections()
elif keypressed in ["c"]:
--- a/mercurial/error.py Tue Nov 17 15:51:09 2020 -0800
+++ b/mercurial/error.py Thu Oct 22 14:14:59 2020 -0700
@@ -195,6 +195,13 @@
"""
+class CanceledError(Abort):
+ """Indicates that the user canceled the operation.
+
+ Examples: Close commit editor with error status, quit chistedit.
+ """
+
+
class HookLoadError(Abort):
"""raised when loading a hook fails, aborting an operation
--- a/mercurial/exchange.py Tue Nov 17 15:51:09 2020 -0800
+++ b/mercurial/exchange.py Thu Oct 22 14:14:59 2020 -0700
@@ -193,7 +193,7 @@
_(b'push and publish %i changesets (yn)?$$ &Yes $$ &No')
% len(published)
):
- raise error.Abort(_(b'user quit'))
+ raise error.CanceledError(_(b'user quit'))
elif behavior == b'abort':
msg = _(b'push would publish %i changesets') % len(published)
hint = _(
--- a/mercurial/patch.py Tue Nov 17 15:51:09 2020 -0800
+++ b/mercurial/patch.py Thu Oct 22 14:14:59 2020 -0700
@@ -1272,7 +1272,7 @@
elif r == 6: # all
ret = skipall = True
elif r == 7: # quit
- raise error.Abort(_(b'user quit'))
+ raise error.CanceledError(_(b'user quit'))
return ret, skipfile, skipall, newpatches
seen = set()
--- a/mercurial/scmutil.py Tue Nov 17 15:51:09 2020 -0800
+++ b/mercurial/scmutil.py Thu Oct 22 14:14:59 2020 -0700
@@ -261,6 +261,8 @@
detailed_exit_code = 20
elif isinstance(inst, error.ConfigError):
detailed_exit_code = 30
+ elif isinstance(inst, error.CanceledError):
+ detailed_exit_code = 250
ui.error(_(b"abort: %s\n") % inst.message)
if inst.hint:
ui.error(_(b"(%s)\n") % inst.hint)
--- a/mercurial/ui.py Tue Nov 17 15:51:09 2020 -0800
+++ b/mercurial/ui.py Thu Oct 22 14:14:59 2020 -0700
@@ -1852,7 +1852,7 @@
self.system(
b"%s \"%s\"" % (editor, name),
environ=environ,
- onerr=error.Abort,
+ onerr=error.CanceledError,
errprefix=_(b"edit failed"),
blockedtag=b'editor',
)
--- a/tests/test-commit-interactive.t Tue Nov 17 15:51:09 2020 -0800
+++ b/tests/test-commit-interactive.t Thu Oct 22 14:14:59 2020 -0700
@@ -885,7 +885,7 @@
(enter ? for help) [Ynesfdaq?] q
abort: user quit
- [255]
+ [250]
Patterns
@@ -1014,7 +1014,7 @@
(enter ? for help) [Ynesfdaq?] q
abort: user quit
- [255]
+ [250]
s, all
@@ -1419,7 +1419,7 @@
(enter ? for help) [Ynesfdaq?] q
abort: user quit
- [255]
+ [250]
$ hg revert editedfile
Removing changes from patch
--- a/tests/test-commit.t Tue Nov 17 15:51:09 2020 -0800
+++ b/tests/test-commit.t Thu Oct 22 14:14:59 2020 -0700
@@ -155,7 +155,7 @@
$ HGEDITOR=false hg ci --addremove
adding newfile
abort: edit failed: false exited with status 1
- [255]
+ [250]
$ hg status
? newfile
--- a/tests/test-editor-filename.t Tue Nov 17 15:51:09 2020 -0800
+++ b/tests/test-editor-filename.t Thu Oct 22 14:14:59 2020 -0700
@@ -17,7 +17,7 @@
$ hg commit
*.commit.hg.txt (glob)
abort: edit failed: sh exited with status 1
- [255]
+ [250]
Verify that the path for a histedit editor has the expected suffix.
@@ -30,7 +30,7 @@
$ hg histedit
*.histedit.hg.txt (glob)
abort: edit failed: sh exited with status 1
- [255]
+ [250]
Verify that when performing an action that has the side-effect of creating an
editor for a diff, the file ends in .diff.
@@ -61,4 +61,4 @@
(enter ? for help) [Ynesfdaq?] q
abort: user quit
- [255]
+ [250]
--- a/tests/test-rebase-collapse.t Tue Nov 17 15:51:09 2020 -0800
+++ b/tests/test-rebase-collapse.t Thu Oct 22 14:14:59 2020 -0700
@@ -760,7 +760,7 @@
already rebased 1:f899f3910ce7 B "B" as 82b8abf9c185
rebasing 3:63668d570d21 C tip "C"
abort: edit failed: false exited with status 1
- [255]
+ [250]
$ hg tglog
o 3: 63668d570d21 'C'
|
--- a/tests/test-rebase-transaction.t Tue Nov 17 15:51:09 2020 -0800
+++ b/tests/test-rebase-transaction.t Thu Oct 22 14:14:59 2020 -0700
@@ -171,7 +171,7 @@
transaction abort!
rollback completed
abort: edit failed: false exited with status 1
- [255]
+ [250]
$ hg tglog
o 5: D
|
--- a/tests/test-resolve.t Tue Nov 17 15:51:09 2020 -0800
+++ b/tests/test-resolve.t Thu Oct 22 14:14:59 2020 -0700
@@ -495,7 +495,7 @@
> EOF
re-merge all unresolved files (yn)? n
abort: user quit
- [255]
+ [250]
$ hg resolve --all << EOF
> y
@@ -523,7 +523,7 @@
> EOF
mark all unresolved files as resolved (yn)? n
abort: user quit
- [255]
+ [250]
$ hg resolve -m << EOF
> y
@@ -551,7 +551,7 @@
> EOF
mark all resolved files as unresolved (yn)? n
abort: user quit
- [255]
+ [250]
$ hg resolve -m << EOF
> y
--- a/tests/test-revert-interactive.t Tue Nov 17 15:51:09 2020 -0800
+++ b/tests/test-revert-interactive.t Thu Oct 22 14:14:59 2020 -0700
@@ -153,7 +153,7 @@
(enter ? for help) [Ynesfdaq?] q
abort: user quit
- [255]
+ [250]
$ ls folder1/
g
--- a/tests/test-split.t Tue Nov 17 15:51:09 2020 -0800
+++ b/tests/test-split.t Thu Oct 22 14:14:59 2020 -0700
@@ -159,7 +159,7 @@
transaction abort!
rollback completed
abort: edit failed: false exited with status 1
- [255]
+ [250]
$ hg status
$ HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py"