errors: raise more specific errors from rewriteutil
Differential Revision: https://phab.mercurial-scm.org/D9330
--- a/mercurial/rewriteutil.py Tue Nov 17 19:29:08 2020 +0900
+++ b/mercurial/rewriteutil.py Mon Nov 16 15:11:51 2020 -0800
@@ -33,20 +33,20 @@
if node.nullrev in revs:
msg = _(b"cannot %s null changeset") % action
hint = _(b"no changeset checked out")
- raise error.Abort(msg, hint=hint)
+ raise error.InputError(msg, hint=hint)
if len(repo[None].parents()) > 1:
- raise error.Abort(_(b"cannot %s while merging") % action)
+ raise error.StateError(_(b"cannot %s while merging") % action)
publicrevs = repo.revs(b'%ld and public()', revs)
if publicrevs:
msg = _(b"cannot %s public changesets") % action
hint = _(b"see 'hg help phases' for details")
- raise error.Abort(msg, hint=hint)
+ raise error.InputError(msg, hint=hint)
newunstable = disallowednewunstable(repo, revs)
if newunstable:
- raise error.Abort(_(b"cannot %s changeset with children") % action)
+ raise error.InputError(_(b"cannot %s changeset with children") % action)
def disallowednewunstable(repo, revs):
--- a/tests/test-amend.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-amend.t Mon Nov 16 15:11:51 2020 -0800
@@ -197,7 +197,7 @@
$ echo 2 >> B
$ hg amend
abort: cannot amend changeset with children
- [255]
+ [10]
#if obsstore-on
@@ -240,7 +240,7 @@
$ hg amend -m AMEND
abort: cannot amend public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
Amend a merge changeset
--- a/tests/test-branch-change.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-branch-change.t Mon Nov 16 15:11:51 2020 -0800
@@ -58,7 +58,7 @@
$ hg branch -r 1::3 foo
abort: cannot change branch of changeset with children
- [255]
+ [10]
Change with dirty working directory
@@ -129,7 +129,7 @@
$ hg branch -r 2 stable
abort: cannot change branch of changeset with children
- [255]
+ [10]
Enabling the allowunstable config and trying to change branch on a branch head
which is not a topological head
@@ -368,7 +368,7 @@
$ hg branch -r . def
abort: cannot change branch of public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
Merge commit with conflicts, with evolution and without
--- a/tests/test-commit-amend.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-commit-amend.t Mon Nov 16 15:11:51 2020 -0800
@@ -12,7 +12,7 @@
$ hg ci --amend
abort: cannot amend public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
$ hg phase -r . -f -d
$ echo a >> a
@@ -407,7 +407,7 @@
(branch merge, don't forget to commit)
$ hg ci --amend
abort: cannot amend while merging
- [255]
+ [20]
$ hg ci -m 'merge'
Refuse to amend if there is a merge conflict (issue5805):
--- a/tests/test-fix.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-fix.t Mon Nov 16 15:11:51 2020 -0800
@@ -266,11 +266,11 @@
$ hg fix -r 0
abort: cannot fix public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
$ hg fix -r 0 --working-dir
abort: cannot fix public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
$ hg cat -r tip hello.whole
hello
$ cat hello.whole
@@ -1174,7 +1174,7 @@
$ hg commit -m "second"
$ hg --config experimental.evolution.allowunstable=False fix -r '.^'
abort: cannot fix changeset with children
- [255]
+ [10]
$ hg fix -r '.^'
1 new orphan changesets
$ hg cat -r 2 foo.whole
--- a/tests/test-histedit-obsolete.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-histedit-obsolete.t Mon Nov 16 15:11:51 2020 -0800
@@ -309,7 +309,7 @@
$ hg histedit -r '.~2'
abort: cannot edit public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
Prepare further testing
--- a/tests/test-rebase-collapse.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-rebase-collapse.t Mon Nov 16 15:11:51 2020 -0800
@@ -551,7 +551,7 @@
$ hg rebase --collapse -r 1 -d 0
abort: cannot rebase changeset with children
(use --keep to keep original changesets)
- [255]
+ [10]
Test collapsing in place
--- a/tests/test-rebase-scenario-global.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-rebase-scenario-global.t Mon Nov 16 15:11:51 2020 -0800
@@ -327,15 +327,15 @@
$ hg rebase -d 0 -b 6
abort: cannot rebase public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
$ hg rebase -d 5 -b 6
abort: cannot rebase public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
$ hg rebase -d 5 -r '1 + (6::)'
abort: cannot rebase public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
$ hg rebase -d 5 -b 6 --keep
rebasing 6:e1c4361dd923 "C"
@@ -455,7 +455,7 @@
$ hg rebase -r '2::8' -d 1
abort: cannot rebase changeset with children
(use --keep to keep original changesets)
- [255]
+ [10]
$ hg rebase -r '2::8' -d 1 -k
rebasing 2:c9e50f6cdc55 "C"
rebasing 3:ffd453c31098 "D"
@@ -501,7 +501,7 @@
$ hg rebase -r '3::8' -d 1
abort: cannot rebase changeset with children
(use --keep to keep original changesets)
- [255]
+ [10]
$ hg rebase -r '3::8' -d 1 --keep
rebasing 3:ffd453c31098 "D"
rebasing 6:3d8a618087a7 "G"
@@ -544,7 +544,7 @@
$ hg rebase -r '3::7' -d 1
abort: cannot rebase changeset with children
(use --keep to keep original changesets)
- [255]
+ [10]
$ hg rebase -r '3::7' -d 1 --keep
rebasing 3:ffd453c31098 "D"
rebasing 6:3d8a618087a7 "G"
@@ -584,7 +584,7 @@
$ hg rebase -r '3::(7+5)' -d 1
abort: cannot rebase changeset with children
(use --keep to keep original changesets)
- [255]
+ [10]
$ hg rebase -r '3::(7+5)' -d 1 --keep
rebasing 3:ffd453c31098 "D"
rebasing 4:c01897464e7f "E"
--- a/tests/test-split.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-split.t Mon Nov 16 15:11:51 2020 -0800
@@ -79,7 +79,7 @@
$ hg split .
abort: cannot split public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
$ hg phase --draft -f -r 'all()'
@@ -467,7 +467,7 @@
#if obsstore-off
$ runsplit -r 1 --no-rebase
abort: cannot split changeset with children
- [255]
+ [10]
#else
$ runsplit -r 1 --no-rebase >/dev/null
3 new orphan changesets
@@ -518,7 +518,7 @@
$ rm .hg/localtags
$ hg split $B --config experimental.evolution=createmarkers
abort: cannot split changeset with children
- [255]
+ [10]
$ cat > $TESTTMP/messages <<EOF
> Split B
> EOF
--- a/tests/test-unamend.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-unamend.t Mon Nov 16 15:11:51 2020 -0800
@@ -284,7 +284,7 @@
$ hg --config experimental.evolution=createmarkers unamend
abort: cannot unamend changeset with children
- [255]
+ [10]
$ hg unamend
3 new orphan changesets
@@ -298,7 +298,7 @@
$ hg unamend
abort: cannot unamend public changesets
(see 'hg help phases' for details)
- [255]
+ [10]
Testing whether unamend retains copies or not
--- a/tests/test-uncommit.t Tue Nov 17 19:29:08 2020 +0900
+++ b/tests/test-uncommit.t Mon Nov 16 15:11:51 2020 -0800
@@ -53,7 +53,7 @@
$ hg uncommit
abort: cannot uncommit null changeset
(no changeset checked out)
- [255]
+ [10]
Create some commits
@@ -411,7 +411,7 @@
$ hg uncommit --config experimental.uncommitondirtywdir=True
abort: cannot uncommit while merging
- [255]
+ [20]
$ hg status
M a