Mercurial > hg
changeset 44215:b1069b369d6e
mergestate: add accessors for local and other nodeid, not just contexts
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.
Differential Revision: https://phab.mercurial-scm.org/D8040
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 29 Jan 2020 11:30:16 -0800 |
parents | 3d2de64c49d2 |
children | 281b6690e646 |
files | mercurial/merge.py |
diffstat | 1 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Wed Jan 15 22:24:16 2020 -0800 +++ b/mercurial/merge.py Wed Jan 29 11:30:16 2020 -0800 @@ -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.