changeset 34796:ed91846c29cf

filemerge: introduce functions to halt merge flow Depends on D931. This patch introduces functions and a config option that will allow a user to halt the merge if there are failures during a file merge. These functions will be used in the next patch. Differential Revision: https://phab.mercurial-scm.org/D932
author Ryan McElroy <rmcelroy@fb.com>
date Fri, 06 Oct 2017 06:48:43 -0700
parents 530b7361e3a9
children 284fa44f7f39
files mercurial/configitems.py mercurial/filemerge.py mercurial/help/config.txt
diffstat 3 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Sun Oct 15 19:29:56 2017 +0530
+++ b/mercurial/configitems.py	Fri Oct 06 06:48:43 2017 -0700
@@ -531,6 +531,9 @@
 coreconfigitem('merge', 'followcopies',
     default=True,
 )
+coreconfigitem('merge', 'on-failure',
+    default='continue',
+)
 coreconfigitem('merge', 'preferancestor',
         default=lambda: ['*'],
 )
--- a/mercurial/filemerge.py	Sun Oct 15 19:29:56 2017 +0530
+++ b/mercurial/filemerge.py	Fri Oct 06 06:48:43 2017 -0700
@@ -745,6 +745,20 @@
         if not r and back is not None:
             back.remove()
 
+def _haltmerge():
+    msg = _('merge halted after failed merge (see hg resolve)')
+    raise error.InterventionRequired(msg)
+
+def _onfilemergefailure(ui):
+    action = ui.config('merge', 'on-failure')
+    if action == 'prompt':
+        msg = _('continue merge operation (yn)?' '$$ &Yes $$ &No')
+        if ui.promptchoice(msg, 0) == 1:
+            _haltmerge()
+    if action == 'halt':
+        _haltmerge()
+    # default action is 'continue', in which case we neither prompt nor halt
+
 def _check(repo, r, ui, tool, fcd, files):
     fd = fcd.path()
     unused, unused, unused, back = files
--- a/mercurial/help/config.txt	Sun Oct 15 19:29:56 2017 +0530
+++ b/mercurial/help/config.txt	Fri Oct 06 06:48:43 2017 -0700
@@ -1288,6 +1288,17 @@
    different contents. Similar to ``merge.checkignored``, except for files that
    are not ignored. (default: ``abort``)
 
+``on-failure``
+   When set to ``continue`` (the default), the merge process attempts to
+   merge all unresolved files using the merge chosen tool, regardless of
+   whether previous file merge attempts during the process succeeded or not.
+   Setting this to ``prompt`` will prompt after any merge failure continue
+   or halt the merge process. Setting this to ``halt`` will automatically
+   halt the merge process on any merge tool failure. The merge process
+   can be restarted by using the ``resolve`` command. When a merge is
+   halted, the repository is left in a normal ``unresolved`` merge state.
+   (default: ``continue``)
+
 ``merge-patterns``
 ------------------