# HG changeset patch # User Sean Farley # Date 1401397979 18000 # Node ID b342c3e2518aefa7c5999030fba72ddc4a6c627b # Parent e4d35aa9056c7844e25834256eeab79c9a325545 memctx: add _manifest implementation that computes the filenode This is an initial implementation of having a manifest for memctx that computes the hash in the same way that filenodes are computed elsewhere. diff -r e4d35aa9056c -r b342c3e2518a mercurial/context.py --- a/mercurial/context.py Tue Apr 29 16:43:59 2014 -0500 +++ b/mercurial/context.py Thu May 29 16:12:59 2014 -0500 @@ -13,6 +13,7 @@ import obsolete as obsmod import repoview import fileset +import revlog propertycache = util.propertycache @@ -1587,6 +1588,27 @@ """commit context to the repo""" return self._repo.commitctx(self) + @propertycache + def _manifest(self): + """generate a manifest based on the return values of filectxfn""" + + # keep this simple for now; just worry about p1 + pctx = self._parents[0] + man = pctx.manifest().copy() + + for f, fnode in man.iteritems(): + p1node = nullid + p2node = nullid + p = pctx[f].parents() + if len(p) > 0: + p1node = p[0].node() + if len(p) > 1: + p2node = p[1].node() + man[f] = revlog.hash(self[f].data(), p1node, p2node) + + return man + + class memfilectx(committablefilectx): """memfilectx represents an in-memory file to commit.