Show More
@@ -336,9 +336,9 b' class revlog(object):' | |||||
336 | self.defversion = opener.defversion |
|
336 | self.defversion = opener.defversion | |
337 | if self.defversion & REVLOGNG: |
|
337 | if self.defversion & REVLOGNG: | |
338 | self.defversion |= REVLOGNGINLINEDATA |
|
338 | self.defversion |= REVLOGNGINLINEDATA | |
339 | self.load() |
|
339 | self._load() | |
340 |
|
340 | |||
341 | def load(self): |
|
341 | def _load(self): | |
342 | v = self.defversion |
|
342 | v = self.defversion | |
343 | try: |
|
343 | try: | |
344 | f = self.opener(self.indexfile) |
|
344 | f = self.opener(self.indexfile) | |
@@ -386,14 +386,14 b' class revlog(object):' | |||||
386 | shaoffset = ngshaoffset |
|
386 | shaoffset = ngshaoffset | |
387 |
|
387 | |||
388 | if i: |
|
388 | if i: | |
389 |
if (lazyparser.safe_to_use and not self.inline |
|
389 | if (lazyparser.safe_to_use and not self._inline() and | |
390 | st and st.st_size > 10000): |
|
390 | st and st.st_size > 10000): | |
391 | # big index, let's parse it on demand |
|
391 | # big index, let's parse it on demand | |
392 | parser = lazyparser(f, st.st_size, self.indexformat, shaoffset) |
|
392 | parser = lazyparser(f, st.st_size, self.indexformat, shaoffset) | |
393 | self.index = lazyindex(parser) |
|
393 | self.index = lazyindex(parser) | |
394 | self.nodemap = lazymap(parser) |
|
394 | self.nodemap = lazymap(parser) | |
395 | else: |
|
395 | else: | |
396 | self.parseindex(f, st) |
|
396 | self._parseindex(f, st) | |
397 | if self.version != REVLOGV0: |
|
397 | if self.version != REVLOGV0: | |
398 | e = list(self.index[0]) |
|
398 | e = list(self.index[0]) | |
399 | type = gettype(e[0]) |
|
399 | type = gettype(e[0]) | |
@@ -403,12 +403,11 b' class revlog(object):' | |||||
403 | self.nodemap = {nullid: nullrev} |
|
403 | self.nodemap = {nullid: nullrev} | |
404 | self.index = [] |
|
404 | self.index = [] | |
405 |
|
405 | |||
406 |
|
406 | def _parseindex(self, fp, st): | ||
407 | def parseindex(self, fp, st): |
|
|||
408 | s = struct.calcsize(self.indexformat) |
|
407 | s = struct.calcsize(self.indexformat) | |
409 | self.index = [] |
|
408 | self.index = [] | |
410 | self.nodemap = {nullid: nullrev} |
|
409 | self.nodemap = {nullid: nullrev} | |
411 |
inline = self.inline |
|
410 | inline = self._inline() | |
412 | n = 0 |
|
411 | n = 0 | |
413 | leftover = None |
|
412 | leftover = None | |
414 | while True: |
|
413 | while True: | |
@@ -419,7 +418,7 b' class revlog(object):' | |||||
419 | data = fp.read() |
|
418 | data = fp.read() | |
420 | if not data: |
|
419 | if not data: | |
421 | break |
|
420 | break | |
422 |
if n == 0 and self.inline |
|
421 | if n == 0 and self._inline(): | |
423 | # cache the first chunk |
|
422 | # cache the first chunk | |
424 | self.chunkcache = (0, data) |
|
423 | self.chunkcache = (0, data) | |
425 | if leftover: |
|
424 | if leftover: | |
@@ -449,25 +448,26 b' class revlog(object):' | |||||
449 | break |
|
448 | break | |
450 |
|
449 | |||
451 |
|
450 | |||
452 | def loadindex(self, start, end): |
|
451 | def _loadindex(self, start, end): | |
453 | """load a block of indexes all at once from the lazy parser""" |
|
452 | """load a block of indexes all at once from the lazy parser""" | |
454 | if isinstance(self.index, lazyindex): |
|
453 | if isinstance(self.index, lazyindex): | |
455 | self.index.p.loadindex(start, end) |
|
454 | self.index.p.loadindex(start, end) | |
456 |
|
455 | |||
457 | def loadindexmap(self): |
|
456 | def _loadindexmap(self): | |
458 | """loads both the map and the index from the lazy parser""" |
|
457 | """loads both the map and the index from the lazy parser""" | |
459 | if isinstance(self.index, lazyindex): |
|
458 | if isinstance(self.index, lazyindex): | |
460 | p = self.index.p |
|
459 | p = self.index.p | |
461 | p.loadindex() |
|
460 | p.loadindex() | |
462 | self.nodemap = p.map |
|
461 | self.nodemap = p.map | |
463 |
|
462 | |||
464 | def loadmap(self): |
|
463 | def _loadmap(self): | |
465 | """loads the map from the lazy parser""" |
|
464 | """loads the map from the lazy parser""" | |
466 | if isinstance(self.nodemap, lazymap): |
|
465 | if isinstance(self.nodemap, lazymap): | |
467 | self.nodemap.p.loadmap() |
|
466 | self.nodemap.p.loadmap() | |
468 | self.nodemap = self.nodemap.p.map |
|
467 | self.nodemap = self.nodemap.p.map | |
469 |
|
468 | |||
470 |
def inline |
|
469 | def _inline(self): return self.version & REVLOGNGINLINEDATA | |
|
470 | ||||
471 | def tip(self): return self.node(len(self.index) - 1) |
|
471 | def tip(self): return self.node(len(self.index) - 1) | |
472 | def count(self): return len(self.index) |
|
472 | def count(self): return len(self.index) | |
473 | def node(self, rev): |
|
473 | def node(self, rev): | |
@@ -841,7 +841,7 b' class revlog(object):' | |||||
841 |
|
841 | |||
842 | def chunk(self, rev, df=None, cachelen=4096): |
|
842 | def chunk(self, rev, df=None, cachelen=4096): | |
843 | start, length = self.start(rev), self.length(rev) |
|
843 | start, length = self.start(rev), self.length(rev) | |
844 |
inline = self.inline |
|
844 | inline = self._inline() | |
845 | if inline: |
|
845 | if inline: | |
846 | start += (rev + 1) * struct.calcsize(self.indexformat) |
|
846 | start += (rev + 1) * struct.calcsize(self.indexformat) | |
847 | end = start + length |
|
847 | end = start + length | |
@@ -899,7 +899,7 b' class revlog(object):' | |||||
899 | rev = self.rev(node) |
|
899 | rev = self.rev(node) | |
900 | base = self.base(rev) |
|
900 | base = self.base(rev) | |
901 |
|
901 | |||
902 |
if self.inline |
|
902 | if self._inline(): | |
903 | # we probably have the whole chunk cached |
|
903 | # we probably have the whole chunk cached | |
904 | df = None |
|
904 | df = None | |
905 | else: |
|
905 | else: | |
@@ -909,9 +909,9 b' class revlog(object):' | |||||
909 | if self.cache and self.cache[1] >= base and self.cache[1] < rev: |
|
909 | if self.cache and self.cache[1] >= base and self.cache[1] < rev: | |
910 | base = self.cache[1] |
|
910 | base = self.cache[1] | |
911 | text = self.cache[2] |
|
911 | text = self.cache[2] | |
912 | self.loadindex(base, rev + 1) |
|
912 | self._loadindex(base, rev + 1) | |
913 | else: |
|
913 | else: | |
914 | self.loadindex(base, rev + 1) |
|
914 | self._loadindex(base, rev + 1) | |
915 | text = self.chunk(base, df=df) |
|
915 | text = self.chunk(base, df=df) | |
916 |
|
916 | |||
917 | bins = [] |
|
917 | bins = [] | |
@@ -929,7 +929,7 b' class revlog(object):' | |||||
929 | return text |
|
929 | return text | |
930 |
|
930 | |||
931 | def checkinlinesize(self, tr, fp=None): |
|
931 | def checkinlinesize(self, tr, fp=None): | |
932 |
if not self.inline |
|
932 | if not self._inline(): | |
933 | return |
|
933 | return | |
934 | if not fp: |
|
934 | if not fp: | |
935 | fp = self.opener(self.indexfile, 'r') |
|
935 | fp = self.opener(self.indexfile, 'r') | |
@@ -986,7 +986,7 b' class revlog(object):' | |||||
986 | p1, p2 - the parent nodeids of the revision |
|
986 | p1, p2 - the parent nodeids of the revision | |
987 | d - an optional precomputed delta |
|
987 | d - an optional precomputed delta | |
988 | """ |
|
988 | """ | |
989 |
if not self.inline |
|
989 | if not self._inline(): | |
990 | dfh = self.opener(self.datafile, "a") |
|
990 | dfh = self.opener(self.datafile, "a") | |
991 | else: |
|
991 | else: | |
992 | dfh = None |
|
992 | dfh = None | |
@@ -1040,7 +1040,7 b' class revlog(object):' | |||||
1040 | self.nodemap[node] = n |
|
1040 | self.nodemap[node] = n | |
1041 | entry = struct.pack(self.indexformat, *e) |
|
1041 | entry = struct.pack(self.indexformat, *e) | |
1042 |
|
1042 | |||
1043 |
if not self.inline |
|
1043 | if not self._inline(): | |
1044 | transaction.add(self.datafile, offset) |
|
1044 | transaction.add(self.datafile, offset) | |
1045 | transaction.add(self.indexfile, n * len(entry)) |
|
1045 | transaction.add(self.indexfile, n * len(entry)) | |
1046 | if data[0]: |
|
1046 | if data[0]: | |
@@ -1058,7 +1058,7 b' class revlog(object):' | |||||
1058 |
|
1058 | |||
1059 | ifh.write(entry) |
|
1059 | ifh.write(entry) | |
1060 |
|
1060 | |||
1061 |
if self.inline |
|
1061 | if self._inline(): | |
1062 | ifh.write(data[0]) |
|
1062 | ifh.write(data[0]) | |
1063 | ifh.write(data[1]) |
|
1063 | ifh.write(data[1]) | |
1064 | self.checkinlinesize(transaction, ifh) |
|
1064 | self.checkinlinesize(transaction, ifh) | |
@@ -1135,7 +1135,7 b' class revlog(object):' | |||||
1135 | ifh = self.opener(self.indexfile, "a+") |
|
1135 | ifh = self.opener(self.indexfile, "a+") | |
1136 | ifh.seek(0, 2) |
|
1136 | ifh.seek(0, 2) | |
1137 | transaction.add(self.indexfile, ifh.tell(), self.count()) |
|
1137 | transaction.add(self.indexfile, ifh.tell(), self.count()) | |
1138 |
if self.inline |
|
1138 | if self._inline(): | |
1139 | dfh = None |
|
1139 | dfh = None | |
1140 | else: |
|
1140 | else: | |
1141 | transaction.add(self.datafile, end) |
|
1141 | transaction.add(self.datafile, end) | |
@@ -1184,7 +1184,7 b' class revlog(object):' | |||||
1184 | text = self.patches(text, [delta]) |
|
1184 | text = self.patches(text, [delta]) | |
1185 | chk = self._addrevision(text, transaction, link, p1, p2, None, |
|
1185 | chk = self._addrevision(text, transaction, link, p1, p2, None, | |
1186 | ifh, dfh) |
|
1186 | ifh, dfh) | |
1187 |
if not dfh and not self.inline |
|
1187 | if not dfh and not self._inline(): | |
1188 | # addrevision switched from inline to conventional |
|
1188 | # addrevision switched from inline to conventional | |
1189 | # reopen the index |
|
1189 | # reopen the index | |
1190 | dfh = self.opener(self.datafile, "a") |
|
1190 | dfh = self.opener(self.datafile, "a") | |
@@ -1200,11 +1200,11 b' class revlog(object):' | |||||
1200 | link, self.rev(p1), self.rev(p2), node) |
|
1200 | link, self.rev(p1), self.rev(p2), node) | |
1201 | self.index.append(e) |
|
1201 | self.index.append(e) | |
1202 | self.nodemap[node] = r |
|
1202 | self.nodemap[node] = r | |
1203 |
if self.inline |
|
1203 | if self._inline(): | |
1204 | ifh.write(struct.pack(self.indexformat, *e)) |
|
1204 | ifh.write(struct.pack(self.indexformat, *e)) | |
1205 | ifh.write(cdelta) |
|
1205 | ifh.write(cdelta) | |
1206 | self.checkinlinesize(transaction, ifh) |
|
1206 | self.checkinlinesize(transaction, ifh) | |
1207 |
if not self.inline |
|
1207 | if not self._inline(): | |
1208 | dfh = self.opener(self.datafile, "a") |
|
1208 | dfh = self.opener(self.datafile, "a") | |
1209 | ifh = self.opener(self.indexfile, "a") |
|
1209 | ifh = self.opener(self.indexfile, "a") | |
1210 | else: |
|
1210 | else: | |
@@ -1223,7 +1223,7 b' class revlog(object):' | |||||
1223 | return |
|
1223 | return | |
1224 |
|
1224 | |||
1225 | if isinstance(self.index, lazyindex): |
|
1225 | if isinstance(self.index, lazyindex): | |
1226 | self.loadindexmap() |
|
1226 | self._loadindexmap() | |
1227 |
|
1227 | |||
1228 | # When stripping away a revision, we need to make sure it |
|
1228 | # When stripping away a revision, we need to make sure it | |
1229 | # does not actually belong to an older changeset. |
|
1229 | # does not actually belong to an older changeset. | |
@@ -1236,7 +1236,7 b' class revlog(object):' | |||||
1236 |
|
1236 | |||
1237 | # first truncate the files on disk |
|
1237 | # first truncate the files on disk | |
1238 | end = self.start(rev) |
|
1238 | end = self.start(rev) | |
1239 |
if not self.inline |
|
1239 | if not self._inline(): | |
1240 | df = self.opener(self.datafile, "a") |
|
1240 | df = self.opener(self.datafile, "a") | |
1241 | df.truncate(end) |
|
1241 | df.truncate(end) | |
1242 | end = rev * struct.calcsize(self.indexformat) |
|
1242 | end = rev * struct.calcsize(self.indexformat) | |
@@ -1276,7 +1276,7 b' class revlog(object):' | |||||
1276 | s = struct.calcsize(self.indexformat) |
|
1276 | s = struct.calcsize(self.indexformat) | |
1277 | i = actual / s |
|
1277 | i = actual / s | |
1278 | di = actual - (i * s) |
|
1278 | di = actual - (i * s) | |
1279 |
if self.inline |
|
1279 | if self._inline(): | |
1280 | databytes = 0 |
|
1280 | databytes = 0 | |
1281 | for r in xrange(self.count()): |
|
1281 | for r in xrange(self.count()): | |
1282 | databytes += self.length(r) |
|
1282 | databytes += self.length(r) |
General Comments 0
You need to be logged in to leave comments.
Login now