[PATCH 05 of 14] revlog: add a flags method that returns revision flags

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


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

> # HG changeset patch
> # User Vishakh H <vsh426 at gmail.com>
> # Date 1279263210 -19800
> # Node ID 25f876f3a1a882eda81e01651bc229c46a838af9
> # Parent  f24fc146825832dc47442cabdefed43c9afca0ba
> revlog: add a flags method that returns revision flags
> 
> flags returns all flags in revision by default or checks for an
> optional second flag.
> 
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -533,6 +533,11 @@
>          return self.index[rev][1]
>      def base(self, rev):
>          return self.index[rev][3]
> +    def flags(self, rev, checkflag=None):
> +        if checkflag:
> +            return ((self.index[rev][0] & 0xFFFF) & checkflag)
> +        else:
> +            return (self.index[rev][0] & 0xFFFF)

I like it.
If you had to detail the kind of flags that are stored here, in natural language, what would you say?

I am trying to see if we could use a name that would be more precise than simply "flags", because we already have quite a few different flags around the codebase, and sometimes we confuse which one is which.
I am not against the change at all: but since you should be familiar with this code by now, I am asking for your opinion, to see if we can improve the situation.

Thanks,

-Nicolas.

>  
>      def size(self, rev):
>          """return the length of the uncompressed text for a given revision"""
> @@ -1020,9 +1025,9 @@
>          base = self.base(rev)
>  
>          # check rev flags
> -        if self.index[rev][0] & 0xFFFF:
> +        if self.flags(rev):
>              raise RevlogError(_('incompatible revision flag %x') %
> -                              (self.index[rev][0] & 0xFFFF))
> +                              self.flags(rev))
>  
>          # do we have useful data cached?
>          if self._cache and self._cache[1] >= base and self._cache[1] < rev:
> _______________________________________________
> 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