D9391: errors: raise InputError when push fails because it creates new heads

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Nov 24 18:09:04 UTC 2020


martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I decided to raise `InputError` here because the user should adapt. I
  think remote errors (exit code 100) should be when something goes
  wrong on the remote and there's nothing the user can do.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/discovery.py
  tests/test-bookmarks-pushpull.t
  tests/test-exchange-obsmarkers-case-A3.t
  tests/test-obsolete-checkheads.t
  tests/test-phases-exchange.t
  tests/test-push-checkheads-multibranches-E3.t
  tests/test-push-checkheads-partial-C1.t
  tests/test-push-checkheads-partial-C2.t
  tests/test-push-checkheads-partial-C3.t
  tests/test-push-checkheads-partial-C4.t
  tests/test-push-checkheads-unpushed-D1.t
  tests/test-push-checkheads-unpushed-D2.t
  tests/test-push-checkheads-unpushed-D3.t
  tests/test-push-checkheads-unpushed-D4.t
  tests/test-push-checkheads-unpushed-D5.t
  tests/test-push-checkheads-unpushed-D6.t
  tests/test-push-warn.t
  tests/test-push.t
  tests/test-treediscovery-legacy.t
  tests/test-treediscovery.t

CHANGE DETAILS

diff --git a/tests/test-treediscovery.t b/tests/test-treediscovery.t
--- a/tests/test-treediscovery.t
+++ b/tests/test-treediscovery.t
@@ -271,7 +271,7 @@
   searching for changes
   abort: push creates new remote branches: both, name1
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
   $ hg push $remote --new-branch
   pushing to http://localhost:$HGPORT/
   searching for changes
diff --git a/tests/test-treediscovery-legacy.t b/tests/test-treediscovery-legacy.t
--- a/tests/test-treediscovery-legacy.t
+++ b/tests/test-treediscovery-legacy.t
@@ -287,7 +287,7 @@
   searching for changes
   abort: push creates new remote branches: both, name1
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
   $ hg push $remote --new-branch
   pushing to http://localhost:$HGPORT/
   searching for changes
diff --git a/tests/test-push.t b/tests/test-push.t
--- a/tests/test-push.t
+++ b/tests/test-push.t
@@ -387,7 +387,7 @@
   searching for changes
   abort: push creates new remote head [0-9a-f]+ (re)
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 (demonstrate that even though we don't have anything to exchange, we're still
 showing the error)
   $ hg push
