revlog: directly use the Struct object for related operation
The Struct object has all the piece we needs, so no need to duplicate
information on the revlog itself.
Differential Revision: https://phab.mercurial-scm.org/D10307
--- a/mercurial/pure/parsers.py Mon Apr 05 12:21:23 2021 +0200
+++ b/mercurial/pure/parsers.py Mon Apr 05 12:21:58 2021 +0200
@@ -44,7 +44,7 @@
class BaseIndexObject(object):
# Format of an index entry according to Python's `struct` language
- index_format = revlog_constants.INDEX_ENTRY_V1.format
+ index_format = revlog_constants.INDEX_ENTRY_V1
# Size of a C unsigned long long int, platform independent
big_int_size = struct.calcsize(b'>Q')
# Size of a C long int, platform independent
@@ -99,7 +99,7 @@
def append(self, tup):
if '_nodemap' in vars(self):
self._nodemap[tup[7]] = len(self)
- data = _pack(self.index_format, *tup)
+ data = self.index_format.pack(*tup)
self._extra.append(data)
def _check_index(self, i):
@@ -117,7 +117,7 @@
else:
index = self._calculate_index(i)
data = self._data[index : index + self.index_size]
- r = _unpack(self.index_format, data)
+ r = self.index_format.unpack(data)
if self._lgt and i == 0:
r = (offset_type(0, gettype(r[0])),) + r[1:]
return r
@@ -243,7 +243,7 @@
class Index2Mixin(object):
- index_format = revlog_constants.INDEX_ENTRY_V2.format
+ index_format = revlog_constants.INDEX_ENTRY_V2
index_size = revlog_constants.INDEX_ENTRY_V2.size
null_item = (0, 0, 0, -1, -1, -1, -1, nullid, 0, 0)