##// END OF EJS Templates
revlog: move the details of revlog "v0" index inside revlog.utils.constants...
marmoute -
r47615:34e1fa4b default
parent child Browse files
Show More
@@ -41,6 +41,7 b' from .pycompat import getattr'
41 41 from .revlogutils.constants import (
42 42 FLAG_GENERALDELTA,
43 43 FLAG_INLINE_DATA,
44 INDEX_ENTRY_V0,
44 45 REVLOGV0,
45 46 REVLOGV1,
46 47 REVLOGV1_FLAGS,
@@ -218,19 +219,6 b' class revlogproblem(object):'
218 219 node = attr.ib(default=None)
219 220
220 221
221 # index v0:
222 # 4 bytes: offset
223 # 4 bytes: compressed length
224 # 4 bytes: base rev
225 # 4 bytes: link rev
226 # 20 bytes: parent 1 nodeid
227 # 20 bytes: parent 2 nodeid
228 # 20 bytes: nodeid
229 indexformatv0 = struct.Struct(b">4l20s20s20s")
230 indexformatv0_pack = indexformatv0.pack
231 indexformatv0_unpack = indexformatv0.unpack
232
233
234 222 class revlogoldindex(list):
235 223 @property
236 224 def nodemap(self):
@@ -284,7 +272,7 b' class revlogoldindex(list):'
284 272
285 273 class revlogoldio(object):
286 274 def __init__(self):
287 self.size = indexformatv0.size
275 self.size = INDEX_ENTRY_V0.size
288 276
289 277 def parseindex(self, data, inline):
290 278 s = self.size
@@ -295,7 +283,7 b' class revlogoldio(object):'
295 283 while off + s <= l:
296 284 cur = data[off : off + s]
297 285 off += s
298 e = indexformatv0_unpack(cur)
286 e = INDEX_ENTRY_V0.unpack(cur)
299 287 # transform to revlogv1 format
300 288 e2 = (
301 289 offset_type(e[0], 0),
@@ -315,6 +303,13 b' class revlogoldio(object):'
315 303 return index, None
316 304
317 305 def packentry(self, entry, node, version, rev):
306 """return the binary representation of an entry
307
308 entry: a tuple containing all the values (see index.__getitem__)
309 node: a callback to convert a revision to nodeid
310 version: the changelog version
311 rev: the revision number
312 """
318 313 if gettype(entry[0]):
319 314 raise error.RevlogError(
320 315 _(b'index entry flags need revlog version 1')
@@ -328,7 +323,7 b' class revlogoldio(object):'
328 323 node(entry[6]),
329 324 entry[7],
330 325 )
331 return indexformatv0_pack(*e2)
326 return INDEX_ENTRY_V0.pack(*e2)
332 327
333 328
334 329 # index ng:
@@ -9,6 +9,8 b''
9 9
10 10 from __future__ import absolute_import
11 11
12 import struct
13
12 14 from ..interfaces import repository
13 15
14 16 ### main revlog header
@@ -32,6 +34,16 b' REVLOGV2_FLAGS = FLAG_INLINE_DATA'
32 34
33 35 ### individual entry
34 36
37 ## index v0:
38 # 4 bytes: offset
39 # 4 bytes: compressed length
40 # 4 bytes: base rev
41 # 4 bytes: link rev
42 # 20 bytes: parent 1 nodeid
43 # 20 bytes: parent 2 nodeid
44 # 20 bytes: nodeid
45 INDEX_ENTRY_V0 = struct.Struct(b">4l20s20s20s")
46
35 47 # revlog index flags
36 48
37 49 # For historical reasons, revlog's internal flags were exposed via the
General Comments 0
You need to be logged in to leave comments. Login now