Patchwork [1,of,2,STABLE,V2] annotate: reuse already calculated annotation

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 29, 2013, 2:28 p.m.
Message ID <ab31364ceb7b1841e252.1364567324@feefifofum>
Download mbox | patch
Permalink /patch/1216/
State Accepted
Commit a54ddfae8907b43c9802b8fbebb85fe3604bb869
Headers show

Comments

Katsunori FUJIWARA - March 29, 2013, 2:28 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1364565435 -32400
# Branch stable
# Node ID ab31364ceb7b1841e25246bbedcf6501a43ef6ee
# Parent  43dfb6fce6a76168766f3b73f4c991ab811590ec
annotate: reuse already calculated annotation

Before this patch, annotation is re-calculated even if it is already
calculated. This may cause unexpected annotation, because already
cleared "pcache" ("pcache[f] = []") prevents from scanning ancestors.

This patch reuses already calculated annotation if it is available.

In fact, "reusable" situation should be seen only on legacy
repositories in which a filelog include the merging between the
revision and its ancestor, because:

  - tree is scanned in depth-first

    without such merging, annotation result should be released soon

  - recent Mercurial doesn't allow such merging

    changelog and manifest can include such merging someway, but
    filelogs can't, because "localrepository._filecommit()" converts
    such merging request to linear history.

Patch

diff -r 43dfb6fce6a7 -r ab31364ceb7b mercurial/context.py
--- a/mercurial/context.py	Fri Mar 01 11:54:36 2013 -0300
+++ b/mercurial/context.py	Fri Mar 29 22:57:15 2013 +0900
@@ -710,9 +710,14 @@ 
                     needed[p] = needed.get(p, 0) + 1
             if ready:
                 visit.pop()
-                curr = decorate(f.data(), f)
+                reusable = f in hist
+                if reusable:
+                    curr = hist[f]
+                else:
+                    curr = decorate(f.data(), f)
                 for p in pl:
-                    curr = pair(hist[p], curr)
+                    if not reusable:
+                        curr = pair(hist[p], curr)
                     if needed[p] == 1:
                         del hist[p]
                     else: