[PATCH 06 of 14] revlog: introduce flag for punched revisions

Nicolas Dumazet nicdumz at gmail.com
Fri Jul 16 02:59:02 CDT 2010


On Fri, 16 Jul 2010 12:45:14 +0530
Vishakh H <vsh426 at gmail.com> wrote:

> # HG changeset patch
> # User Vishakh H <vsh426 at gmail.com>
> # Date 1279263210 -19800
> # Node ID 693696b7c08aa5f2f011e5ef1871107447bc9582
> # Parent  25f876f3a1a882eda81e01651bc229c46a838af9
> revlog: introduce flag for punched revisions
> 
> REVLOG_PUNCHED_FLAG = 2, is used to mark a revision as punched.
> REVLOG_KNOWN_FLAGS is the accumulation of all known revision flags.
> 
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -30,6 +30,8 @@
>  REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA
>  REVLOG_DEFAULT_FORMAT = REVLOGNG
>  REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
> +REVLOG_PUNCHED_FLAG = 2
> +REVLOG_KNOWN_FLAGS = REVLOG_PUNCHED_FLAG
>  
>  # amount of data read unconditionally, should be >= 4
>  # when not inline: threshold for using lazy index
> @@ -1025,9 +1027,9 @@
>          base = self.base(rev)
>  
>          # check rev flags
> -        if self.flags(rev):
> +        if self.flags(rev, ~REVLOG_KNOWN_FLAGS):
>              raise RevlogError(_('incompatible revision flag %x') %
> -                              self.flags(rev))
> +                              self.flags(rev, ~REVLOG_KNOWN_FLAGS))
>  

This chunk seems good to me.

>          # do we have useful data cached?
>          if self._cache and self._cache[1] >= base and self._cache[1] < rev:
> @@ -1042,7 +1044,8 @@
>          bins = [self._chunk(r) for r in xrange(base + 1, rev + 1)]
>          text = mdiff.patches(text, bins)
>          p1, p2 = self.parents(node)
> -        if node != hash(text, p1, p2):
> +        if (node != hash(text, p1, p2) and
> +            not self.flags(rev, REVLOG_PUNCHED_FLAG)):
>              raise RevlogError(_("integrity check failed on %s:%d")
>                                % (self.indexfile, rev))

REVLOG_PUNCHED_FLAG, or REVLOG_KNOWN_FLAGS ?
If you're checking for integrity, dont you want to include all possible flags?

>  
> @@ -1128,7 +1131,8 @@
>  
>          # full versions are inserted when the needed deltas
>          # become comparable to the uncompressed text
> -        if not curr or dist > len(text) * 2:
> +        if (not curr or dist > len(text) * 2 or
> +            self.flags(base, REVLOG_PUNCHED_FLAG)):

is it a punch-specific branch? Again, I'd expect REVLOG_KNOWN_FLAGS here. (But that might be because you're not telling us enough in the commit message?)

-Nicolas

>              data = compress(text)
>              l = len(data[1]) + len(data[0])
>              base = curr
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Nicolas Dumazet — NicDumZ


More information about the Mercurial-devel mailing list