Patchwork D932: filemerge: introduce functions to halt merge flow

login
register
mail settings
Submitter phabricator
Date Oct. 17, 2017, 1:47 a.m.
Message ID <72bb96de70709efec266afcd56c63a7a@localhost.localdomain>
Download mbox | patch
Permalink /patch/25063/
State Not Applicable
Headers show

Comments

phabricator - Oct. 17, 2017, 1:47 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa1625035db16: filemerge: introduce functions to halt merge flow (authored by ryanmce, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D932?vs=2501&id=2876#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D932?vs=2501&id=2876

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/filemerge.py
  mercurial/help/config.txt

CHANGE DETAILS




To: ryanmce, #hg-reviewers, krbullock, mbthomas, durin42
Cc: durin42, krbullock, pulkit, mercurial-devel

Patch

diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -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``
 ------------------
 
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -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
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -531,6 +531,9 @@ 
 coreconfigitem('merge', 'followcopies',
     default=True,
 )
+coreconfigitem('merge', 'on-failure',
+    default='continue',
+)
 coreconfigitem('merge', 'preferancestor',
         default=lambda: ['*'],
 )