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.
--- 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))
--- 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):