Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 32430:36d3559c69a6
revlog: tweak wording and logic for flags validation
First, the logic around the if..elif..elif was subtly wrong
and sub-optimal because all branches would be tested as long as
the revlog was valid. This patch changes things so it behaves like
a switch statement over the revlog version.
While I was here, I also tweaked error strings to make them
consistent and to read better.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 19 May 2017 20:10:50 -0700 |
parents | df448de7cf3b |
children | d47b62368f3a |
comparison
equal
deleted
inserted
replaced
32429:3ea1f1e71a0a | 32430:36d3559c69a6 |
---|---|
326 self.version = v | 326 self.version = v |
327 self._inline = v & FLAG_INLINE_DATA | 327 self._inline = v & FLAG_INLINE_DATA |
328 self._generaldelta = v & FLAG_GENERALDELTA | 328 self._generaldelta = v & FLAG_GENERALDELTA |
329 flags = v & ~0xFFFF | 329 flags = v & ~0xFFFF |
330 fmt = v & 0xFFFF | 330 fmt = v & 0xFFFF |
331 if fmt == REVLOGV0 and flags: | 331 if fmt == REVLOGV0: |
332 raise RevlogError(_("index %s unknown flags %#04x for format v0") | 332 if flags: |
333 % (self.indexfile, flags >> 16)) | 333 raise RevlogError(_('unknown flags (%#04x) in version %d ' |
334 elif fmt == REVLOGV1 and flags & ~REVLOGV1_FLAGS: | 334 'revlog %s') % |
335 raise RevlogError(_("index %s unknown flags %#04x for revlogng") | 335 (flags >> 16, fmt, self.indexfile)) |
336 % (self.indexfile, flags >> 16)) | 336 elif fmt == REVLOGV1: |
337 elif fmt > REVLOGV1: | 337 if flags & ~REVLOGV1_FLAGS: |
338 raise RevlogError(_("index %s unknown format %d") | 338 raise RevlogError(_('unknown flags (%#04x) in version %d ' |
339 % (self.indexfile, fmt)) | 339 'revlog %s') % |
340 (flags >> 16, fmt, self.indexfile)) | |
341 else: | |
342 raise RevlogError(_('unknown version (%d) in revlog %s') % | |
343 (fmt, self.indexfile)) | |
340 | 344 |
341 self.storedeltachains = True | 345 self.storedeltachains = True |
342 | 346 |
343 self._io = revlogio() | 347 self._io = revlogio() |
344 if self.version == REVLOGV0: | 348 if self.version == REVLOGV0: |