Mercurial > hg
changeset 11962:5f7ee3db3dd8
revlog._addrevision(): make the parent of the cached delta explicit
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 18 Aug 2010 19:45:52 +0200 |
parents | f3075ffa6b30 |
children | 7c3aa579d98a |
files | mercurial/manifest.py mercurial/revlog.py |
diffstat | 2 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/manifest.py Thu Aug 19 13:25:46 2010 +0200 +++ b/mercurial/manifest.py Wed Aug 18 19:45:52 2010 +0200 @@ -188,11 +188,7 @@ if dstart != None: delta.append([dstart, dend, "".join(dline)]) # apply the delta to the addlist, and get a delta for addrevision - cachedelta = addlistdelta(addlist, delta) - - # the delta is only valid if we've been processing the tip revision - if p1 != self.tip(): - cachedelta = None + cachedelta = (self.rev(p1), addlistdelta(addlist, delta)) arraytext = addlist text = buffer(arraytext)
--- a/mercurial/revlog.py Thu Aug 19 13:25:46 2010 +0200 +++ b/mercurial/revlog.py Wed Aug 18 19:45:52 2010 +0200 @@ -1142,7 +1142,7 @@ tr.replace(self.indexfile, trindex * self._io.size) self._chunkclear() - def addrevision(self, text, transaction, link, p1, p2, d=None): + def addrevision(self, text, transaction, link, p1, p2, cachedelta=None): """add a revision to the log text - the revision data to add @@ -1156,13 +1156,15 @@ dfh = self.opener(self.datafile, "a") ifh = self.opener(self.indexfile, "a+") try: - return self._addrevision(text, transaction, link, p1, p2, d, ifh, dfh) + return self._addrevision(text, transaction, link, p1, p2, + cachedelta, ifh, dfh) finally: if dfh: dfh.close() ifh.close() - def _addrevision(self, text, transaction, link, p1, p2, d, ifh, dfh): + def _addrevision(self, text, transaction, link, p1, p2, + cachedelta, ifh, dfh): node = hash(text, p1, p2) if node in self.nodemap: return node @@ -1172,8 +1174,14 @@ base = self.base(prev) offset = self.end(prev) flags = 0 + d = None if curr: + # can we use the cached delta? + if cachedelta: + cacherev, d = cachedelta + if cacherev != prev: + d = None if not d: if self._parentdelta: ptext = self.revision(p1)