1069 file handle to be used for reading. If the file handle is read, its |
1069 file handle to be used for reading. If the file handle is read, its |
1070 seek position will not be preserved. |
1070 seek position will not be preserved. |
1071 |
1071 |
1072 Requests for data may be satisfied by a cache. |
1072 Requests for data may be satisfied by a cache. |
1073 |
1073 |
1074 Returns a str or a buffer instance of raw byte data. Callers will |
1074 Returns a 2-tuple of (offset, data) for the requested range of |
1075 need to call ``self.start(rev)`` and ``self.length()`` to determine |
1075 revisions. Offset is the integer offset from the beginning of the |
1076 where each revision's data begins and ends. |
1076 revlog and data is a str or buffer of the raw byte data. |
|
1077 |
|
1078 Callers will need to call ``self.start(rev)`` and ``self.length(rev)`` |
|
1079 to determine where each revision's data begins and ends. |
1077 """ |
1080 """ |
1078 start = self.start(startrev) |
1081 start = self.start(startrev) |
1079 end = self.end(endrev) |
1082 end = self.end(endrev) |
1080 if self._inline: |
1083 if self._inline: |
1081 start += (startrev + 1) * self._io.size |
1084 start += (startrev + 1) * self._io.size |
1082 end += (endrev + 1) * self._io.size |
1085 end += (endrev + 1) * self._io.size |
1083 length = end - start |
1086 length = end - start |
1084 return self._getchunk(start, length, df=df) |
1087 |
|
1088 return start, self._getchunk(start, length, df=df) |
1085 |
1089 |
1086 def _chunk(self, rev, df=None): |
1090 def _chunk(self, rev, df=None): |
1087 """Obtain a single decompressed chunk for a revision. |
1091 """Obtain a single decompressed chunk for a revision. |
1088 |
1092 |
1089 Accepts an integer revision and an optional already-open file handle |
1093 Accepts an integer revision and an optional already-open file handle |
1090 to be used for reading. If used, the seek position of the file will not |
1094 to be used for reading. If used, the seek position of the file will not |
1091 be preserved. |
1095 be preserved. |
1092 |
1096 |
1093 Returns a str holding uncompressed data for the requested revision. |
1097 Returns a str holding uncompressed data for the requested revision. |
1094 """ |
1098 """ |
1095 return decompress(self._chunkraw(rev, rev, df=df)) |
1099 return decompress(self._chunkraw(rev, rev, df=df)[1]) |
1096 |
1100 |
1097 def _chunks(self, revs, df=None): |
1101 def _chunks(self, revs, df=None): |
1098 """Obtain decompressed chunks for the specified revisions. |
1102 """Obtain decompressed chunks for the specified revisions. |
1099 |
1103 |
1100 Accepts an iterable of numeric revisions that are assumed to be in |
1104 Accepts an iterable of numeric revisions that are assumed to be in |
1121 # preload the cache |
1125 # preload the cache |
1122 try: |
1126 try: |
1123 while True: |
1127 while True: |
1124 # ensure that the cache doesn't change out from under us |
1128 # ensure that the cache doesn't change out from under us |
1125 _cache = self._chunkcache |
1129 _cache = self._chunkcache |
1126 self._chunkraw(revs[0], revs[-1], df=df) |
1130 self._chunkraw(revs[0], revs[-1], df=df)[1] |
1127 if _cache == self._chunkcache: |
1131 if _cache == self._chunkcache: |
1128 break |
1132 break |
1129 offset, data = _cache |
1133 offset, data = _cache |
1130 except OverflowError: |
1134 except OverflowError: |
1131 # issue4215 - we can't cache a run of chunks greater than |
1135 # issue4215 - we can't cache a run of chunks greater than |