##// END OF EJS Templates
revlog: raise offset/type helpers to global scope
Matt Mackall -
r4918:e017d3a8 default
parent child Browse files
Show More
@@ -61,7 +61,7 b' class bundlerevlog(revlog.revlog):'
61 61 if self.version == revlog.REVLOGV0:
62 62 e = (start, size, None, link, p1, p2, node)
63 63 else:
64 e = (self.offset_type(start, 0), size, -1, None, link,
64 e = (revlog.offset_type(start, 0), size, -1, None, link,
65 65 self.rev(p1), self.rev(p2), node)
66 66 self.basemap[n] = prev
67 67 self.index.append(e)
@@ -281,6 +281,17 b' class lazymap(object):'
281 281 class RevlogError(Exception): pass
282 282 class LookupError(RevlogError): pass
283 283
284 def getoffset(q):
285 if q & 0xFFFF:
286 raise RevlogError(_('incompatible revision flag %x') % q)
287 return int(q >> 16)
288
289 def gettype(q):
290 return int(q & 0xFFFF)
291
292 def offset_type(offset, type):
293 return long(long(offset) << 16 | type)
294
284 295 class revlog(object):
285 296 """
286 297 the underlying revision storage object
@@ -333,6 +344,8 b' class revlog(object):'
333 344 f = self.opener(self.indexfile)
334 345 i = f.read(4)
335 346 f.seek(0)
347 if len(i) > 0:
348 v = struct.unpack(versionformat, i)[0]
336 349 except IOError, inst:
337 350 if inst.errno != errno.ENOENT:
338 351 raise
@@ -351,8 +364,6 b' class revlog(object):'
351 364 and st.st_size == oldst.st_size):
352 365 return
353 366 self.indexstat = st
354 if len(i) > 0:
355 v = struct.unpack(versionformat, i)[0]
356 367 flags = v & ~0xFFFF
357 368 fmt = v & 0xFFFF
358 369 if fmt == REVLOGV0:
@@ -385,8 +396,8 b' class revlog(object):'
385 396 self.parseindex(f, st)
386 397 if self.version != REVLOGV0:
387 398 e = list(self.index[0])
388 type = self.ngtype(e[0])
389 e[0] = self.offset_type(0, type)
399 type = gettype(e[0])
400 e[0] = offset_type(0, type)
390 401 self.index[0] = e
391 402 else:
392 403 self.nodemap = {nullid: nullrev}
@@ -438,18 +449,6 b' class revlog(object):'
438 449 break
439 450
440 451
441 def ngoffset(self, q):
442 if q & 0xFFFF:
443 raise RevlogError(_('%s: incompatible revision flag %x') %
444 (self.indexfile, q))
445 return long(q >> 16)
446
447 def ngtype(self, q):
448 return int(q & 0xFFFF)
449
450 def offset_type(self, offset, type):
451 return long(long(offset) << 16 | type)
452
453 452 def loadindex(self, start, end):
454 453 """load a block of indexes all at once from the lazy parser"""
455 454 if isinstance(self.index, lazyindex):
@@ -498,7 +497,7 b' class revlog(object):'
498 497 if rev == nullrev:
499 498 return 0
500 499 if self.version != REVLOGV0:
501 return self.ngoffset(self.index[rev][0])
500 return getoffset(self.index[rev][0])
502 501 return self.index[rev][0]
503 502
504 503 def end(self, rev): return self.start(rev) + self.length(rev)
@@ -1042,7 +1041,7 b' class revlog(object):'
1042 1041 if self.version == REVLOGV0:
1043 1042 e = (offset, l, base, link, p1, p2, node)
1044 1043 else:
1045 e = (self.offset_type(offset, 0), l, len(text),
1044 e = (offset_type(offset, 0), l, len(text),
1046 1045 base, link, self.rev(p1), self.rev(p2), node)
1047 1046
1048 1047 self.index.append(e)
@@ -1205,7 +1204,7 b' class revlog(object):'
1205 1204 if self.version == REVLOGV0:
1206 1205 e = (end, len(cdelta), base, link, p1, p2, node)
1207 1206 else:
1208 e = (self.offset_type(end, 0), len(cdelta), textlen, base,
1207 e = (offset_type(end, 0), len(cdelta), textlen, base,
1209 1208 link, self.rev(p1), self.rev(p2), node)
1210 1209 self.index.append(e)
1211 1210 self.nodemap[node] = r
General Comments 0
You need to be logged in to leave comments. Login now