comparison mercurial/revlog.py @ 41202:e7a2cc84dbc0

revlog: always enable generaldelta on version 2 revlogs This commit starts the process of diverging version 2 revlogs from version 1 revlogs. generaldelta is a useful feature and has been enabled by default for ages. I can't think of a good reason why the feature should be disabled. Yes, it is true changelogs today don't have generaldelta enabled. But that's because they don't have delta chains enabled, so generaldelta makes no sense there. This commit makes generaldelta always enabled on version 2 revlogs. As part of this, one-off code in changelog.py mucking with revlog.version had to be made conditional on the revlog version, as we don't want to change revlog feature flags on version 2 revlogs. The fact this code exists is horrible and stems from revlog options being shared by the opener. We probably want a better API here. But that can wait for another patch. Differential Revision: https://phab.mercurial-scm.org/D5561
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 09 Jan 2019 17:41:36 -0800
parents 6439cefaeb64
children d0de4fdd87aa
comparison
equal deleted inserted replaced
41201:6439cefaeb64 41202:e7a2cc84dbc0
385 385
386 mmapindexthreshold = None 386 mmapindexthreshold = None
387 opts = getattr(opener, 'options', {}) or {} 387 opts = getattr(opener, 'options', {}) or {}
388 388
389 if 'revlogv2' in opts: 389 if 'revlogv2' in opts:
390 # version 2 revlogs always use generaldelta. 390 versionflags = REVLOGV2 | FLAG_INLINE_DATA
391 versionflags = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA
392 elif 'revlogv1' in opts: 391 elif 'revlogv1' in opts:
393 versionflags = REVLOGV1 | FLAG_INLINE_DATA 392 versionflags = REVLOGV1 | FLAG_INLINE_DATA
394 if 'generaldelta' in opts: 393 if 'generaldelta' in opts:
395 versionflags |= FLAG_GENERALDELTA 394 versionflags |= FLAG_GENERALDELTA
396 else: 395 else:
449 except IOError as inst: 448 except IOError as inst:
450 if inst.errno != errno.ENOENT: 449 if inst.errno != errno.ENOENT:
451 raise 450 raise
452 451
453 self.version = versionflags 452 self.version = versionflags
454 self._inline = versionflags & FLAG_INLINE_DATA 453
455 self._generaldelta = versionflags & FLAG_GENERALDELTA
456 flags = versionflags & ~0xFFFF 454 flags = versionflags & ~0xFFFF
457 fmt = versionflags & 0xFFFF 455 fmt = versionflags & 0xFFFF
456
458 if fmt == REVLOGV0: 457 if fmt == REVLOGV0:
459 if flags: 458 if flags:
460 raise error.RevlogError(_('unknown flags (%#04x) in version %d ' 459 raise error.RevlogError(_('unknown flags (%#04x) in version %d '
461 'revlog %s') % 460 'revlog %s') %
462 (flags >> 16, fmt, self.indexfile)) 461 (flags >> 16, fmt, self.indexfile))
462
463 self._inline = False
464 self._generaldelta = False
465
463 elif fmt == REVLOGV1: 466 elif fmt == REVLOGV1:
464 if flags & ~REVLOGV1_FLAGS: 467 if flags & ~REVLOGV1_FLAGS:
465 raise error.RevlogError(_('unknown flags (%#04x) in version %d ' 468 raise error.RevlogError(_('unknown flags (%#04x) in version %d '
466 'revlog %s') % 469 'revlog %s') %
467 (flags >> 16, fmt, self.indexfile)) 470 (flags >> 16, fmt, self.indexfile))
471
472 self._inline = versionflags & FLAG_INLINE_DATA
473 self._generaldelta = versionflags & FLAG_GENERALDELTA
474
468 elif fmt == REVLOGV2: 475 elif fmt == REVLOGV2:
469 if flags & ~REVLOGV2_FLAGS: 476 if flags & ~REVLOGV2_FLAGS:
470 raise error.RevlogError(_('unknown flags (%#04x) in version %d ' 477 raise error.RevlogError(_('unknown flags (%#04x) in version %d '
471 'revlog %s') % 478 'revlog %s') %
472 (flags >> 16, fmt, self.indexfile)) 479 (flags >> 16, fmt, self.indexfile))
480
481 self._inline = versionflags & FLAG_INLINE_DATA
482 # generaldelta implied by version 2 revlogs.
483 self._generaldelta = True
484
473 else: 485 else:
474 raise error.RevlogError(_('unknown version (%d) in revlog %s') % 486 raise error.RevlogError(_('unknown version (%d) in revlog %s') %
475 (fmt, self.indexfile)) 487 (fmt, self.indexfile))
476 488
477 self._storedeltachains = True 489 self._storedeltachains = True