changeset 44916:e607099d8b93

context: implement mergestate() method This will let us have the mergestate storage be controlled by the context. In particular, for working contexts we should use the existing mergestate, but for overlay contexts it's inappropriate to drop files in .hg/merge. Differential Revision: https://phab.mercurial-scm.org/D8551
author Augie Fackler <augie@google.com>
date Mon, 18 May 2020 16:00:26 -0400
parents b7808443ed6a
children 5d8ae9248a70
files mercurial/context.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Mon May 18 14:59:59 2020 -0400
+++ b/mercurial/context.py	Mon May 18 16:00:26 2020 -0400
@@ -34,6 +34,7 @@
     error,
     fileset,
     match as matchmod,
+    mergestate as mergestatemod,
     obsolete as obsmod,
     patch,
     pathutil,
@@ -474,6 +475,12 @@
 
         return r
 
+    def mergestate(self, clean=False):
+        """Get a mergestate object for this context."""
+        raise NotImplementedError(
+            '%s does not implement mergestate()' % self.__class__
+        )
+
 
 class changectx(basectx):
     """A changecontext object makes access to data related to a particular
@@ -2003,6 +2010,11 @@
 
         sparse.aftercommit(self._repo, node)
 
+    def mergestate(self, clean=False):
+        if clean:
+            return mergestatemod.mergestate.clean(self._repo)
+        return mergestatemod.mergestate.read(self._repo)
+
 
 class committablefilectx(basefilectx):
     """A committablefilectx provides common functionality for a file context