changeset 35329:d901a88891fe

rebase: rerun a rebase on-disk if IMM merge conflicts arise Differential Revision: https://phab.mercurial-scm.org/D1249
author Phil Cohen <phillco@fb.com>
date Fri, 08 Dec 2017 12:14:38 -0800
parents 228916ca12b5
children 2e1c32a9c97b
files hgext/rebase.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Thu Dec 07 22:35:43 2017 -0800
+++ b/hgext/rebase.py	Fri Dec 08 12:14:38 2017 -0800
@@ -759,6 +759,25 @@
     unresolved conflicts.
 
     """
+    if opts.get('continue') or opts.get('abort'):
+        # in-memory rebase is not compatible with resuming rebases.
+        opts['inmemory'] = False
+
+    if opts.get('inmemory', False):
+        try:
+            # in-memory merge doesn't support conflicts, so if we hit any, abort
+            # and re-run as an on-disk merge.
+            return _origrebase(ui, repo, **opts)
+        except error.InMemoryMergeConflictsError:
+            ui.warn(_('hit merge conflicts; re-running rebase without in-memory'
+                      ' merge\n'))
+            _origrebase(ui, repo, **{'abort': True})
+            opts['inmemory'] = False
+            return _origrebase(ui, repo, **opts)
+    else:
+        return _origrebase(ui, repo, **opts)
+
+def _origrebase(ui, repo, **opts):
     opts = pycompat.byteskwargs(opts)
     if 'inmemory' not in opts:
         opts['inmemory'] = False