comparison mercurial/obsolete.py @ 24928:876a2ebfbf4f

obsolete: speed up unstable computation Speed up the computation of the unstable revset by using the not public() revset. In another series of patches, we optimize the not public() revset and together it leads to a 50-100x speedup on the computation of unstable() for our big repos.
author Laurent Charignon <lcharignon@fb.com>
date Tue, 28 Apr 2015 16:51:23 -0700
parents cd0068232ec0
children e632a2429982
comparison
equal deleted inserted replaced
24927:cd0068232ec0 24928:876a2ebfbf4f
1108 return obs 1108 return obs
1109 1109
1110 @cachefor('unstable') 1110 @cachefor('unstable')
1111 def _computeunstableset(repo): 1111 def _computeunstableset(repo):
1112 """the set of non obsolete revisions with obsolete parents""" 1112 """the set of non obsolete revisions with obsolete parents"""
1113 # revset is not efficient enough here 1113 revs = [(ctx.rev(), ctx) for ctx in
1114 # we do (obsolete()::) - obsolete() by hand 1114 repo.set('(not public()) and (not obsolete())')]
1115 obs = getrevs(repo, 'obsolete') 1115 revs.sort(key=lambda x:x[0])
1116 if not obs: 1116 unstable = set()
1117 return set() 1117 for rev, ctx in revs:
1118 cl = repo.changelog 1118 # A rev is unstable if one of its parent is obsolete or unstable
1119 return set(r for r in cl.descendants(obs) if r not in obs) 1119 # this works since we traverse following growing rev order
1120 if util.any((x.obsolete() or (x.rev() in unstable))
1121 for x in ctx.parents()):
1122 unstable.add(rev)
1123 return unstable
1120 1124
1121 @cachefor('suspended') 1125 @cachefor('suspended')
1122 def _computesuspendedset(repo): 1126 def _computesuspendedset(repo):
1123 """the set of obsolete parents with non obsolete descendants""" 1127 """the set of obsolete parents with non obsolete descendants"""
1124 suspended = repo.changelog.ancestors(getrevs(repo, 'unstable')) 1128 suspended = repo.changelog.ancestors(getrevs(repo, 'unstable'))