D789: merge: add option to abort merge process on failure

2017-10-06 Thread ryanmce (Ryan McElroy)
ryanmce marked an inline comment as done.
ryanmce added inline comments.

INLINE COMMENTS

> markand wrote in configitems.py:302
> Please follow the naming style as defined in the UI Guidelines 
> . 
> Therefore it should be **abort-on-failure**.

Thanks! I didn't know about this new naming guideline. I definitely like it 
better than the old allthewordssmashedtogether guideline. Will update the 
current series.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: markand, mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-10-06 Thread markand (David Demelier)
markand added inline comments.

INLINE COMMENTS

> configitems.py:302
>  )
> +coreconfigitem('merge', 'abortonfailure',
> +default=False,

Please follow the naming style as defined in the UI Guidelines 
. Therefore 
it should be **abort-on-failure**.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: markand, mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-10-06 Thread ryanmce (Ryan McElroy)
ryanmce abandoned this revision.
ryanmce added a comment.


  Replaced by series ending at https://phab.mercurial-scm.org/D953

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce planned changes to this revision.
ryanmce added a comment.


  This doesn't actually lead to merge conflicts in the repo -- the error.Abort 
is "too strong". I need deeper surgery here.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce updated this revision to Diff 2333.
ryanmce added a comment.


  fix check-code -- whoops

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D789?vs=2332=2333

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/filemerge.py
  mercurial/help/config.txt
  tests/test-merge-tool-abort.t

CHANGE DETAILS

diff --git a/tests/test-merge-tool-abort.t b/tests/test-merge-tool-abort.t
new file mode 100644
--- /dev/null
+++ b/tests/test-merge-tool-abort.t
@@ -0,0 +1,70 @@
+  $ cat >> $HGRCPATH < [extensions]
+  > rebase=
+  > [phases]
+  > publish=False
+  > [merge]
+  > abortonfailure=True
+  > EOF
+
+  $ hg init repo
+  $ cd repo
+  $ echo a > a
+  $ echo b > b
+  $ hg commit -qAm ab
+  $ echo c >> a
+  $ echo c >> b
+  $ hg commit -qAm c
+  $ hg up -q ".^"
+  $ echo d >> a
+  $ echo d >> b
+  $ hg commit -qAm d
+
+Check that failing external tool aborts the merge
+  $ hg rebase -s 1 -d 2 --tool false
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+Check that successful tool with failed post-check aborts the merge
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=changed
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+   output file a appears unchanged
+  was merge successful (yn)? n
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=conflicts 
--config merge-tools.true.premerge=keep
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=prompt
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  was merge of 'a' successful (yn)? n
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+Check that successful tool otherwise allows the merge to continue
+  $ hg rebase -s 1 -d 2 --tool echo --keep --config 
merge-tools.echo.premerge=keep
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  $TESTTMP/repo/a *a~base* *a~other* (glob)
+  $TESTTMP/repo/b *b~base* *b~other* (glob)
+
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1239,6 +1239,14 @@
different contents. Similar to ``merge.checkignored``, except for files that
are not ignored. (default: ``abort``)
 
+``abortonfailure``
+   Traditionally, the merge process attempts to merge all unresolved files
+   using the merge tool of choice, regardless of whether previous file merge
+   attempts succeeded or failed. Setting the ``merge.abortonfailure`` option to
+   True changes this behavior so that a failed merge will immediately abort
+   the merge operation, leaving the user in a normal unresolved merge state.
+   (default: ``False``)
+
 ``merge-patterns``
 --
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -521,6 +521,14 @@
 util.unlink(b)
 util.unlink(c)
 
+def getmergeerrorhandler(repo):
+onerr = None
+if repo.ui.configbool('merge', 'abortonfailure'):
+def onerr(*args):
+msg = _('merge aborted due to nonzero mergetool return code')
+return error.Abort(msg)
+return onerr
+
 def _formatconflictmarker(repo, ctx, template, label, pad):
 """Applies the given template to the ctx, prefixed by the label.
 
@@ -713,6 +721,9 @@
 r = _check(repo, r, ui, tool, fcd, files)
 
 if r:
+if repo.ui.configbool('merge', 'abortonfailure'):
+msg = _('merge aborted due to merge tool failure')
+raise error.Abort(msg)
 if onfailure:
 ui.warn(onfailure % fd)
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -299,6 +299,9 @@
 coreconfigitem('merge', 'followcopies',
 default=True,
 )
+coreconfigitem('merge', 'abortonfailure',
+default=False,
+)
 coreconfigitem('pager', 'ignore',
 default=list,
 )



To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce updated this revision to Diff 2332.
ryanmce marked an inline comment as done.
ryanmce added a comment.


  Followed yuja's advice and moved the abort later.
  
  This has many advantages as shown in the updated test, which shows this abort
  also helps with merge tool post-checks, which are also tested.
  
  It also gives me ideas for the prompts that we can improve to allow this to
  be an option at runtime rather than only a config-time option as it is now.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D789?vs=2007=2332

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/filemerge.py
  mercurial/help/config.txt
  tests/test-merge-tool-abort.t

CHANGE DETAILS

diff --git a/tests/test-merge-tool-abort.t b/tests/test-merge-tool-abort.t
new file mode 100644
--- /dev/null
+++ b/tests/test-merge-tool-abort.t
@@ -0,0 +1,70 @@
+  $ cat >> $HGRCPATH < [extensions]
+  > rebase=
+  > [phases]
+  > publish=False
+  > [merge]
+  > abortonfailure=True
+  > EOF
+
+  $ hg init repo
+  $ cd repo
+  $ echo a > a
+  $ echo b > b
+  $ hg commit -qAm ab
+  $ echo c >> a
+  $ echo c >> b
+  $ hg commit -qAm c
+  $ hg up -q .^
+  $ echo d >> a
+  $ echo d >> b
+  $ hg commit -qAm d
+
+Check that failing external tool aborts the merge
+  $ hg rebase -s 1 -d 2 --tool false
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+Check that successful tool with failed post-check aborts the merge
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=changed
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+   output file a appears unchanged
+  was merge successful (yn)? n
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=conflicts 
--config merge-tools.true.premerge=keep
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+  $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=prompt
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  was merge of 'a' successful (yn)? n
+  abort: merge aborted due to merge tool failure
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+
+Check that successful tool otherwise allows the merge to continue
+  $ hg rebase -s 1 -d 2 --tool echo --keep --config 
merge-tools.echo.premerge=keep
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  $TESTTMP/repo/a *a~base* *a~other* (glob)
+  $TESTTMP/repo/b *b~base* *b~other* (glob)
+
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1239,6 +1239,14 @@
different contents. Similar to ``merge.checkignored``, except for files that
are not ignored. (default: ``abort``)
 
+``abortonfailure``
+   Traditionally, the merge process attempts to merge all unresolved files
+   using the merge tool of choice, regardless of whether previous file merge
+   attempts succeeded or failed. Setting the ``merge.abortonfailure`` option to
+   True changes this behavior so that a failed merge will immediately abort
+   the merge operation, leaving the user in a normal unresolved merge state.
+   (default: ``False``)
+
 ``merge-patterns``
 --
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -521,6 +521,14 @@
 util.unlink(b)
 util.unlink(c)
 
+def getmergeerrorhandler(repo):
+onerr = None
+if repo.ui.configbool('merge', 'abortonfailure'):
+def onerr(*args):
+msg = _('merge aborted due to nonzero mergetool return code')
+return error.Abort(msg)
+return onerr
+
 def _formatconflictmarker(repo, ctx, template, label, pad):
 """Applies the given template to the ctx, prefixed by the label.
 
@@ -713,6 +721,9 @@
 r = _check(repo, r, ui, tool, fcd, files)
 
 if r:
+if repo.ui.configbool('merge', 'abortonfailure'):
+msg = _('merge aborted due to merge tool failure')
+raise error.Abort(msg)
 if onfailure:
 ui.warn(onfailure % fd)
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -299,6 +299,9 @@
 coreconfigitem('merge', 'followcopies',
 default=True,
 )
+coreconfigitem('merge', 'abortonfailure',
+default=False,
+)
 coreconfigitem('pager', 'ignore',
 default=list,
 )



To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D789: merge: add option to abort merge process on failure

2017-10-02 Thread ryanmce (Ryan McElroy)
ryanmce marked 4 inline comments as done.
ryanmce added inline comments.

INLINE COMMENTS

> yuja wrote in filemerge.py:734
> Perhaps it's better to abort here, not in _xmerge().
> 
> Several merge tools do not return non-zero status on error, so
> we have extra _check() to detect merge error.

I looked through the code and you're right -- this is a better place. This also 
makes this change smaller overall. Thanks for the excellent suggestion!

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-26 Thread ryanmce (Ryan McElroy)
ryanmce added inline comments.

INLINE COMMENTS

> mbthomas wrote in filemerge.py:537
> Typo: `nonrzero`.

doh!

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-26 Thread mbthomas (Mark Thomas)
mbthomas requested changes to this revision.
mbthomas added inline comments.

INLINE COMMENTS

> filemerge.py:537
> +def onerr(*args):
> +msg = _('merge aborted due to nonrzero mergetool return code')
> +raise error.Abort(msg)

Typo: `nonrzero`.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja, mbthomas
Cc: mbthomas, yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-26 Thread ryanmce (Ryan McElroy)
ryanmce added a comment.


  Thanks for the feedback @yuja! I'll work on a second version.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja
Cc: yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-26 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  Can you rename or fold the test so we can do `./run-tests.py test-merge-*`?

INLINE COMMENTS

> filemerge.py:536
> +if repo.ui.configbool('merge', 'abortonfailure'):
> +def onerr(*args):
> +msg = _('merge aborted due to nonrzero mergetool return code')

Nit: onerr() is a function to return an exception object (e.g. an exception 
type), not a function to raise an exception.

> filemerge.py:734
>  if onfailure:
>  ui.warn(onfailure % fd)
>  

Perhaps it's better to abort here, not in _xmerge().

Several merge tools do not return non-zero status on error, so
we have extra _check() to detect merge error.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark, yuja
Cc: yuja, quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-22 Thread ryanmce (Ryan McElroy)
ryanmce marked an inline comment as done.
ryanmce added inline comments.

INLINE COMMENTS

> ryanmce wrote in test-filemerge-abort.t:22
> Or did you mean this? I guess here I can use `:fail`

Actually I can't because I need an external tool to fail here.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark
Cc: quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-22 Thread quark (Jun Wu)
quark accepted this revision.
quark added a comment.


  Answer myself - this is different and useful.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers, quark
Cc: quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-22 Thread ryanmce (Ryan McElroy)
ryanmce added inline comments.

INLINE COMMENTS

> test-filemerge-abort.t:22
> +  $ hg commit -qAm d
> +  $ hg rebase -s 1 -d 2 --tool false
> +  rebasing 1:1f28a51c3c9b "c"

Or did you mean this? I guess here I can use `:fail`

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers
Cc: quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-22 Thread ryanmce (Ryan McElroy)
ryanmce added a comment.


  No, it's an option that let's me `:cq` out of vim and stop additional windows 
from popping up, AFTER the merge process has already started.

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers
Cc: quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-22 Thread quark (Jun Wu)
quark added a comment.


  Is this the same as `--tool internal:fail`?

REPOSITORY
  rHG Mercurial

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

To: ryanmce, #hg-reviewers
Cc: quark, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D789: merge: add option to abort merge process on failure

2017-09-22 Thread ryanmce (Ryan McElroy)
ryanmce created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Traditionally, the merge process attempts to merge all unresolved files
  using the merge tool of choice, regardless of whether previous file merge
  attempts succeeded or failed. Setting the merge.abortonfailure option to
  True changes this behavior so that a failed merge will immediately abort
  the merge operation, leaving the user in a normal unresolved merge state.
  
  This is particularly useful when there may be many files to be merged and the
  user just wants to abort the process by exiting their editor with an error.

TEST PLAN
  Added a new test

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/filemerge.py
  mercurial/help/config.txt
  tests/test-filemerge-abort.t

CHANGE DETAILS

diff --git a/tests/test-filemerge-abort.t b/tests/test-filemerge-abort.t
new file mode 100644
--- /dev/null
+++ b/tests/test-filemerge-abort.t
@@ -0,0 +1,36 @@
+  $ cat >> $HGRCPATH < [extensions]
+  > rebase=
+  > [phases]
+  > publish=False
+  > [merge]
+  > abortonfailure=True
+  > EOF
+
+  $ hg init repo
+  $ cd repo
+  $ echo a > a
+  $ echo b > b
+  $ hg commit -qAm ab
+  $ echo c >> a
+  $ echo c >> b
+  $ hg commit -qAm c
+  $ hg up -q .^
+  $ echo d >> a
+  $ echo d >> b
+  $ hg commit -qAm d
+  $ hg rebase -s 1 -d 2 --tool false
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  abort: merge aborted due to nonrzero mergetool return code
+  [255]
+  $ hg rebase --abort
+  rebase aborted
+  $ hg rebase -s 1 -d 2 --tool true
+  rebasing 1:1f28a51c3c9b "c"
+  merging a
+  merging b
+  note: rebase of 1:1f28a51c3c9b created no changes to commit
+  saved backup bundle to 
$TESTTMP/repo/.hg/strip-backup/1f28a51c3c9b-5312ccf5-rebase.hg (glob)
+
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1239,6 +1239,14 @@
different contents. Similar to ``merge.checkignored``, except for files that
are not ignored. (default: ``abort``)
 
+``abortonfailure``
+   Traditionally, the merge process attempts to merge all unresolved files
+   using the merge tool of choice, regardless of whether previous file merge
+   attempts succeeded or failed. Setting the ``merge.abortonfailure`` option to
+   True changes this behavior so that a failed merge will immediately abort
+   the merge operation, leaving the user in a normal unresolved merge state.
+   (default: ``False``)
+
 ``merge-patterns``
 --
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -514,13 +514,30 @@
 repo.ui.status(_('running merge tool %s for file %s\n') %
(tool, fcd.path()))
 repo.ui.debug('launching merge tool: %s\n' % cmd)
-r = ui.system(cmd, cwd=repo.root, environ=env, blockedtag='mergetool')
+onerr = getmergeerrorhandler(repo)
+r = ui.system(cmd, cwd=repo.root, environ=env, blockedtag='mergetool',
+  onerr=onerr)
 repo.ui.debug('merge tool returned: %s\n' % r)
 return True, r, False
 finally:
 util.unlink(b)
 util.unlink(c)
 
+def getmergeerrorhandler(repo):
+"""
+Traditionally, the merge process attempts to merge all unresolved files
+using the merge tool of choice, regardless of whether previous file merge
+attempts succeeded or failed. Setting the merge.abortonfailure option to
+True changes this behavior so that a failed merge will immediately abort
+the merge operation, leaving the user in a normal unresolved merge state.
+"""
+onerr = None
+if repo.ui.configbool('merge', 'abortonfailure'):
+def onerr(*args):
+msg = _('merge aborted due to nonrzero mergetool return code')
+raise error.Abort(msg)
+return onerr
+
 def _formatconflictmarker(repo, ctx, template, label, pad):
 """Applies the given template to the ctx, prefixed by the label.
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -296,6 +296,9 @@
 coreconfigitem('merge', 'followcopies',
 default=True,
 )
+coreconfigitem('merge', 'abortonfailure',
+default=False,
+)
 coreconfigitem('pager', 'ignore',
 default=list,
 )



To: ryanmce, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel