graphlog: pass changesets to revset.match() in changelog order
Running:
$ time hg debugrevspec 'user(mpm)' | wc
on Mercurial repository takes 1.0s with a regular version and 1.8s if
commands.debugrevspec() is patched to pass revisions to revset.match() from tip
to 0.
Depending on what we expect from the revset API and caller wisdom, we might
want to push this change in revset.match() later.
--- a/hgext/graphlog.py Wed Apr 11 11:07:30 2012 +0200
+++ b/hgext/graphlog.py Wed Apr 11 11:14:07 2012 +0200
@@ -409,7 +409,11 @@
return [], None, None
expr, filematcher = _makelogrevset(repo, pats, opts, revs)
if expr:
- revs = revsetmod.match(repo.ui, expr)(repo, revs)
+ # Evaluate revisions in changelog order for performance
+ # reasons but preserve the original sequence order in the
+ # filtered result.
+ matched = set(revsetmod.match(repo.ui, expr)(repo, sorted(revs)))
+ revs = [r for r in revs if r in matched]
return revs, expr, filematcher
def generate(ui, dag, displayer, showparents, edgefn, getrenamed=None,