annotate: prepare ancestry context of workingfilectx stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 18 Apr 2015 15:27:03 +0900
branchstable
changeset 24818 8d7d0bf62f9f
parent 24817 0bb98eee531d
child 24819 22c70c08d4af
annotate: prepare ancestry context of workingfilectx _ancestrycontext is necessary for fast lookup of _changeid. Because we can't compute the ancestors from wctx, we skip to its parents. 'None' is not needed to be included in _ancestrycontext because it is used for a membership test of filelog revisions. repo: https://hg.mozilla.org/releases/mozilla-beta/#062e49bcb2da command: hg annotate -r 'wdir()' gfx/thebes/gfxWindowsPlatform.cpp before: 51.520 sec after: 1.780 sec
mercurial/context.py
--- a/mercurial/context.py	Sat Apr 18 14:10:55 2015 +0900
+++ b/mercurial/context.py	Sat Apr 18 15:27:03 2015 +0900
@@ -906,8 +906,15 @@
         introrev = self.introrev()
         if self.rev() != introrev:
             base = self.filectx(self.filenode(), changeid=introrev)
-        if introrev and getattr(base, '_ancestrycontext', None) is None:
-            ac = self._repo.changelog.ancestors([introrev], inclusive=True)
+        if getattr(base, '_ancestrycontext', None) is None:
+            cl = self._repo.changelog
+            if introrev is None:
+                # wctx is not inclusive, but works because _ancestrycontext
+                # is used to test filelog revisions
+                ac = cl.ancestors([p.rev() for p in base.parents()],
+                                  inclusive=True)
+            else:
+                ac = cl.ancestors([introrev], inclusive=True)
             base._ancestrycontext = ac
 
         # This algorithm would prefer to be recursive, but Python is a