[PATCH 13 of 21 V2] speedy: add hook to walkchangerevs to allow for slow path acceleration
Tomasz Kleczek
tkleczek at fb.com
Thu Dec 13 20:52:25 CST 2012
# 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.
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):
More information about the Mercurial-devel
mailing list