Tag caching, at last

Greg Ward greg-hg at gerg.ca
Sun Jul 12 16:18:03 CDT 2009


On Sat, Jul 11, 2009 at 7:55 PM, timeless<timeless at gmail.com> wrote:
> On Fri, Jul 10, 2009 at 6:34 PM, Greg Ward<greg at gerg.ca> wrote:
>>    def _readversion(self, cachefile):
>>        """Read the first line of the cache file, which contains the
>>        file version number.  Return true if we can use this cache file."""
>>
>>        # The first line looks like "hgtagcache 0000", where 0000 is the
>>        # version number for the file format in hex.  (This should make
>>        # it possible to switch to a binary format if necessary in
>>        # future, where the first 16 chars will be "hgtagcache xxxx\n".)
>>        firstline = cachefile.next()
>>        if not (len(firstline) == 16 and
>>                firstline[:11] == 'hgtagcache '):
>>            self.ui.warn(_("invalid tag cache file (ignoring it)\n"))
>>            return False
>
> do you need 'else:' here? :)
>>        else:
>>            try:
>>                version = int(firstline[11:15], 16)
>>            except ValueError:
>>                ui.warn(_("invalid tag cache version (%r)") % firstline[11:15])
>>                return False

Strictly speaking, no.  But I like clear, detailed, specific error messages.

Greg



More information about the Mercurial-devel mailing list