This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-25 at 14:00 UTC+2 (a few minutes of down time)

Commit 5bbba7bd authored by Siddharth Agarwal's avatar Siddharth Agarwal
Browse files

mergestate: add a cached property accessor for the local context

This is going to be useful in an upcoming patch. We make this a public accessor
because this is also going to be useful for custom merge drivers.
parent 1bf1a7c3df43
......@@ -103,8 +103,9 @@ class mergestate(object):
self._state = {}
self._local = None
self._other = None
if 'otherctx' in vars(self):
del self.otherctx
for var in ('localctx', 'otherctx'):
if var in vars(self):
delattr(self, var)
if node:
self._local = node
self._other = other
......@@ -126,8 +127,9 @@ class mergestate(object):
self._state = {}
self._local = None
self._other = None
if 'otherctx' in vars(self):
del self.otherctx
for var in ('localctx', 'otherctx'):
if var in vars(self):
delattr(self, var)
self._readmergedriver = None
self._mdstate = 's'
unsupported = set()
......@@ -286,6 +288,12 @@ class mergestate(object):
return configmergedriver
@util.propertycache
def localctx(self):
if self._local is None:
raise RuntimeError("localctx accessed but self._local isn't set")
return self._repo[self._local]
@util.propertycache
def otherctx(self):
if self._other is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment