##// END OF EJS Templates
revlog: move `offset_type` to `revlogutils`...
marmoute -
r48186:ac60a136 default
parent child Browse files
Show More
@@ -39,6 +39,7 b' from . import ('
39 39 phases,
40 40 pycompat,
41 41 revlog,
42 revlogutils,
42 43 util,
43 44 vfs as vfsmod,
44 45 )
@@ -95,7 +96,7 b' class bundlerevlog(revlog.revlog):'
95 96 baserev = self.rev(deltabase)
96 97 # start, size, full unc. size, base (unused), link, p1, p2, node, sidedata_offset (unused), sidedata_size (unused)
97 98 e = (
98 revlog.offset_type(start, flags),
99 revlogutils.offset_type(start, flags),
99 100 size,
100 101 -1,
101 102 baserev,
@@ -17,6 +17,7 b' from ..node import ('
17 17 from .. import (
18 18 error,
19 19 pycompat,
20 revlogutils,
20 21 util,
21 22 )
22 23
@@ -42,10 +43,6 b' def gettype(q):'
42 43 return int(q & 0xFFFF)
43 44
44 45
45 def offset_type(offset, type):
46 return int(int(offset) << 16 | type)
47
48
49 46 class BaseIndexObject(object):
50 47 # Can I be passed to an algorithme implemented in Rust ?
51 48 rust_ext_compat = 0
@@ -145,7 +142,8 b' class BaseIndexObject(object):'
145 142 data = self._data[index : index + self.entry_size]
146 143 r = self._unpack_entry(i, data)
147 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 147 return r
150 148
151 149 def _unpack_entry(self, rev, data):
@@ -72,6 +72,7 b' from . import ('
72 72 mdiff,
73 73 policy,
74 74 pycompat,
75 revlogutils,
75 76 templatefilters,
76 77 util,
77 78 )
@@ -146,12 +147,6 b' ellipsisprocessor = ('
146 147 )
147 148
148 149
149 def offset_type(offset, type):
150 if (type & ~flagutil.REVIDX_KNOWN_FLAGS) != 0:
151 raise ValueError(b'unknown revlog index flags')
152 return int(int(offset) << 16 | type)
153
154
155 150 def _verify_revision(rl, skipflags, state, node):
156 151 """Verify the integrity of the given revlog ``node`` while providing a hook
157 152 point for extensions to influence the operation."""
@@ -2590,7 +2585,7 b' class revlog(object):'
2590 2585 sidedata_offset = 0
2591 2586
2592 2587 e = (
2593 offset_type(offset, flags),
2588 revlogutils.offset_type(offset, flags),
2594 2589 deltainfo.deltalen,
2595 2590 textlen,
2596 2591 deltainfo.base,
@@ -6,3 +6,11 b''
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9
10 from ..interfaces import repository
11
12
13 def offset_type(offset, type):
14 if (type & ~repository.REVISION_FLAGS_KNOWN) != 0:
15 raise ValueError(b'unknown revlog index flags: %d' % type)
16 return int(int(offset) << 16 | type)
@@ -18,6 +18,7 b' from .. import ('
18 18 error,
19 19 node,
20 20 pycompat,
21 revlogutils,
21 22 util,
22 23 )
23 24
@@ -35,12 +36,6 b' def gettype(q):'
35 36 return int(q & 0xFFFF)
36 37
37 38
38 def offset_type(offset, type):
39 if (type & ~flagutil.REVIDX_KNOWN_FLAGS) != 0:
40 raise ValueError(b'unknown revlog index flags')
41 return int(int(offset) << 16 | type)
42
43
44 39 class revlogoldindex(list):
45 40 rust_ext_compat = 0
46 41 entry_size = INDEX_ENTRY_V0.size
@@ -143,7 +138,7 b' def parse_index_v0(data, inline):'
143 138 e = INDEX_ENTRY_V0.unpack(cur)
144 139 # transform to revlogv1 format
145 140 e2 = (
146 offset_type(e[0], 0),
141 revlogutils.offset_type(e[0], 0),
147 142 e[1],
148 143 -1,
149 144 e[2],
@@ -13,6 +13,7 b' from mercurial import ('
13 13 util,
14 14 )
15 15 from mercurial.revlogutils import flagutil
16 from mercurial.interfaces import repository
16 17
17 18 # Test only: These flags are defined here only in the context of testing the
18 19 # behavior of the flag processor. The canonical way to add flags is to get in
@@ -131,6 +132,7 b' def extsetup(ui):'
131 132 # Teach revlog about our test flags
132 133 flags = [REVIDX_NOOP, REVIDX_BASE64, REVIDX_GZIP, REVIDX_FAIL]
133 134 flagutil.REVIDX_KNOWN_FLAGS |= util.bitsfrom(flags)
135 repository.REVISION_FLAGS_KNOWN |= util.bitsfrom(flags)
134 136 revlog.REVIDX_FLAGS_ORDER.extend(flags)
135 137
136 138 # Teach exchange to use changegroup 3
General Comments 0
You need to be logged in to leave comments. Login now