diff --git a/hgext/absorb.py b/hgext/absorb.py --- a/hgext/absorb.py +++ b/hgext/absorb.py @@ -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(): diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -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) diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -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"]: diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -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 diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -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 = _( diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -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() diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -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) diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -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', ) diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t --- a/tests/test-commit-interactive.t +++ b/tests/test-commit-interactive.t @@ -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 diff --git a/tests/test-commit.t b/tests/test-commit.t --- a/tests/test-commit.t +++ b/tests/test-commit.t @@ -155,7 +155,7 @@ $ HGEDITOR=false hg ci --addremove adding newfile abort: edit failed: false exited with status 1 - [255] + [250] $ hg status ? newfile diff --git a/tests/test-editor-filename.t b/tests/test-editor-filename.t --- a/tests/test-editor-filename.t +++ b/tests/test-editor-filename.t @@ -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] diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t --- a/tests/test-rebase-collapse.t +++ b/tests/test-rebase-collapse.t @@ -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' | diff --git a/tests/test-rebase-transaction.t b/tests/test-rebase-transaction.t --- a/tests/test-rebase-transaction.t +++ b/tests/test-rebase-transaction.t @@ -171,7 +171,7 @@ transaction abort! rollback completed abort: edit failed: false exited with status 1 - [255] + [250] $ hg tglog o 5: D | diff --git a/tests/test-resolve.t b/tests/test-resolve.t --- a/tests/test-resolve.t +++ b/tests/test-resolve.t @@ -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 diff --git a/tests/test-revert-interactive.t b/tests/test-revert-interactive.t --- a/tests/test-revert-interactive.t +++ b/tests/test-revert-interactive.t @@ -153,7 +153,7 @@ (enter ? for help) [Ynesfdaq?] q abort: user quit - [255] + [250] $ ls folder1/ g diff --git a/tests/test-split.t b/tests/test-split.t --- a/tests/test-split.t +++ b/tests/test-split.t @@ -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"