Mercurial > public > mercurial-scm > hg
diff mercurial/context.py @ 35400:8a0cac20a1ad
memfilectx: make changectx argument mandatory in constructor (API)
committablefilectx has three subclasses: workingfilectx, memfilectx,
and overlayfilectx. committablefilectx takes an optional (change) ctx
instance to its constructor. If it's provided, it's set on the
instance as self._changectx. If not, that property is supposed to be
defined by the class. However, only workingfilectx does that. The
other two will have the property undefined if it's not passed in the
constructor. That seems bad to me. This patch makes the changectx
argument to the memfilectx constructor mandatory because that fixes
the failure I ran into. It seems like we should also fix the
overlayfilectx case.
Differential Revision: https://phab.mercurial-scm.org/D1658
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 11 Dec 2017 09:27:40 -0800 |
parents | 8384553b1684 |
children | 265cd9e19d26 |
line wrap: on
line diff
--- a/mercurial/context.py Sat Dec 09 14:22:12 2017 -0800 +++ b/mercurial/context.py Mon Dec 11 09:27:40 2017 -0800 @@ -2204,12 +2204,11 @@ files = self._cache.keys() def getfile(repo, memctx, path): if self._cache[path]['exists']: - return memfilectx(repo, path, + return memfilectx(repo, memctx, path, self._cache[path]['data'], 'l' in self._cache[path]['flags'], 'x' in self._cache[path]['flags'], - self._cache[path]['copied'], - memctx) + self._cache[path]['copied']) else: # Returning None, but including the path in `files`, is # necessary for memctx to register a deletion. @@ -2389,9 +2388,9 @@ copied = fctx.renamed() if copied: copied = copied[0] - return memfilectx(repo, path, fctx.data(), + return memfilectx(repo, memctx, path, fctx.data(), islink=fctx.islink(), isexec=fctx.isexec(), - copied=copied, memctx=memctx) + copied=copied) return getfilectx @@ -2405,9 +2404,8 @@ if data is None: return None islink, isexec = mode - return memfilectx(repo, path, data, islink=islink, - isexec=isexec, copied=copied, - memctx=memctx) + return memfilectx(repo, memctx, path, data, islink=islink, + isexec=isexec, copied=copied) return getfilectx @@ -2539,8 +2537,8 @@ See memctx and committablefilectx for more details. """ - def __init__(self, repo, path, data, islink=False, - isexec=False, copied=None, memctx=None): + def __init__(self, repo, changectx, path, data, islink=False, + isexec=False, copied=None): """ path is the normalized file path relative to repository root. data is the file content as a string. @@ -2548,7 +2546,7 @@ isexec is True if the file is executable. copied is the source file path if current file was copied in the revision being committed, or None.""" - super(memfilectx, self).__init__(repo, path, None, memctx) + super(memfilectx, self).__init__(repo, path, None, changectx) self._data = data self._flags = (islink and 'l' or '') + (isexec and 'x' or '') self._copied = None