[PATCH STABLE] annotate: reuse ancestry context when adjusting linkrev (issue4532)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Mar 20 03:16:15 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1426819943 25200
#      Thu Mar 19 19:52:23 2015 -0700
# Branch stable
# Node ID d0ecf62a37d0ab1c2f737a164c5d0b50af6fbb31
# Parent  6136704b975df292819647ba8ac46209487fbc46
annotate: reuse ancestry context when adjusting linkrev (issue4532)

The linkrev adjustment will likely do the same ancestry walking multiple time
so we already have an optional mechanism to take advantage of this. Since
2896f53509a7, linkrev adjustment was done lazily to prevent too bad performance
impact on rename computation. However, this laziness created a quadratic
situation in 'annotate'.

Mercurial repo: hg annotate mercurial/commands.py
before:   8.090
after:  36.300

Mozilla repo: hg annotate layout/generic/nsTextFrame.cpp
before:   1.190
after:  290.230


So we setup sharing of the ancestry context in the annotate case too. Linkrev
adjustment still have an impact but it a much more sensible one.

Mercurial repo: hg annotate mercurial/commands.py
before:  36.300
after:   10.230

Mozilla repo: hg annotate layout/generic/nsTextFrame.cpp
before: 290.230
after:    5.560

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -911,10 +911,12 @@ class basefilectx(object):
         # use linkrev to find the first changeset where self appeared
         base = self
         introrev = self.introrev()
         if self.rev() != introrev:
             base = self.filectx(self.filenode(), changeid=introrev)
+            ac = self._repo.changelog.ancestors([introrev], inclusive=True)
+            base._ancestrycontext = ac
 
         # This algorithm would prefer to be recursive, but Python is a
         # bit recursion-hostile. Instead we do an iterative
         # depth-first search.
 


More information about the Mercurial-devel mailing list