##// END OF EJS Templates
revlog: some basic code reordering
Matt Mackall -
r4987:8d30004a default
parent child Browse files
Show More
@@ -15,17 +15,30 b' from i18n import _'
15 import binascii, changegroup, errno, ancestor, mdiff, os
15 import binascii, changegroup, errno, ancestor, mdiff, os
16 import sha, struct, util, zlib
16 import sha, struct, util, zlib
17
17
18 # revlog version strings
18 # revlog flags
19 REVLOGV0 = 0
19 REVLOGV0 = 0
20 REVLOGNG = 1
20 REVLOGNG = 1
21
22 # revlog flags
23 REVLOGNGINLINEDATA = (1 << 16)
21 REVLOGNGINLINEDATA = (1 << 16)
24 REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA
22 REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA
25
26 REVLOG_DEFAULT_FORMAT = REVLOGNG
23 REVLOG_DEFAULT_FORMAT = REVLOGNG
27 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
24 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
28
25
26 class RevlogError(Exception):
27 pass
28 class LookupError(RevlogError):
29 pass
30
31 def getoffset(q):
32 if q & 0xFFFF:
33 raise RevlogError(_('incompatible revision flag %x') % q)
34 return int(q >> 16)
35
36 def gettype(q):
37 return int(q & 0xFFFF)
38
39 def offset_type(offset, type):
40 return long(long(offset) << 16 | type)
41
29 def hash(text, p1, p2):
42 def hash(text, p1, p2):
30 """generate a hash from the given text and its parent hashes
43 """generate a hash from the given text and its parent hashes
31
44
@@ -68,22 +81,6 b' def decompress(bin):'
68 return bin[1:]
81 return bin[1:]
69 raise RevlogError(_("unknown compression type %r") % t)
82 raise RevlogError(_("unknown compression type %r") % t)
70
83
71 indexformatv0 = ">4l20s20s20s"
72 v0shaoffset = 56
73 # index ng:
74 # 6 bytes offset
75 # 2 bytes flags
76 # 4 bytes compressed length
77 # 4 bytes uncompressed length
78 # 4 bytes: base rev
79 # 4 bytes link rev
80 # 4 bytes parent 1 rev
81 # 4 bytes parent 2 rev
82 # 32 bytes: nodeid
83 indexformatng = ">Qiiiiii20s12x"
84 ngshaoffset = 32
85 versionformat = ">I"
86
87 class lazyparser(object):
84 class lazyparser(object):
88 """
85 """
89 this class avoids the need to parse the entirety of large indices
86 this class avoids the need to parse the entirety of large indices
@@ -289,21 +286,8 b' class lazymap(object):'
289 def __delitem__(self, key):
286 def __delitem__(self, key):
290 del self.p.map[key]
287 del self.p.map[key]
291
288
292 class RevlogError(Exception):
289 indexformatv0 = ">4l20s20s20s"
293 pass
290 v0shaoffset = 56
294 class LookupError(RevlogError):
295 pass
296
297 def getoffset(q):
298 if q & 0xFFFF:
299 raise RevlogError(_('incompatible revision flag %x') % q)
300 return int(q >> 16)
301
302 def gettype(q):
303 return int(q & 0xFFFF)
304
305 def offset_type(offset, type):
306 return long(long(offset) << 16 | type)
307
291
308 class revlogoldio(object):
292 class revlogoldio(object):
309 def __init__(self):
293 def __init__(self):
@@ -334,6 +318,20 b' class revlogoldio(object):'
334 node(entry[5]), node(entry[6]), entry[7])
318 node(entry[5]), node(entry[6]), entry[7])
335 return struct.pack(indexformatv0, *e2)
319 return struct.pack(indexformatv0, *e2)
336
320
321 # index ng:
322 # 6 bytes offset
323 # 2 bytes flags
324 # 4 bytes compressed length
325 # 4 bytes uncompressed length
326 # 4 bytes: base rev
327 # 4 bytes link rev
328 # 4 bytes parent 1 rev
329 # 4 bytes parent 2 rev
330 # 32 bytes: nodeid
331 indexformatng = ">Qiiiiii20s12x"
332 ngshaoffset = 32
333 versionformat = ">I"
334
337 class revlogio(object):
335 class revlogio(object):
338 def __init__(self):
336 def __init__(self):
339 self.size = struct.calcsize(indexformatng)
337 self.size = struct.calcsize(indexformatng)
@@ -1253,5 +1251,3 b' class revlog(object):'
1253 di = 0
1251 di = 0
1254
1252
1255 return (dd, di)
1253 return (dd, di)
1256
1257
General Comments 0
You need to be logged in to leave comments. Login now