errors: raise StateError when push fails because it creates new heads
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 23 Nov 2020 16:39:53 -0800
changeset 46120 9261f6c1d39b
parent 46119 db5dddb38f5b
child 46121 c000eff2c635
errors: raise StateError when push fails because it creates new heads I decided to raise `StateError` here because the local and remote repos are in an incompatible state. I think remote errors (exit code 100) should be when something goes wrong on the remote and there's nothing the user can do. Differential Revision: https://phab.mercurial-scm.org/D9391
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
--- a/mercurial/discovery.py	Mon Nov 23 10:38:05 2020 -0800
+++ b/mercurial/discovery.py	Mon Nov 23 16:39:53 2020 -0800
@@ -362,7 +362,7 @@
 def checkheads(pushop):
     """Check that a push won't add any outgoing head
 
-    raise Abort error and display ui message as needed.
+    raise StateError error and display ui message as needed.
     """
 
     repo = pushop.repo.unfiltered()
@@ -409,7 +409,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.StateError(errmsg, hint=hint)
 
     # 2. Find heads that we need not warn about
     nowarnheads = _nowarnheads(pushop)
@@ -505,7 +505,7 @@
             for h in dhs:
                 repo.ui.note(b" %s\n" % short(h))
     if errormsg:
-        raise error.Abort(errormsg, hint=hint)
+        raise error.StateError(errormsg, hint=hint)
 
 
 def _postprocessobsolete(pushop, futurecommon, candidate_newhs):
--- a/tests/test-bookmarks-pushpull.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-bookmarks-pushpull.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
   $ 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]
+  [20]
   $ 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]
+  [20]
   $ cd ../addmarks
 
 Check summary output for incoming/outgoing bookmarks
--- a/tests/test-exchange-obsmarkers-case-A3.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-exchange-obsmarkers-case-A3.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
   $ cd ..
 
 test obsmarkers exchange.
--- a/tests/test-obsolete-checkheads.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-obsolete-checkheads.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
 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]
+  [20]
 
 
 
@@ -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]
+  [20]
 
 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]
+  [20]
--- a/tests/test-phases-exchange.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-phases-exchange.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
   $ hg push -fr 435b5d83910c ../mu # because the push will create new visible head
   pushing to ../mu
   searching for changes
--- a/tests/test-push-checkheads-multibranches-E3.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-multibranches-E3.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ cd ../..
--- a/tests/test-push-checkheads-partial-C1.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-partial-C1.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ cd ../..
--- a/tests/test-push-checkheads-partial-C2.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-partial-C2.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ cd ../..
--- a/tests/test-push-checkheads-partial-C3.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-partial-C3.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ cd ../..
--- a/tests/test-push-checkheads-partial-C4.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-partial-C4.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ cd ../..
--- a/tests/test-push-checkheads-unpushed-D1.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-unpushed-D1.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ cd ../..
 
--- a/tests/test-push-checkheads-unpushed-D2.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-unpushed-D2.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ cd ../..
--- a/tests/test-push-checkheads-unpushed-D3.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-unpushed-D3.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
   $ 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]
+  [20]
 
 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]
+  [20]
 
   $ cd ../..
--- a/tests/test-push-checkheads-unpushed-D4.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-unpushed-D4.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
 Actual testing (existing branch only)
 ------------------------------------
--- a/tests/test-push-checkheads-unpushed-D5.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-unpushed-D5.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
   $ hg push --rev 'desc(A1)'
   pushing to $TESTTMP/D5/server
   searching for changes
--- a/tests/test-push-checkheads-unpushed-D6.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-checkheads-unpushed-D6.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ cd ../..
--- a/tests/test-push-warn.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push-warn.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
 
 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
 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]
+  [20]
 
 
 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]
+  [20]
   $ 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]
+  [20]
   $ 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]
+  [20]
   $ 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]
+  [20]
 
 
 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]
+  [20]
 
 
 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
   $ 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]
+  [20]
 
 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]
+  [20]
 
 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]
+  [20]
 
   $ cd ..
--- a/tests/test-push.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-push.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
 (demonstrate that even though we don't have anything to exchange, we're still
 showing the error)
   $ hg push
--- a/tests/test-treediscovery-legacy.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-treediscovery-legacy.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
   $ hg push $remote --new-branch
   pushing to http://localhost:$HGPORT/
   searching for changes
--- a/tests/test-treediscovery.t	Mon Nov 23 10:38:05 2020 -0800
+++ b/tests/test-treediscovery.t	Mon Nov 23 16:39:53 2020 -0800
@@ -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]
+  [20]
   $ hg push $remote --new-branch
   pushing to http://localhost:$HGPORT/
   searching for changes