# HG changeset patch # User Valentin Gatien-Baron # Date 1586905796 14400 # 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 -r 5c2a4f37eace -r 16c361152133 mercurial/commands.py --- a/mercurial/commands.py Fri Apr 10 19:58:34 2020 +0200 +++ b/mercurial/commands.py Tue Apr 14 19:09:56 2020 -0400 @@ -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 diff -r 5c2a4f37eace -r 16c361152133 tests/test-bisect.t --- a/tests/test-bisect.t Fri Apr 10 19:58:34 2020 +0200 +++ b/tests/test-bisect.t Tue Apr 14 19:09:56 2020 -0400 @@ -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 -r 5c2a4f37eace -r 16c361152133 tests/test-copies-unrelated.t --- a/tests/test-copies-unrelated.t Fri Apr 10 19:58:34 2020 +0200 +++ b/tests/test-copies-unrelated.t Tue Apr 14 19:09:56 2020 -0400 @@ -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 -r 5c2a4f37eace -r 16c361152133 tests/test-graft-interrupted.t --- a/tests/test-graft-interrupted.t Fri Apr 10 19:58:34 2020 +0200 +++ b/tests/test-graft-interrupted.t Tue Apr 14 19:09:56 2020 -0400 @@ -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 -r 5c2a4f37eace -r 16c361152133 tests/test-graft.t --- a/tests/test-graft.t Fri Apr 10 19:58:34 2020 +0200 +++ b/tests/test-graft.t Tue Apr 14 19:09:56 2020 -0400 @@ -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 -r 5c2a4f37eace -r 16c361152133 tests/test-issue1175.t --- a/tests/test-issue1175.t Fri Apr 10 19:58:34 2020 +0200 +++ b/tests/test-issue1175.t Tue Apr 14 19:09:56 2020 -0400 @@ -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