# HG changeset patch # User Benoit Boissinot # Date 2010-08-18 17:45:52 # Node ID 5f7ee3db3dd8f0d84dbde385c299286ff32d06aa # Parent f3075ffa6b30dcca549b8f5ada5570e44e8ee5f2 revlog._addrevision(): make the parent of the cached delta explicit diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -188,11 +188,7 @@ class manifest(revlog.revlog): 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) diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1142,7 +1142,7 @@ class revlog(object): 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 @@ class revlog(object): 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 @@ class revlog(object): 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)