comparison mercurial/context.py @ 32069:a457da5296a5 stable

context: optimize linkrev adjustment in blockancestors() (issue5538) We set parent._descendantrev = child.rev() when walking parents in blockancestors() so that, when linkrev adjustment is perform for these, it starts from a close descendant instead of possibly topmost introrev. (See `self._adjustlinkrev(self._descendantrev)` in filectx._changeid().) This is similar to changeset c82d88dfaf59, which added a "f._changeid" instruction in annotate() for the same purpose. However, here, we set _descendantrev explicitly instead of relying on the '_changeid' cached property being accessed (with effect to set _changeid attribute) so that, in _parentfilectx() (called from parents()), we go through `if '_changeid' in vars(self) [...]` branch in which instruction `fctx._descendantrev = self.rev()` finally appears and does what we want. With this, we can roughly get a 3x speedup (including in example of issue5538 from mozilla-central repository) on usage of followlines revset (and equivalent hgweb request).
author Denis Laxalde <denis.laxalde@logilab.fr>
date Mon, 24 Apr 2017 18:33:23 +0200
parents befefdd34cf8
children 2cfdf5241096 c850f0ed54c1
comparison
equal deleted inserted replaced
32068:51fdedd29b0a 32069:a457da5296a5
1212 if linerange1[0] == linerange1[1]: 1212 if linerange1[0] == linerange1[1]:
1213 # Parent's linerange is empty, meaning that the block got 1213 # Parent's linerange is empty, meaning that the block got
1214 # introduced in this revision; no need to go futher in this 1214 # introduced in this revision; no need to go futher in this
1215 # branch. 1215 # branch.
1216 continue 1216 continue
1217 # Set _descendantrev with 'c' (a known descendant) so that, when
1218 # _adjustlinkrev is called for 'p', it receives this descendant
1219 # (as srcrev) instead possibly topmost introrev.
1220 p._descendantrev = c.rev()
1217 visit[p.linkrev(), p.filenode()] = p, linerange1 1221 visit[p.linkrev(), p.filenode()] = p, linerange1
1218 if inrange: 1222 if inrange:
1219 yield c, linerange2 1223 yield c, linerange2
1220 1224
1221 def blockdescendants(fctx, fromline, toline): 1225 def blockdescendants(fctx, fromline, toline):