changeset 23603:d74eb8d477d5

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).
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 19 Dec 2014 00:11:56 +0900
parents a4679a74df14
children bb304f9b05d0
files mercurial/context.py
diffstat 1 files changed, 2 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Thu Dec 18 16:41:59 2014 -0600
+++ b/mercurial/context.py	Fri Dec 19 00:11:56 2014 +0900
@@ -1633,10 +1633,9 @@
 
         # 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 @@
                 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)