comparison mercurial/pure/parsers.py @ 47394:ac60a1366a49

revlog: move `offset_type` to `revlogutils` This multiple module are using this so it make sense to move it at the utility level. Differential Revision: https://phab.mercurial-scm.org/D10792
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 30 May 2021 16:19:36 +0200
parents 25ce16bf724b
children 084ed6a7c6fd
comparison
equal deleted inserted replaced
47393:7a0ec25d5836 47394:ac60a1366a49
15 sha1nodeconstants, 15 sha1nodeconstants,
16 ) 16 )
17 from .. import ( 17 from .. import (
18 error, 18 error,
19 pycompat, 19 pycompat,
20 revlogutils,
20 util, 21 util,
21 ) 22 )
22 23
23 from ..revlogutils import nodemap as nodemaputil 24 from ..revlogutils import nodemap as nodemaputil
24 from ..revlogutils import constants as revlog_constants 25 from ..revlogutils import constants as revlog_constants
38 return x 39 return x
39 40
40 41
41 def gettype(q): 42 def gettype(q):
42 return int(q & 0xFFFF) 43 return int(q & 0xFFFF)
43
44
45 def offset_type(offset, type):
46 return int(int(offset) << 16 | type)
47 44
48 45
49 class BaseIndexObject(object): 46 class BaseIndexObject(object):
50 # Can I be passed to an algorithme implemented in Rust ? 47 # Can I be passed to an algorithme implemented in Rust ?
51 rust_ext_compat = 0 48 rust_ext_compat = 0
143 else: 140 else:
144 index = self._calculate_index(i) 141 index = self._calculate_index(i)
145 data = self._data[index : index + self.entry_size] 142 data = self._data[index : index + self.entry_size]
146 r = self._unpack_entry(i, data) 143 r = self._unpack_entry(i, data)
147 if self._lgt and i == 0: 144 if self._lgt and i == 0:
148 r = (offset_type(0, gettype(r[0])),) + r[1:] 145 offset = revlogutils.offset_type(0, gettype(r[0]))
146 r = (offset,) + r[1:]
149 return r 147 return r
150 148
151 def _unpack_entry(self, rev, data): 149 def _unpack_entry(self, rev, data):
152 r = self.index_format.unpack(data) 150 r = self.index_format.unpack(data)
153 r = r + ( 151 r = r + (