Mercurial > hg
changeset 27130:6f045b563fa5
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.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 30 Nov 2015 10:03:21 -0800 |
parents | 1bf1a7c3df43 |
children | d837da26155e |
files | mercurial/merge.py |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Mon Nov 30 10:05:09 2015 -0800 +++ b/mercurial/merge.py Mon Nov 30 10:03:21 2015 -0800 @@ -103,8 +103,9 @@ 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 @@ 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() @@ -287,6 +289,12 @@ 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: raise RuntimeError("localctx accessed but self._local isn't set")