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