Patchwork [4,of,4,STABLE] annotate: prepare ancestry context of workingfilectx

login
register
mail settings
Submitter Yuya Nishihara
Date April 18, 2015, 11:28 a.m.
Message ID <e5a525ce04a0ea81adb2.1429356494@mimosa>
Download mbox | patch
Permalink /patch/8738/
State Accepted
Headers show

Comments

Yuya Nishihara - April 18, 2015, 11:28 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1429338423 -32400
#      Sat Apr 18 15:27:03 2015 +0900
# Branch stable
# Node ID e5a525ce04a0ea81adb253479e7ec023a00248d9
# Parent  5551511c8a017481b16c0cdbc4b2deb3d7b01d28
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
Matt Mackall - April 19, 2015, 6:54 p.m.
On Sat, 2015-04-18 at 20:28 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1429338423 -32400
> #      Sat Apr 18 15:27:03 2015 +0900
> # Branch stable
> # Node ID e5a525ce04a0ea81adb253479e7ec023a00248d9
> # Parent  5551511c8a017481b16c0cdbc4b2deb3d7b01d28
> 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

Queued for stable, thanks. In the future, please try to avoid
refactoring on stable.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -906,8 +906,15 @@  class basefilectx(object):
         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