# HG changeset patch # User Pierre-Yves David # Date 1490204105 -3600 # Node ID cc8ae2a66b0ff83ea23a60c3a252569412862c2b # Parent e2dc8c4897be0d53ee82e85f8e50521290a19a84 stablerange: use rangelength in findmissingrange We stop using the building '__len__' this get use closer to be able to use a tuple. diff -r e2dc8c4897be -r cc8ae2a66b0f hgext3rd/evolve/obsdiscovery.py --- a/hgext3rd/evolve/obsdiscovery.py Wed Mar 22 17:59:21 2017 +0100 +++ b/hgext3rd/evolve/obsdiscovery.py Wed Mar 22 18:35:05 2017 +0100 @@ -241,6 +241,7 @@ heads = local.revs('heads(%ld)', probeset) + rangelength = local.stablerange.rangelength # size of slice ? heappop = heapq.heappop heappush = heapq.heappush @@ -280,8 +281,8 @@ sliceme = [] heapify(sliceme) for entry in sample: - if 1 < len(entry): - heappush(sliceme, (-len(entry), entry)) + if 1 < rangelength(local, entry): + heappush(sliceme, (-rangelength(local, entry), entry)) while sliceme and 0 < needed: _key, target = heappop(sliceme) @@ -289,7 +290,7 @@ # XXX we could record hierarchy to optimise drop if addentry(entry): if 1 < len(entry): - heappush(sliceme, (-len(entry), entry)) + heappush(sliceme, (-rangelength(local, entry), entry)) needed -= 1 if needed <= 0: break @@ -298,7 +299,7 @@ samplesize = fullsamplesize nbsample = len(sample) - maxsize = max([len(r) for r in sample]) + maxsize = max([rangelength(local, r) for r in sample]) ui.debug("query %i; sample size is %i, largest range %i\n" % (querycount, maxsize, nbsample)) nbreplies = 0 @@ -309,7 +310,7 @@ nbreplies += 1 if remotehash == _obshashrange(local, entry): continue - elif 1 == len(entry): + elif 1 == rangelength(local, entry): missing.add(n(entry[0])) else: for new in entry.subranges():