Changeset View
Changeset View
Standalone View
Standalone View
mercurial/pure/parsers.py
Show All 36 Lines | def gettype(q): | ||||
return int(q & 0xFFFF) | return int(q & 0xFFFF) | ||||
def offset_type(offset, type): | def offset_type(offset, type): | ||||
return int(int(offset) << 16 | type) | return int(int(offset) << 16 | type) | ||||
class BaseIndexObject(object): | class BaseIndexObject(object): | ||||
# Format of an index entry according to Python's `struct` language | |||||
index_format = b">Qiiiiii20s12x" | index_format = b">Qiiiiii20s12x" | ||||
big_int_size = struct.calcsize(b'Q') | # Size of a C unsigned long long int, platform independent | ||||
int_size = struct.calcsize(b'i') | big_int_size = struct.calcsize(b'>Q') | ||||
# Size of a C long int, platform independent | |||||
SimonSapin: This description isn’t factually wrong, but wouldn’t it be a serious bug if the on-disk format… | |||||
Not Done ReplyCorrection: since index_format starts with >, it opts in both to big-endian and to "stardard sizes" so index_size is in fact platform-independent. See docs in https://docs.python.org/3/library/struct.html#format-characters Maybe > should be added to the format string for big_int_size and int_size as well, just to be safe. SimonSapin: Correction: since `index_format` starts with `>`, it opts in both to big-endian and to… | |||||
Done ReplyThanks for the catch, I'll add > to the other format strings Alphare: Thanks for the catch, I'll add `>` to the other format strings | |||||
int_size = struct.calcsize(b'>i') | |||||
# Size of the entire index format | |||||
index_size = struct.calcsize(index_format) | index_size = struct.calcsize(index_format) | ||||
# An empty index entry, used as a default value to be overridden, or nullrev | |||||
null_item = (0, 0, 0, -1, -1, -1, -1, nullid) | null_item = (0, 0, 0, -1, -1, -1, -1, nullid) | ||||
@property | @property | ||||
def nodemap(self): | def nodemap(self): | ||||
msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]" | msg = b"index.nodemap is deprecated, use index.[has_node|rev|get_rev]" | ||||
util.nouideprecwarn(msg, b'5.3', stacklevel=2) | util.nouideprecwarn(msg, b'5.3', stacklevel=2) | ||||
return self._nodemap | return self._nodemap | ||||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |
This description isn’t factually wrong, but wouldn’t it be a serious bug if the on-disk format ends up varying across different platforms?