##// END OF EJS Templates
revlog: unify checks for supported flag...
marmoute -
r48004:0e9105bf default
parent child Browse files
Show More
@@ -46,6 +46,7 b' from .revlogutils.constants import ('
46 REVLOG_DEFAULT_FLAGS,
46 REVLOG_DEFAULT_FLAGS,
47 REVLOG_DEFAULT_FORMAT,
47 REVLOG_DEFAULT_FORMAT,
48 REVLOG_DEFAULT_VERSION,
48 REVLOG_DEFAULT_VERSION,
49 SUPPORTED_FLAGS,
49 )
50 )
50 from .revlogutils.flagutil import (
51 from .revlogutils.flagutil import (
51 REVIDX_DEFAULT_FLAGS,
52 REVIDX_DEFAULT_FLAGS,
@@ -487,33 +488,24 b' class revlog(object):'
487 self._format_flags = header & ~0xFFFF
488 self._format_flags = header & ~0xFFFF
488 self._format_version = header & 0xFFFF
489 self._format_version = header & 0xFFFF
489
490
491 supported_flags = SUPPORTED_FLAGS.get(self._format_version)
492 if supported_flags is None:
493 msg = _(b'unknown version (%d) in revlog %s')
494 msg %= (self._format_version, self.display_id)
495 raise error.RevlogError(msg)
496 elif self._format_flags & ~supported_flags:
497 msg = _(b'unknown flags (%#04x) in version %d revlog %s')
498 display_flag = self._format_flags >> 16
499 msg %= (display_flag, self._format_version, self.display_id)
500 raise error.RevlogError(msg)
501
490 if self._format_version == REVLOGV0:
502 if self._format_version == REVLOGV0:
491 if self._format_flags:
492 msg = _(b'unknown flags (%#04x) in version %d revlog %s')
493 display_flag = self._format_flags >> 16
494 msg %= (display_flag, self._format_version, self.display_id)
495 raise error.RevlogError(msg)
496
497 self._inline = False
503 self._inline = False
498 self._generaldelta = False
504 self._generaldelta = False
499
500 elif self._format_version == REVLOGV1:
505 elif self._format_version == REVLOGV1:
501 if self._format_flags & ~REVLOGV1_FLAGS:
502 msg = _(b'unknown flags (%#04x) in version %d revlog %s')
503 display_flag = self._format_flags >> 16
504 msg %= (display_flag, self._format_version, self.display_id)
505 raise error.RevlogError(msg)
506
507 self._inline = self._format_flags & FLAG_INLINE_DATA
506 self._inline = self._format_flags & FLAG_INLINE_DATA
508 self._generaldelta = self._format_flags & FLAG_GENERALDELTA
507 self._generaldelta = self._format_flags & FLAG_GENERALDELTA
509
510 elif self._format_version == REVLOGV2:
508 elif self._format_version == REVLOGV2:
511 if self._format_flags & ~REVLOGV2_FLAGS:
512 msg = _(b'unknown flags (%#04x) in version %d revlog %s')
513 display_flag = self._format_flags >> 16
514 msg %= (display_flag, self._format_version, self.display_id)
515 raise error.RevlogError(msg)
516
517 # There is a bug in the transaction handling when going from an
509 # There is a bug in the transaction handling when going from an
518 # inline revlog to a separate index and data file. Turn it off until
510 # inline revlog to a separate index and data file. Turn it off until
519 # it's fixed, since v2 revlogs sometimes get rewritten on exchange.
511 # it's fixed, since v2 revlogs sometimes get rewritten on exchange.
@@ -523,11 +515,8 b' class revlog(object):'
523 self._generaldelta = True
515 self._generaldelta = True
524 # revlog-v2 has built in sidedata support
516 # revlog-v2 has built in sidedata support
525 self.hassidedata = True
517 self.hassidedata = True
526
527 else:
518 else:
528 msg = _(b'unknown version (%d) in revlog %s')
519 assert False, 'unreachable'
529 msg %= (self._format_version, self.display_id)
530 raise error.RevlogError(msg)
531
520
532 index_data = entry_data
521 index_data = entry_data
533 self._indexfile = entry_point
522 self._indexfile = entry_point
@@ -45,6 +45,7 b' FLAG_GENERALDELTA = 1 << 17'
45 REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA
45 REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA
46 REVLOG_DEFAULT_FORMAT = REVLOGV1
46 REVLOG_DEFAULT_FORMAT = REVLOGV1
47 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
47 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
48 REVLOGV0_FLAGS = 0
48 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
49 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
49 REVLOGV2_FLAGS = FLAG_INLINE_DATA
50 REVLOGV2_FLAGS = FLAG_INLINE_DATA
50
51
@@ -113,4 +114,10 b' REVIDX_FLAGS_ORDER = ['
113 # bitmark for flags that could cause rawdata content change
114 # bitmark for flags that could cause rawdata content change
114 REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED
115 REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED
115
116
117 SUPPORTED_FLAGS = {
118 REVLOGV0: REVLOGV0_FLAGS,
119 REVLOGV1: REVLOGV1_FLAGS,
120 REVLOGV2: REVLOGV2_FLAGS,
121 }
122
116 SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000
123 SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000
General Comments 0
You need to be logged in to leave comments. Login now