stablerange: directly use tuple to refer to a stable range
Now that all advance logic lives in the unified class we no longer needs the
individual class. Creating and operating on this cache introduce a significant
overhead that we can not stop having.
From now on, a range a is pair tuple '(headrev, index)'. Long live the tuple.
--- a/hgext3rd/evolve/obsdiscovery.py Wed Mar 22 21:28:18 2017 +0100
+++ b/hgext3rd/evolve/obsdiscovery.py Wed Mar 22 21:08:58 2017 +0100
@@ -261,7 +261,7 @@
return True
for h in heads:
- entry = stablerange.stablerange(local, h, 0)
+ entry = (h, 0)
addentry(entry)
querycount = 0
@@ -366,7 +366,7 @@
n = data[:20]
index = _unpack('>I', data[20:])[0]
r = op.repo.changelog.rev(n)
- rhash = _obshashrange(op.repo, stablerange.stablerange(op.repo, r, index))
+ rhash = _obshashrange(op.repo, (r, index))
replies.append(data + rhash)
data = inpart.read(24)
op.reply.newpart('reply:_donotusemeever_evoext_obshashrange_1', data=iter(replies))
--- a/hgext3rd/evolve/stablerange.py Wed Mar 22 21:28:18 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py Wed Mar 22 21:08:58 2017 +0100
@@ -136,7 +136,7 @@
This is intended for debug purposes. Range are returned from largest to
smallest in terms of number of revision it contains."""
subranges = repo.stablerange.subranges
- toproceed = [stablerange(repo, r, 0, ) for r in heads]
+ toproceed = [(r, 0, ) for r in heads]
ranges = set(toproceed)
while toproceed:
entry = toproceed.pop()
@@ -318,14 +318,14 @@
rangedepth = self.depthrev(repo, rangeid[0])
topsize = rangedepth - globalindex
- parentrange = stablerange(repo, p1, rangeid[1])
+ parentrange = (p1, rangeid[1])
# if we have an entry for the current range, lets update the cache
if rangeid in self._revsinrangecache:
parentrevs = self._revsinrangecache[rangeid][:-1]
self._revsinrangecache[parentrange] = parentrevs
if topsize == 1:
- top = stablerange(repo, rangeid[0], globalindex)
+ top = (rangeid[0], globalindex)
return [parentrange, top]
else:
# XXX recursive call, python have issue with them
@@ -336,7 +336,7 @@
# wait for that heavy object to be gone.
parentsubranges = self.subranges(repo, parentrange)
slices = parentsubranges[:-1] # pop the top
- top = stablerange(repo, rangeid[0], globalindex)
+ top = (rangeid[0], globalindex)
# if we have an entry for the current range, lets update the cache
if rangeid in self._revsinrangecache:
parentrevs = self._revsinrangecache[rangeid][-topsize:]
@@ -352,7 +352,7 @@
allrevs = self.revsfromrange(repo, rangeid)
toprevs = allrevs[localindex:]
bottomrevs = allrevs[:localindex]
- top = stablerange(repo, rangeid[0], globalindex)
+ top = (rangeid[0], globalindex)
self._revsinrangecache[top] = toprevs # update cache
#
rangedepth = self.depthrev(repo, rangeid[0])
@@ -371,7 +371,7 @@
newhead = bottomrevs[-1]
bottomdepth = self.depthrev(repo, newhead)
newstart = bottomdepth - len(bottomrevs)
- bottom = stablerange(repo, newhead, newstart)
+ bottom = (newhead, newstart)
self._revsinrangecache[bottom] = bottomrevs # update cache
result.append(bottom)
else:
@@ -381,7 +381,7 @@
subset = cl.ancestors([h], inclusive=True)
hrevs = [r for r in bottomrevs if r in subset]
start = self.depthrev(repo, h) - len(hrevs)
- entry = stablerange(repo, h, start)
+ entry = (h, start)
entryrevs = [r for r in bottomrevs if r in subset]
self._revsinrangecache[entry] = entryrevs # update cache
result.append(entry)