[PATCH 2 of 3] revlog: calculate base revisions iteratively

Benoit Boissinot bboissin at gmail.com
Thu May 5 07:21:48 CDT 2011


On Thu, May 5, 2011 at 1:18 PM, Sune Foldager <cryo at cyanite.org> wrote:
> # HG changeset patch
> # User Sune Foldager <cryo at cyanite.org>
> # Date 1304593827 -7200
> # Node ID 9c8d70e38372c2a67519d7e2804977803a81eaf1
> # Parent  35473c8ce1e85917561a64f6621b1024d85aa97c
> revlog: calculate base revisions iteratively
>
> This is in preparation for generaldelta, where the revlog entry base field
> is reinterpreted as the deltaparent.
>
> Performance is virtually unchanged, as there can be at most two iterations.
>
> diff -r 35473c8ce1e8 -r 9c8d70e38372 mercurial/revlog.py
> --- a/mercurial/revlog.py       Thu May 05 12:26:03 2011 +0200
> +++ b/mercurial/revlog.py       Thu May 05 13:10:27 2011 +0200
> @@ -320,7 +320,12 @@
>     def length(self, rev):
>         return self.index[rev][1]
>     def base(self, rev):
> -        return self.index[rev][3]
> +        index = self.index
> +        e = index[rev]
> +        while e[3] != rev:
> +            rev = e[3]
> +            e = index[rev]
> +        return rev

What do you think of renaming that to "chainbase" or something? It
used to just be a way to access the field from the index, but if it's
no longer the case, we probably need to reflect that.

Benoit


More information about the Mercurial-devel mailing list