[PATCH] generaldelta: initialize basecache properly

Durham Goode durham at fb.com
Fri Sep 20 18:16:20 CDT 2013


On 9/20/13 12:31 PM, "Wojciech Lopata" <lopek at fb.com> wrote:

># HG changeset patch
># User Wojciech Lopata <lopek at fb.com>
># Date 1379699151 25200
>#      Fri Sep 20 10:45:51 2013 -0700
># Node ID e3bf4ac814f13279287e28742f816856bba178ff
># Parent  1c62f9487e46a467aace39316459a5be57c55e8a
>generaldelta: initialize basecache properly
>
>Previously basecache was incorrectly inicialized before add of first
>revision

Šinitialized before adding the first revisionŠ

>from a changegroup. Basecache value infuences when full revisions are
>stored

influences

>in revlog (when using generaldelta). As a result it was possible to
>generate
>a generaldelta-revlog that could be bigger by arbitrary factor than its
>non-generaldelta equivalent.
>
>diff --git a/mercurial/revlog.py b/mercurial/revlog.py
>--- a/mercurial/revlog.py
>+++ b/mercurial/revlog.py
>@@ -200,7 +200,7 @@
>         self.datafile = indexfile[:-2] + ".d"
>         self.opener = opener
>         self._cache = None
>-        self._basecache = (0, 0)
>+        self._basecache = None
>         self._chunkcache = (0, '')
>         self.index = []
>         self._pcache = {}
>@@ -1131,6 +1131,8 @@
>         offset = self.end(prev)
>         flags = 0
>         d = None
>+        if self._basecache is None:
>+            self._basecache = (prev, self.chainbase(prev))
>         basecache = self._basecache
>         p1r, p2r = self.rev(p1), self.rev(p2)

It's a bit hard to understand the implications of this change without
knowing the general delta code in detail. Is it possible to write a test
so we can see the improvement and to prevent regressions?



More information about the Mercurial-devel mailing list