ryanmce created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Depends on https://phab.mercurial-scm.org/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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

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,17 @@
    different contents. Similar to ``merge.checkignored``, except for files that
    are not ignored. (default: ``abort``)
 
+``onfailure``
+   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
+   half 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
@@ -721,6 +721,21 @@
         if not r and back is not None:
             util.unlink(back)
 
+def _haltmerge():
+    msg = _('merge halted after failed merge (see hg resolve)')
+    raise error.InterventionRequired(msg)
+
+def _onfilemergefailure(ui):
+    action = ui.config('merge', 'onfailure')
+    if action == 'continue':
+        return
+    if action == 'prompt':
+        msg = _('continue merge operation (yn)?' '$$ &Yes $$ &No')
+        if ui.promptchoice(msg, 0) == 1:
+            _haltmerge()
+    if action == 'halt':
+        _haltmerge()
+
 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
@@ -299,6 +299,9 @@
 coreconfigitem('merge', 'followcopies',
     default=True,
 )
+coreconfigitem('merge', 'onfailure',
+    default='continue',
+)
 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

Reply via email to