Patchwork D8423: graft: exit 1 on conflicts, like merge

login
register
mail settings
Submitter phabricator
Date April 14, 2020, 11:30 p.m.
Message ID <differential-rev-PHID-DREV-lluhmo4epapj2vby4ha5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46117/
State Superseded
Headers show

Comments

phabricator - April 14, 2020, 11:30 p.m.
valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It's more consistent, and makes it nicer to script around hg if you
  don't have to ignore exit code 255, which is the error code for
  basically everything in hg.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-bisect.t
  tests/test-copies-unrelated.t
  tests/test-graft-interrupted.t
  tests/test-graft.t
  tests/test-issue1175.t

CHANGE DETAILS




To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-issue1175.t b/tests/test-issue1175.t
--- a/tests/test-issue1175.t
+++ b/tests/test-issue1175.t
@@ -74,7 +74,7 @@ 
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
   $ echo a > b
   $ echo b3 >> b
   $ hg resolve --mark b
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -260,7 +260,7 @@ 
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Summary should mention graft:
 
@@ -317,7 +317,7 @@ 
   warning: conflicts while merging e! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Continue without resolve should fail:
 
@@ -511,7 +511,7 @@ 
   grafting 1:5d205f8b35b6 "1"
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
   $ hg resolve --all
   merging a
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
@@ -551,7 +551,7 @@ 
   grafting 2:5c095ad7e90f "2"
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
   $ hg resolve --all
   merging a and b to b
   (no more unresolved files)
@@ -839,7 +839,7 @@ 
   grafting 24:2e7ea477be26 "24"
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
   $ hg resolve --all
   merging a
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
diff --git a/tests/test-graft-interrupted.t b/tests/test-graft-interrupted.t
--- a/tests/test-graft-interrupted.t
+++ b/tests/test-graft-interrupted.t
@@ -32,7 +32,7 @@ 
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Writing the nodes in old format to graftstate
 
@@ -91,7 +91,7 @@ 
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ echo wat > b
   $ hg resolve -m
@@ -141,7 +141,7 @@ 
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ echo foobar > b
   $ hg resolve -m
@@ -180,7 +180,7 @@ 
   warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ echo foobar > b
   $ hg resolve -m
@@ -246,7 +246,7 @@ 
   warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ hg graft --stop --continue
   abort: cannot use '--continue' and '--stop' together
@@ -283,7 +283,7 @@ 
   warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ hg graft --stop
   stopped the interrupted graft
@@ -352,7 +352,7 @@ 
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ hg graft --continue --abort
   abort: cannot use '--continue' and '--abort' together
@@ -399,7 +399,7 @@ 
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ hg abort
   graft aborted
@@ -426,7 +426,7 @@ 
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ hg log -GT "{rev}:{node|short} {desc}"
   @  6:6ec71c037d94 added x
@@ -488,7 +488,7 @@ 
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ cd ..
   $ hg init pullrepo
@@ -609,7 +609,7 @@ 
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Resolve conflict:
   $ echo A>a
@@ -648,7 +648,7 @@ 
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Resolve conflict:
   $ echo A>a
@@ -688,7 +688,7 @@ 
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
   $ echo A>a
   $ hg resolve --mark
diff --git a/tests/test-copies-unrelated.t b/tests/test-copies-unrelated.t
--- a/tests/test-copies-unrelated.t
+++ b/tests/test-copies-unrelated.t
@@ -109,7 +109,7 @@ 
   What do you want to do? u
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Add x, remove it, then add it back, then rename x to y. Similar to the case
 above, but here the break in history is before the rename.
@@ -193,7 +193,7 @@ 
   What do you want to do? u
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 #endif
   $ hg co -qC 2
 BROKEN: This should succeed and merge the changes from x into y
@@ -204,7 +204,7 @@ 
   What do you want to do? u
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Add x, remove it, then add it back, rename x to y from the first commit.
 Similar to the case above, but here the break in history is parallel to the
@@ -278,7 +278,7 @@ 
   What do you want to do? u
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Add x on two branches, then rename x to y on one side. Similar to the case
 above, but here the break in history is via the base commit.
@@ -361,7 +361,7 @@ 
   What do you want to do? u
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 #endif
   $ hg co -qC 2
 BROKEN: This should succeed and merge the changes from x into y
@@ -372,7 +372,7 @@ 
   What do you want to do? u
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
 
 Copies via null revision (there shouldn't be any)
   $ newrepo
diff --git a/tests/test-bisect.t b/tests/test-bisect.t
--- a/tests/test-bisect.t
+++ b/tests/test-bisect.t
@@ -564,7 +564,7 @@ 
   warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
-  [255]
+  [1]
   $ hg bisect --reset
   $ hg up -C .
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2951,7 +2951,7 @@ 
 
     See :hg:`help revisions` for more about specifying revisions.
 
-    Returns 0 on successful completion.
+    Returns 0 on successful completion, 1 if there are unresolved files.
     '''
     with repo.wlock():
         return _dograft(ui, repo, *revs, **opts)
@@ -3212,10 +3212,9 @@ 
                 statedata[b'nodes'] = nodes
                 stateversion = 1
                 graftstate.save(stateversion, statedata)
-                hint = _(b"use 'hg resolve' and 'hg graft --continue'")
-                raise error.Abort(
-                    _(b"unresolved conflicts, can't continue"), hint=hint
-                )
+                ui.error(_(b"abort: unresolved conflicts, can't continue\n"))
+                ui.error(_(b"(use 'hg resolve' and 'hg graft --continue')\n"))
+                return 1
         else:
             cont = False