Patchwork [13,of,21,V2] speedy: add hook to walkchangerevs to allow for slow path acceleration

login
register
mail settings
Submitter Tomasz Kleczek
Date Dec. 14, 2012, 2:52 a.m.
Message ID <45188f6b0235c8840e29.1355453545@dev408.prn1.facebook.com>
Download mbox | patch
Permalink /patch/95/
State Deferred, archived
Headers show

Comments

Tomasz Kleczek - Dec. 14, 2012, 2:52 a.m.
# HG changeset patch
# User Tomasz Kleczek <tkleczek at fb.com>
# Date 1355249698 28800
# Node ID 45188f6b0235c8840e2931c7ae3ec9939bcb172d
# Parent  3942126384a54278f65ac9ec9412dc3e4f46ed51
speedy: add hook to walkchangerevs to allow for slow path acceleration

This hook is used by speedy extension to forward the directory queries
to the history server which allows for a big performance improvements
on big repos.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1001,8 +1001,29 @@ 
 def filterrevsopts(repo, revs, opts):
     return revs
 
+def filterrevs(repo, revs, match):
+    """Return information about revisions modifying matching files.
+
+    Returns a pair of (wanted, fncache) where `wanted` is a set of
+    matching revisions and `fncache` is a dict such that if
+    `rev` is in fncache then fncache[rev] is a list of matching
+    filenames this rev modifies.
+
+    It is slow as it checks every file in every changeset against `match`.
+    """
+    fncache = {}
+    wanted = set()
+    for i in sorted(revs):
+        ctx = repo.changectx(i)
+        matches = filter(match, ctx.files())
+        if matches:
+            fncache[i] = matches
+            wanted.add(i)
+    return wanted, fncache
+
 walkchangerevshooks = {
     'filterrevsopts': filterrevsopts,
+    'filterrevs': filterrevs,
 }
 
 def walkchangerevs(repo, match, opts, prepare):
@@ -1157,13 +1178,7 @@ 
             raise util.Abort(_('can only follow copies/renames for explicit '
                                'filenames'))
 
-        # The slow path checks files modified in every changeset.
-        for i in sorted(revs):
-            ctx = change(i)
-            matches = filter(match, ctx.files())
-            if matches:
-                fncache[i] = matches
-                wanted.add(i)
+        wanted, fncache = walkchangerevshooks['filterrevs'](repo, revs, match)
 
     class followfilter(object):
         def __init__(self, onlyfirst=False):