stablerange: reuse node calculation as much as possible
We have a property cache with that value, so we just reuse it.
--- a/hgext3rd/evolve/obsdiscovery.py Sat Mar 11 12:21:22 2017 -0800
+++ b/hgext3rd/evolve/obsdiscovery.py Sun Mar 12 08:38:39 2017 -0700
@@ -314,11 +314,10 @@
def _queryrange(ui, repo, remote, allentries):
mapping = {}
- n = repo.changelog.node
def gen():
for entry in allentries:
- key = n(entry.head) + _pack('>I', entry.index)
+ key = entry.node + _pack('>I', entry.index)
mapping[key] = entry
yield key
@@ -482,7 +481,6 @@
def debugstablerange(ui, repo, **opts):
"""display the ::REVS set topologically sorted in a stable way
"""
- n = repo.changelog.node
s = node.short
revs = scmutil.revrange(repo, opts['rev'])
# prewarm depth cache
@@ -497,10 +495,10 @@
ranges.add(r)
toproceed.append(r)
ranges = list(ranges)
- ranges.sort(key=lambda r: (-len(r), n(r.head)))
+ ranges.sort(key=lambda r: (-len(r), r.node))
ui.status('rev node index size depth obshash\n')
for r in ranges:
- d = (r.head, s(n(r.head)), r.index, len(r), r.depth, node.short(r.obshash))
+ d = (r.head, s(r.node), r.index, len(r), r.depth, node.short(r.obshash))
ui.status('%3d %s %5d %4d %5d %s\n' % d)
def _hlp2(i):
@@ -605,15 +603,13 @@
@util.propertycache
def obshash(self):
cache = self._repo.obsstore.rangeobshashcache
- cl = self._repo.changelog
- n = cl.node
obshash = cache.get(self._id)
if obshash is not None:
return obshash
sha = hashlib.sha1()
count = 0
if len(self) == 1:
- tmarkers = self._repo.obsstore.relevantmarkers([n(self.head)])
+ tmarkers = self._repo.obsstore.relevantmarkers([self.node])
bmarkers = []
for m in tmarkers:
mbin = obsolete._fm1encodeonemarker(m)