# HG changeset patch # User Sean Farley # Date 1406334961 18000 # Node ID 443ef664fb557b850e8ad21d647c992dd8f6f855 # Parent f8fc5df6a8cf5b7dbd64d3a3fb0e810081125ac5 memctx: create a filectxfn if it is not callable This will allow future patches to construct a memctx based on another context or any other store-type object. diff -r f8fc5df6a8cf -r 443ef664fb55 mercurial/context.py --- a/mercurial/context.py Thu Aug 07 11:39:19 2014 -0400 +++ b/mercurial/context.py Fri Jul 25 19:36:01 2014 -0500 @@ -1596,6 +1596,20 @@ self._filectxfn = filectxfn self.substate = {} + # if store is not callable, wrap it in a function + if not callable(filectxfn): + def getfilectx(repo, memctx, path): + fctx = filectxfn[path] + # this is weird but apparently we only keep track of one parent + # (why not only store that instead of a tuple?) + copied = fctx.renamed() + if copied: + copied = copied[0] + return memfilectx(repo, path, fctx.data(), + islink=fctx.islink(), isexec=fctx.isexec(), + copied=copied, memctx=memctx) + self._filectxfn = getfilectx + self._extra = extra and extra.copy() or {} if self._extra.get('branch', '') == '': self._extra['branch'] = 'default'