Show More
@@ -470,7 +470,7 b' class revlog(object):' | |||
|
470 | 470 | raise RevlogError(_("index %s is corrupted") % (self.indexfile)) |
|
471 | 471 | self.index, self.nodemap, self._chunkcache = d |
|
472 | 472 | if not self._chunkcache: |
|
473 |
self._chunkc |
|
|
473 | self._chunkclear() | |
|
474 | 474 | |
|
475 | 475 | # add the magic null revision at -1 (if it hasn't been done already) |
|
476 | 476 | if (self.index == [] or isinstance(self.index, lazyindex) or |
@@ -551,7 +551,7 b' class revlog(object):' | |||
|
551 | 551 | |
|
552 | 552 | l = len(text) |
|
553 | 553 | for x in xrange(base + 1, rev + 1): |
|
554 | l = mdiff.patchedsize(l, self.chunk(x)) | |
|
554 | l = mdiff.patchedsize(l, self._chunk(x)) | |
|
555 | 555 | return l |
|
556 | 556 | """ |
|
557 | 557 | |
@@ -919,12 +919,11 b' class revlog(object):' | |||
|
919 | 919 | else: |
|
920 | 920 | self._chunkcache = offset, data |
|
921 | 921 | |
|
922 |
def _loadchunk(self, offset, length |
|
|
923 |
if |
|
|
924 |
|
|
|
925 | df = self.opener(self.indexfile) | |
|
926 | else: | |
|
927 | df = self.opener(self.datafile) | |
|
922 | def _loadchunk(self, offset, length): | |
|
923 | if self._inline: | |
|
924 | df = self.opener(self.indexfile) | |
|
925 | else: | |
|
926 | df = self.opener(self.datafile) | |
|
928 | 927 | |
|
929 | 928 | readahead = max(65536, length) |
|
930 | 929 | df.seek(offset) |
@@ -934,7 +933,7 b' class revlog(object):' | |||
|
934 | 933 | return d[:length] |
|
935 | 934 | return d |
|
936 | 935 | |
|
937 |
def _getchunk(self, offset, length |
|
|
936 | def _getchunk(self, offset, length): | |
|
938 | 937 | o, d = self._chunkcache |
|
939 | 938 | l = len(d) |
|
940 | 939 | |
@@ -946,26 +945,25 b' class revlog(object):' | |||
|
946 | 945 | return d # avoid a copy |
|
947 | 946 | return d[cachestart:cacheend] |
|
948 | 947 | |
|
949 |
return self._loadchunk(offset, length |
|
|
948 | return self._loadchunk(offset, length) | |
|
950 | 949 | |
|
951 |
def _ |
|
|
950 | def _chunkraw(self, startrev, endrev): | |
|
952 | 951 | start = self.start(startrev) |
|
953 |
|
|
|
952 | length = self.end(endrev) - start | |
|
954 | 953 | if self._inline: |
|
955 | 954 | start += (startrev + 1) * self._io.size |
|
956 | end += (startrev + 1) * self._io.size | |
|
957 | self._loadchunk(start, end - start, df) | |
|
955 | return self._getchunk(start, length) | |
|
958 | 956 | |
|
959 |
def chunk(self, rev |
|
|
960 | start, length = self.start(rev), self.length(rev) | |
|
961 | if self._inline: | |
|
962 | start += (rev + 1) * self._io.size | |
|
963 | return decompress(self._getchunk(start, length, df)) | |
|
957 | def _chunk(self, rev): | |
|
958 | return decompress(self._chunkraw(rev, rev)) | |
|
959 | ||
|
960 | def _chunkclear(self): | |
|
961 | self._chunkcache = (0, '') | |
|
964 | 962 | |
|
965 | 963 | def revdiff(self, rev1, rev2): |
|
966 | 964 | """return or calculate a delta between two revisions""" |
|
967 | 965 | if rev1 + 1 == rev2 and self.base(rev1) == self.base(rev2): |
|
968 | return self.chunk(rev2) | |
|
966 | return self._chunk(rev2) | |
|
969 | 967 | |
|
970 | 968 | return mdiff.textdiff(self.revision(self.node(rev1)), |
|
971 | 969 | self.revision(self.node(rev2))) |
@@ -987,24 +985,17 b' class revlog(object):' | |||
|
987 | 985 | raise RevlogError(_('incompatible revision flag %x') % |
|
988 | 986 | (self.index[rev][0] & 0xFFFF)) |
|
989 | 987 | |
|
990 | df = None | |
|
991 | ||
|
992 | 988 | # do we have useful data cached? |
|
993 | 989 | if self._cache and self._cache[1] >= base and self._cache[1] < rev: |
|
994 | 990 | base = self._cache[1] |
|
995 | 991 | text = str(self._cache[2]) |
|
996 | self._loadindex(base, rev + 1) | |
|
997 | if not self._inline and rev > base + 1: | |
|
998 | df = self.opener(self.datafile) | |
|
999 | self._prime(base, rev, df) | |
|
1000 | else: | |
|
1001 | self._loadindex(base, rev + 1) | |
|
1002 | if not self._inline and rev > base: | |
|
1003 | df = self.opener(self.datafile) | |
|
1004 | self._prime(base, rev, df) | |
|
1005 | text = self.chunk(base, df=df) | |
|
1006 | 992 | |
|
1007 | bins = [self.chunk(r, df) for r in xrange(base + 1, rev + 1)] | |
|
993 | self._loadindex(base, rev + 1) | |
|
994 | self._chunkraw(base, rev) | |
|
995 | if text is None: | |
|
996 | text = self._chunk(base) | |
|
997 | ||
|
998 | bins = [self._chunk(r) for r in xrange(base + 1, rev + 1)] | |
|
1008 | 999 | text = mdiff.patches(text, bins) |
|
1009 | 1000 | p1, p2 = self.parents(node) |
|
1010 | 1001 | if node != hash(text, p1, p2): |
@@ -1034,12 +1025,8 b' class revlog(object):' | |||
|
1034 | 1025 | |
|
1035 | 1026 | df = self.opener(self.datafile, 'w') |
|
1036 | 1027 | try: |
|
1037 | calc = self._io.size | |
|
1038 | 1028 | for r in self: |
|
1039 | start = self.start(r) + (r + 1) * calc | |
|
1040 | length = self.length(r) | |
|
1041 | d = self._getchunk(start, length) | |
|
1042 | df.write(d) | |
|
1029 | df.write(self._chunkraw(r, r)) | |
|
1043 | 1030 | finally: |
|
1044 | 1031 | df.close() |
|
1045 | 1032 | |
@@ -1054,8 +1041,8 b' class revlog(object):' | |||
|
1054 | 1041 | # real index |
|
1055 | 1042 | fp.rename() |
|
1056 | 1043 | |
|
1057 |
tr.replace(self.indexfile, trindex * |
|
|
1058 |
self._chunkc |
|
|
1044 | tr.replace(self.indexfile, trindex * self._io.size) | |
|
1045 | self._chunkclear() | |
|
1059 | 1046 | |
|
1060 | 1047 | def addrevision(self, text, transaction, link, p1, p2, d=None): |
|
1061 | 1048 | """add a revision to the log |
@@ -1341,7 +1328,7 b' class revlog(object):' | |||
|
1341 | 1328 | |
|
1342 | 1329 | # then reset internal state in memory to forget those revisions |
|
1343 | 1330 | self._cache = None |
|
1344 |
self._chunkc |
|
|
1331 | self._chunkclear() | |
|
1345 | 1332 | for x in xrange(rev, len(self)): |
|
1346 | 1333 | del self.nodemap[self.node(x)] |
|
1347 | 1334 |
General Comments 0
You need to be logged in to leave comments.
Login now