# HG changeset patch # User Valentin Gatien-Baron # Date 2020-04-14 23:09:56 # Node ID 16c361152133c1c7f6a9a39bd17dbb9bd12221f8 # Parent 5c2a4f37eacee93b3b13fa614ce717eac6a0238e graft: exit 1 on conflicts, like merge 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. Differential Revision: https://phab.mercurial-scm.org/D8423 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2951,7 +2951,7 @@ def graft(ui, repo, *revs, **opts): 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 @@ def _dograft(ui, repo, *revs, **opts): 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 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 @@ test the same case, this time with updat 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/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 @@ BROKEN: This should succeed and merge th 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 @@ BROKEN: This should succeed and merge th 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 @@ BROKEN: This should succeed and merge th 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 @@ BROKEN: This should succeed and merge th 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 @@ BROKEN: This should succeed and merge th 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 @@ BROKEN: This should succeed and merge th 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-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 @@ Testing the reading of old format grafts 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 @@ running `hg graft --continue` 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 @@ Test that --date is preserved and reused 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 @@ Test that --log is preserved and reused 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 @@ Testing the --stop flag of `hg graft` wh 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 @@ Testing the --stop flag of `hg graft` wh 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 @@ when stripping is required 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 @@ when stripping is not required 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 @@ when some of the changesets became publi 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 @@ when we created new changesets on top of 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 @@ Prepare wrdir to check --no-commit is re 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 @@ Check --no-commit is resepected when pas 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 @@ When there is conflict: 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-graft.t b/tests/test-graft.t --- a/tests/test-graft.t +++ b/tests/test-graft.t @@ -260,7 +260,7 @@ Graft out of order, skipping a merge and 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 @@ Graft again: 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 @@ Resolve conflicted graft 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 @@ Resolve conflicted graft with rename 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 @@ graft --continue after --force 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-issue1175.t b/tests/test-issue1175.t --- a/tests/test-issue1175.t +++ b/tests/test-issue1175.t @@ -74,7 +74,7 @@ https://bz.mercurial-scm.org/show_bug.cg 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