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

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Fri Jul 30 01:23:08 CDT 2010


On Fri, Jul 16, 2010 at 9:42 AM, Nicolas Dumazet <nicdumz at gmail.com> wrote:
> 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.

They could be called revlog index flags as opposed to, for example,
revlog header flags (like REVLOGNGINLINEDATA). But we could also go
further and do something like

  def flags(self, rev=None, check=None)

where if rev=None we check the header flags and otherwise index flags.

>>
>>      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:

-parren


More information about the Mercurial-devel mailing list