Mercurial > hg
changeset 11935:927ada259634
revlog: optimize deltachain
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 15 Aug 2010 23:13:56 -0500 |
parents | cf858e76e992 |
children | 5b559934d504 |
files | mercurial/revlog.py |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Tue Aug 10 22:28:52 2010 +0530 +++ b/mercurial/revlog.py Sun Aug 15 23:13:56 2010 -0500 @@ -23,6 +23,8 @@ _decompress = zlib.decompress _sha = util.sha1 +_cached, _uncached = 0, 0 + # revlog header flags REVLOGV0 = 0 REVLOGNG = 1 @@ -1030,9 +1032,15 @@ """return chain of revisions to construct a given revision""" chain = [] check = False - while self.base(rev) != rev and rev != cache: + index = self.index + e = index[rev] + while rev != e[3] and rev != cache: chain.append(rev) - rev = self.deltaparent(rev) + if e[0] & REVIDX_PARENTDELTA: + rev = e[5] + else: + rev -= 1 + e = index[rev] chain.reverse() if rev == cache: check = True @@ -1068,7 +1076,13 @@ # do we have useful data cached? if cache and self._cache: + global _cached + _cached += 1 text = self._cache[2] + else: + global _uncached + _uncached += 1 + # drop cache to save memory self._cache = None