obsolete: speed up computation of bumped revset
Speed up the computation of the bumped revset by using the not public() revset.
In another patch series, we optimized the not public() revset. Together,
this cuts the cost of the computation of bumped() from 17% of the total time of
smartlog on our big repo to under 0.1% of the total time.
--- a/mercurial/obsolete.py Thu Mar 19 13:15:20 2015 -0700
+++ b/mercurial/obsolete.py Fri Apr 24 14:46:30 2015 -0700
@@ -1139,19 +1139,18 @@
public = phases.public
cl = repo.changelog
torev = cl.nodemap.get
- obs = getrevs(repo, 'obsolete')
- for rev in repo:
+ for ctx in repo.set('(not public()) and (not obsolete())'):
+ rev = ctx.rev()
# We only evaluate mutable, non-obsolete revision
- if (public < phase(repo, rev)) and (rev not in obs):
- node = cl.node(rev)
- # (future) A cache of precursors may worth if split is very common
- for pnode in allprecursors(repo.obsstore, [node],
- ignoreflags=bumpedfix):
- prev = torev(pnode) # unfiltered! but so is phasecache
- if (prev is not None) and (phase(repo, prev) <= public):
- # we have a public precursors
- bumped.add(rev)
- break # Next draft!
+ node = ctx.node()
+ # (future) A cache of precursors may worth if split is very common
+ for pnode in allprecursors(repo.obsstore, [node],
+ ignoreflags=bumpedfix):
+ prev = torev(pnode) # unfiltered! but so is phasecache
+ if (prev is not None) and (phase(repo, prev) <= public):
+ # we have a public precursors
+ bumped.add(rev)
+ break # Next draft!
return bumped
@cachefor('divergent')