diff --git a/tests/test-push-warn.t b/tests/test-push-warn.t
--- a/tests/test-push-warn.t
+++ b/tests/test-push-warn.t
@@ -33,7 +33,7 @@
   remote has heads on branch 'default' that are not known locally: 1c9246a22a0a
   abort: push creates new remote head 1e108cc5548c
   (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ hg push --debug ../a
   pushing to ../a
@@ -51,7 +51,7 @@
    1e108cc5548c
   abort: push creates new remote head 1e108cc5548c
   (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ hg pull ../a
   pulling from ../a
@@ -68,7 +68,7 @@
   searching for changes
   abort: push creates new remote head 1e108cc5548c
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ hg merge
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -121,7 +121,7 @@
   searching for changes
   abort: push creates new remote head 6346d66eb9f5
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ hg push -r 2 ../c
   pushing to ../c
@@ -134,7 +134,7 @@
   searching for changes
   abort: push creates new remote head a5dda829a167
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ hg push -v -r 3 -r 4 ../c
   pushing to ../c
@@ -144,7 +144,7 @@
    ee8fbc7a0295
   abort: push creates new remote head a5dda829a167
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ hg push -v -f -r 3 -r 4 ../c
   pushing to ../c
@@ -234,14 +234,14 @@
   searching for changes
   abort: push creates new remote branches: c
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
   $ hg push -r 4 -r 5 ../f
   pushing to ../f
   searching for changes
   abort: push creates new remote branches: c
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
 
 Multiple new branches:
@@ -255,14 +255,14 @@
   searching for changes
   abort: push creates new remote branches: c, d
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
   $ hg push -r 4 -r 6 ../f
   pushing to ../f
   searching for changes
   abort: push creates new remote branches: c, d
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
   $ cd ../g
 
@@ -278,7 +278,7 @@
   searching for changes
   abort: push creates new remote head 0b715ef6ff8f on branch 'a'
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
 Push replacement head on existing branches:
 
@@ -355,7 +355,7 @@
   searching for changes
   abort: push creates new remote branches: e
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
 
 Using --new-branch to push new named branch:
@@ -383,7 +383,7 @@
   searching for changes
   abort: push creates new branch 'f' with multiple heads
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ hg push --branch f --new-branch --force ../f
   pushing to ../f
   searching for changes
@@ -427,7 +427,7 @@
   remote has heads on branch 'default' that are not known locally: 534543e22c29 764f8ec07b96 afe7cc7679f5 ce4212fc8847
   abort: push creates new remote head 97bd0c84d346
   (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ hg -R h up -q 0; echo x > h/b; hg -R h ci -qAmx
   $ hg -R i push h
   pushing to h
@@ -435,7 +435,7 @@
   remote has heads on branch 'default' that are not known locally: 18ddb72c4590 534543e22c29 764f8ec07b96 afe7cc7679f5 and 1 others
   abort: push creates new remote head 97bd0c84d346
   (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ hg -R i push h -v
   pushing to h
   searching for changes
@@ -444,7 +444,7 @@
    97bd0c84d346
   abort: push creates new remote head 97bd0c84d346
   (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
 
 Check prepush logic with merged branches:
@@ -479,7 +479,7 @@
   searching for changes
   abort: push creates new remote branches: b
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
 
 Prepush -r should not allow you to sneak in new heads:
@@ -515,7 +515,7 @@
   searching for changes
   abort: push creates new remote head 451211cc22b0 on branch 'a'
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ..
 
@@ -765,14 +765,14 @@
   searching for changes
   abort: push creates new remote head 7d0f4fb6cf04 on branch 'A'
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ hg push inner -r4 -r5
   pushing to inner
   searching for changes
   abort: push creates new remote head 7d0f4fb6cf04 on branch 'A'
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ hg in inner
   comparing with inner
@@ -788,7 +788,7 @@
   running fail-push hook
   abort: push creates new remote head 7d0f4fb6cf04 on branch 'A'
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ..
 
@@ -817,7 +817,7 @@
   searching for changes
   abort: push creates new remote branches: foo (1 closed)
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
 When there is more than one closed branches
   $ hg -q branch bar
@@ -830,7 +830,7 @@
   searching for changes
   abort: push creates new remote branches: bar, foo (2 closed)
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
 When there are more than one new branches and not all are closed
   $ hg -q branch bar1
@@ -842,6 +842,6 @@
   searching for changes
   abort: push creates new remote branches: bar, bar1, foo (2 closed)
   (use 'hg push --new-branch' to create new remote branches)
-  [255]
+  [10]
 
   $ cd ..
diff --git a/tests/test-push-checkheads-unpushed-D6.t b/tests/test-push-checkheads-unpushed-D6.t
--- a/tests/test-push-checkheads-unpushed-D6.t
+++ b/tests/test-push-checkheads-unpushed-D6.t
@@ -81,6 +81,6 @@
   searching for changes
   abort: push creates new remote head 0f88766e02d6
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
diff --git a/tests/test-push-checkheads-unpushed-D5.t b/tests/test-push-checkheads-unpushed-D5.t
--- a/tests/test-push-checkheads-unpushed-D5.t
+++ b/tests/test-push-checkheads-unpushed-D5.t
@@ -100,7 +100,7 @@
   searching for changes
   abort: push creates new remote head 25c56d33e4c4
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ hg push --rev 'desc(A1)'
   pushing to $TESTTMP/D5/server
   searching for changes
diff --git a/tests/test-push-checkheads-unpushed-D4.t b/tests/test-push-checkheads-unpushed-D4.t
--- a/tests/test-push-checkheads-unpushed-D4.t
+++ b/tests/test-push-checkheads-unpushed-D4.t
@@ -111,7 +111,7 @@
   searching for changes
   abort: push creates new remote head f6082bc4ffef
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
 Actual testing (existing branch only)
 ------------------------------------
diff --git a/tests/test-push-checkheads-unpushed-D3.t b/tests/test-push-checkheads-unpushed-D3.t
--- a/tests/test-push-checkheads-unpushed-D3.t
+++ b/tests/test-push-checkheads-unpushed-D3.t
@@ -93,13 +93,13 @@
   searching for changes
   abort: push creates new remote head f6082bc4ffef
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ hg push --rev 'desc(B1)'
   pushing to $TESTTMP/D3/server
   searching for changes
   abort: push creates new remote head 25c56d33e4c4
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
 Extra testing
 -------------
@@ -111,6 +111,6 @@
   searching for changes
   abort: push creates new remote head 25c56d33e4c4
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
diff --git a/tests/test-push-checkheads-unpushed-D2.t b/tests/test-push-checkheads-unpushed-D2.t
--- a/tests/test-push-checkheads-unpushed-D2.t
+++ b/tests/test-push-checkheads-unpushed-D2.t
@@ -94,6 +94,6 @@
   searching for changes
   abort: push creates new remote head 0f88766e02d6
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
diff --git a/tests/test-push-checkheads-unpushed-D1.t b/tests/test-push-checkheads-unpushed-D1.t
--- a/tests/test-push-checkheads-unpushed-D1.t
+++ b/tests/test-push-checkheads-unpushed-D1.t
@@ -73,7 +73,7 @@
   searching for changes
   abort: push creates new remote head 74ff5441d343
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
 
diff --git a/tests/test-push-checkheads-partial-C4.t b/tests/test-push-checkheads-partial-C4.t
--- a/tests/test-push-checkheads-partial-C4.t
+++ b/tests/test-push-checkheads-partial-C4.t
@@ -81,6 +81,6 @@
   searching for changes
   abort: push creates new remote head 0f88766e02d6
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
diff --git a/tests/test-push-checkheads-partial-C3.t b/tests/test-push-checkheads-partial-C3.t
--- a/tests/test-push-checkheads-partial-C3.t
+++ b/tests/test-push-checkheads-partial-C3.t
@@ -80,6 +80,6 @@
   searching for changes
   abort: push creates new remote head 0f88766e02d6
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
diff --git a/tests/test-push-checkheads-partial-C2.t b/tests/test-push-checkheads-partial-C2.t
--- a/tests/test-push-checkheads-partial-C2.t
+++ b/tests/test-push-checkheads-partial-C2.t
@@ -81,6 +81,6 @@
   searching for changes
   abort: push creates new remote head f6082bc4ffef
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
diff --git a/tests/test-push-checkheads-partial-C1.t b/tests/test-push-checkheads-partial-C1.t
--- a/tests/test-push-checkheads-partial-C1.t
+++ b/tests/test-push-checkheads-partial-C1.t
@@ -80,6 +80,6 @@
   searching for changes
   abort: push creates new remote head 25c56d33e4c4
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
diff --git a/tests/test-push-checkheads-multibranches-E3.t b/tests/test-push-checkheads-multibranches-E3.t
--- a/tests/test-push-checkheads-multibranches-E3.t
+++ b/tests/test-push-checkheads-multibranches-E3.t
@@ -89,6 +89,6 @@
   searching for changes
   abort: push creates new remote head dc44c53142f0
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
   $ cd ../..
diff --git a/tests/test-phases-exchange.t b/tests/test-phases-exchange.t
--- a/tests/test-phases-exchange.t
+++ b/tests/test-phases-exchange.t
@@ -1017,7 +1017,7 @@
   searching for changes
   abort: push creates new remote head 435b5d83910c
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ hg push -fr 435b5d83910c ../mu # because the push will create new visible head
   pushing to ../mu
   searching for changes
diff --git a/tests/test-obsolete-checkheads.t b/tests/test-obsolete-checkheads.t
--- a/tests/test-obsolete-checkheads.t
+++ b/tests/test-obsolete-checkheads.t
@@ -97,7 +97,7 @@
   searching for changes
   abort: push creates new remote head 71e3228bffe1
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
 old head is now public (public remote version)
 ==============================================
@@ -157,7 +157,7 @@
   searching for changes
   abort: push creates new remote head d7d41ccbd4de
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
 
 
@@ -269,7 +269,7 @@
   remote has heads on branch 'default' that are not known locally: c70b08862e08
   abort: push creates new remote head 71e3228bffe1
   (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
 
 Pulling the missing data makes it work
 
@@ -319,4 +319,4 @@
   searching for changes
   abort: push creates new remote head 350a93b716be
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
diff --git a/tests/test-exchange-obsmarkers-case-A3.t b/tests/test-exchange-obsmarkers-case-A3.t
--- a/tests/test-exchange-obsmarkers-case-A3.t
+++ b/tests/test-exchange-obsmarkers-case-A3.t
@@ -201,7 +201,7 @@
   searching for changes
   abort: push creates new remote head e5ea8f9c7314
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ cd ..
 
 test obsmarkers exchange.
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -742,7 +742,7 @@
   searching for changes
   abort: push creates new remote head c922c0139ca0 with bookmark 'Y'
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ hg -R ../a book
      @                         1:0d2164f0ce0d
    * X                         1:0d2164f0ce0d
@@ -759,7 +759,7 @@
   searching for changes
   abort: push creates new remote head c922c0139ca0 with bookmark 'Y'
   (merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ hg -R ../a book
      @                         1:0d2164f0ce0d
    * X                         1:0d2164f0ce0d
@@ -1055,7 +1055,7 @@
   remote has heads on branch 'default' that are not known locally: a2a606d9ff1b
   abort: push creates new remote head 54694f811df9 with bookmark 'X'
   (pull and merge or see 'hg help push' for details about pushing new heads)
-  [255]
+  [10]
   $ cd ../addmarks
 
 Check summary output for incoming/outgoing bookmarks
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -359,7 +359,7 @@
 def checkheads(pushop):
     """Check that a push won't add any outgoing head
 
-    raise Abort error and display ui message as needed.
+    raise InputError error and display ui message as needed.
     """
 
     repo = pushop.repo.unfiltered()
@@ -406,7 +406,7 @@
         else:
             errmsg = _(b"push creates new remote branches: %s") % branchnames
         hint = _(b"use 'hg push --new-branch' to create new remote branches")
-        raise error.Abort(errmsg, hint=hint)
+        raise error.InputError(errmsg, hint=hint)
 
     # 2. Find heads that we need not warn about
     nowarnheads = _nowarnheads(pushop)
@@ -499,7 +499,7 @@
             for h in dhs:
                 repo.ui.note(b" %s\n" % short(h))
     if errormsg:
-        raise error.Abort(errormsg, hint=hint)
+        raise error.InputError(errormsg, hint=hint)
 
 
 def _postprocessobsolete(pushop, futurecommon, candidate_newhs):



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


More information about the Mercurial-devel mailing list