Patchwork D8551: context: implement mergestate() method

login
register
mail settings
Submitter phabricator
Date May 18, 2020, 10:08 p.m.
Message ID <differential-rev-PHID-DREV-k7lyfnthygcrv5bhi45p-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46341/
State Superseded
Headers show

Comments

phabricator - May 18, 2020, 10:08 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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