# HG changeset patch # User FUJIWARA Katsunori # Date 2014-12-18 15:11:56 # Node ID d74eb8d477d5b87fd7771560f978f4e1dad68db6 # Parent a4679a74df144213aa2e6b6d86cf6d02eb193c10 memctx: calculate manifest more efficiently Before this patch, "memctx._manifest" updates all entries in the (parent) manifest. But this is inefficiency, because almost all files may be clean in that context. On the other hand, just updating entries for changed "files" specified at construction causes unexpected abortion, when there is at least one newly removed file (see issue4470 for detail). To calculate manifest more efficiently, this patch replaces "pman.iteritems()" for the loop by "self._status.modified" to avoid updating entries for clean or removed files Examination of removal is also omitted, because removed files aren't treated in this loop (= "self[f]" returns not None always). diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1633,10 +1633,9 @@ class memctx(committablectx): # keep this simple for now; just worry about p1 pctx = self._parents[0] - pman = pctx.manifest() man = pctx.manifest().copy() - for f, fnode in pman.iteritems(): + for f in self._status.modified: p1node = nullid p2node = nullid p = pctx[f].parents() # if file isn't in pctx, check p2? @@ -1644,12 +1643,7 @@ class memctx(committablectx): p1node = p[0].node() if len(p) > 1: p2node = p[1].node() - fctx = self[f] - if fctx is None: - # removed file - del man[f] - else: - man[f] = revlog.hash(fctx.data(), p1node, p2node) + man[f] = revlog.hash(self[f].data(), p1node, p2node) for f in self._status.added: man[f] = revlog.hash(self[f].data(), nullid, nullid)