Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 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 | 11a160547d7f |
comparison
equal
deleted
inserted
replaced
23602:a4679a74df14 | 23603:d74eb8d477d5 |
---|---|
1631 def _manifest(self): | 1631 def _manifest(self): |
1632 """generate a manifest based on the return values of filectxfn""" | 1632 """generate a manifest based on the return values of filectxfn""" |
1633 | 1633 |
1634 # keep this simple for now; just worry about p1 | 1634 # keep this simple for now; just worry about p1 |
1635 pctx = self._parents[0] | 1635 pctx = self._parents[0] |
1636 pman = pctx.manifest() | |
1637 man = pctx.manifest().copy() | 1636 man = pctx.manifest().copy() |
1638 | 1637 |
1639 for f, fnode in pman.iteritems(): | 1638 for f in self._status.modified: |
1640 p1node = nullid | 1639 p1node = nullid |
1641 p2node = nullid | 1640 p2node = nullid |
1642 p = pctx[f].parents() # if file isn't in pctx, check p2? | 1641 p = pctx[f].parents() # if file isn't in pctx, check p2? |
1643 if len(p) > 0: | 1642 if len(p) > 0: |
1644 p1node = p[0].node() | 1643 p1node = p[0].node() |
1645 if len(p) > 1: | 1644 if len(p) > 1: |
1646 p2node = p[1].node() | 1645 p2node = p[1].node() |
1647 fctx = self[f] | 1646 man[f] = revlog.hash(self[f].data(), p1node, p2node) |
1648 if fctx is None: | |
1649 # removed file | |
1650 del man[f] | |
1651 else: | |
1652 man[f] = revlog.hash(fctx.data(), p1node, p2node) | |
1653 | 1647 |
1654 for f in self._status.added: | 1648 for f in self._status.added: |
1655 man[f] = revlog.hash(self[f].data(), nullid, nullid) | 1649 man[f] = revlog.hash(self[f].data(), nullid, nullid) |
1656 | 1650 |
1657 for f in self._status.removed: | 1651 for f in self._status.removed: |