Patchwork D9330: errors: raise more specific errors from rewriteutil

login
register
mail settings
Submitter phabricator
Date Nov. 17, 2020, 12:29 a.m.
Message ID <differential-rev-PHID-DREV-7jaafiu2rolq4ddvtgoi-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47608/
State Superseded
Headers show

Comments

phabricator - Nov. 17, 2020, 12:29 a.m.
martinvonz created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9330

AFFECTED FILES
  mercurial/rewriteutil.py
  tests/test-amend.t
  tests/test-branch-change.t
  tests/test-commit-amend.t
  tests/test-fix.t
  tests/test-histedit-obsolete.t
  tests/test-rebase-collapse.t
  tests/test-rebase-scenario-global.t
  tests/test-split.t
  tests/test-unamend.t
  tests/test-uncommit.t

CHANGE DETAILS




To: martinvonz, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -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
diff --git a/tests/test-unamend.t b/tests/test-unamend.t
--- a/tests/test-unamend.t
+++ b/tests/test-unamend.t
@@ -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
 
diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -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
diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -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"
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
@@ -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
 
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -309,7 +309,7 @@ 
   $ hg histedit -r '.~2'
   abort: cannot edit public changesets
   (see 'hg help phases' for details)
-  [255]
+  [10]
 
 
 Prepare further testing
diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -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
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -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):
diff --git a/tests/test-branch-change.t b/tests/test-branch-change.t
--- a/tests/test-branch-change.t
+++ b/tests/test-branch-change.t
@@ -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
 
diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -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
 
diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -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):