[PATCH] revset: changed revsets to use spanset

Matt Mackall mpm at selenic.com
Tue Feb 18 13:33:12 CST 2014


On Tue, 2014-02-18 at 09:33 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz at fb.com>
> # Date 1391451315 28800
> #      Mon Feb 03 10:15:15 2014 -0800
> # Node ID 1062b23968e304d61dc4ff958e7c34633f187544
> # Parent  84f626df10a5df208b211d3ad907562034d33c1e
> revset: changed revsets to use spanset
> 
> Performance Benchmarking:
> 
> $ hg perfrevset "first(all())"
> ! wall 0.304936 comb 0.300000 user 0.280000 sys 0.020000 (best of 33)
> 
> $ ./hg perfrevset "first(all())"
> ! wall 0.175640 comb 0.180000 user 0.160000 sys 0.020000 (best of 56)
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2558,7 +2558,8 @@
>          if newtree != tree:
>              ui.note(revset.prettyformat(newtree), "\n")
>      func = revset.match(ui, expr)
> -    for c in func(repo, revset.baseset(range(len(repo)))):
> +    for c in func(repo, revset.spanset(0, len(repo),
> +        repo.changelog.filteredrevs)):

Ok, I'm noticing something I didn't see in your earlier patch. It'd be
better if spansets took a repo object:

 spanset(repo, start, end)

..and looked up the hidden revs internally. This way less code has to be
explicitly aware of hidden revs. Then we can get lazy and add some
default args like:

 spanset(repo, start=0, end=None)

so that we can just do:

 spanset(repo) # 0:len(repo) implied

..because we do that a bunch. And this ends up only slightly more
verbose than our old list(repo) version.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list