# HG changeset patch # User Pierre-Yves David # Date 1490155761 -3600 # Node ID dd8ed58bf79c7018e8962e94718fe30680a155e4 # Parent 086a85c37e9ea97f9b7a580af90b3f436ca25002 stablerange: move the subrangesclosure inside the module This seems more suitable and open the way to simple update of how we build things without too much impact outside the module. The debug command is still in the 'obsdiscovery' module because it also deal to obshash and I'm not sure of were this should live yet. diff -r 086a85c37e9e -r dd8ed58bf79c hgext3rd/evolve/obsdiscovery.py --- a/hgext3rd/evolve/obsdiscovery.py Sun Mar 19 05:33:52 2017 +0100 +++ b/hgext3rd/evolve/obsdiscovery.py Wed Mar 22 05:09:21 2017 +0100 @@ -393,16 +393,7 @@ revs = scmutil.revrange(repo, opts['rev']) # prewarm depth cache repo.stablerange.warmup(repo, revs) - toproceed = [stablerange.stablerange(repo, r, 0, ) for r in revs] - ranges = set(toproceed) - while toproceed: - entry = toproceed.pop() - for r in entry.subranges(): - if r not in ranges: - ranges.add(r) - toproceed.append(r) - ranges = list(ranges) - ranges.sort(key=lambda r: (-len(r), r.node)) + ranges = stablerange.subrangesclosure(repo, revs) ui.status('rev node index size depth obshash\n') for r in ranges: d = (r.head, s(r.node), r.index, len(r), r.depth, node.short(r.obshash)) diff -r 086a85c37e9e -r dd8ed58bf79c hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Sun Mar 19 05:33:52 2017 +0100 +++ b/hgext3rd/evolve/stablerange.py Wed Mar 22 05:09:21 2017 +0100 @@ -132,6 +132,23 @@ ### Stable Range computation ### ################################# +def subrangesclosure(repo, heads): + """set of all standard subrange under heads + + This is intended for debug purposes. Range are returned from largest to + smallest in terms of number of revision it contains.""" + toproceed = [stablerange(repo, r, 0, ) for r in heads] + ranges = set(toproceed) + while toproceed: + entry = toproceed.pop() + for r in entry.subranges(): + if r not in ranges: + ranges.add(r) + toproceed.append(r) + ranges = list(ranges) + ranges.sort(key=lambda r: (-len(r), r.node)) + return ranges + class stablerangecache(dict): def __init__(self):