Patchwork D8040: mergestate: add accessors for local and other nodeid, not just contexts

login
register
mail settings
Submitter phabricator
Date Jan. 30, 2020, 12:57 a.m.
Message ID <differential-rev-PHID-DREV-2bkpqjjzertyrtxbvrql-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44759/
State Superseded
Headers show

Comments

phabricator - Jan. 30, 2020, 12:57 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The mergestate can contain invalid nodeids. In that case,
  `mergestate.localctx` or `mergestate.otherctx` will fail. This patch
  provides a way of accessing the nodeid without failing in such cases.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -386,18 +386,26 @@ 
         return configmergedriver
 
     @util.propertycache
-    def localctx(self):
+    def local(self):
         if self._local is None:
-            msg = b"localctx accessed but self._local isn't set"
+            msg = b"local accessed but self._local isn't set"
             raise error.ProgrammingError(msg)
-        return self._repo[self._local]
+        return self._local
+
+    @util.propertycache
+    def localctx(self):
+        return self._repo[self.local]
+
+    @util.propertycache
+    def other(self):
+        if self._other is None:
+            msg = b"other accessed but self._other isn't set"
+            raise error.ProgrammingError(msg)
+        return self._other
 
     @util.propertycache
     def otherctx(self):
-        if self._other is None:
-            msg = b"otherctx accessed but self._other isn't set"
-            raise error.ProgrammingError(msg)
-        return self._repo[self._other]
+        return self._repo[self.other]
 
     def active(self):
         """Whether mergestate is active.