[PATCH 2 of 5 mergedriver] merge.mergestate: introduce a way to conclude all paused merges

Siddharth Agarwal sid0 at fb.com
Fri Oct 9 18:10:21 CDT 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1444428399 25200
#      Fri Oct 09 15:06:39 2015 -0700
# Node ID 1f8c79286f7b6008c755dc809d12b07eee9f0a6e
# Parent  ef1c9fd840c5e750e83cf65873ac8217a5119ab1
merge.mergestate: introduce a way to conclude all paused merges

As a previous patch noted, we're going to restructure our merge process to
perform all premerges before doing any merges. We need a way to store and
finished off any paused merges. This function provides that.

This function is currently inactive but will do useful things in upcoming
patches.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -78,6 +78,7 @@ class mergestate(object):
             self._other = other
         shutil.rmtree(self._repo.join('merge'), True)
         self._dirty = False
+        self._pausedmerges = []
 
     def _read(self):
         """Analyse each record content to restore a serialized state from disk
@@ -101,6 +102,7 @@ class mergestate(object):
                 raise util.Abort(_('unsupported merge state record: %s')
                                    % rtype)
         self._dirty = False
+        self._pausedmerges = []
 
     def _readrecords(self):
         """Read merge state from disk and return a list of record (TYPE, data)
@@ -323,6 +325,22 @@ class mergestate(object):
             self.mark(dfile, 'r')
         return r
 
+    def concludemerges(self):
+        """complete all paused merges"""
+        results = {}
+        for dfile, mergectx in self._pausedmerges:
+            r = mergectx.merge()
+            if r is None:
+                # no real conflict
+                del self._state[dfile]
+                self._dirty = True
+            elif not r:
+                self.mark(dfile, 'r')
+            results[dfile] = r
+
+        self._pausedmerges = []
+        return results
+
 def _checkunknownfile(repo, wctx, mctx, f, f2=None):
     if f2 is None:
         f2 = f


More information about the Mercurial-devel mailing list