Show More
@@ -1342,6 +1342,8 b' class revlog(object):' | |||||
1342 | original seek position will NOT be restored. |
|
1342 | original seek position will NOT be restored. | |
1343 |
|
1343 | |||
1344 | Returns a str or buffer of raw byte data. |
|
1344 | Returns a str or buffer of raw byte data. | |
|
1345 | ||||
|
1346 | Raises if the requested number of bytes could not be read. | |||
1345 | """ |
|
1347 | """ | |
1346 | # Cache data both forward and backward around the requested |
|
1348 | # Cache data both forward and backward around the requested | |
1347 | # data, in a fixed size window. This helps speed up operations |
|
1349 | # data, in a fixed size window. This helps speed up operations | |
@@ -1353,9 +1355,26 b' class revlog(object):' | |||||
1353 | with self._datareadfp(df) as df: |
|
1355 | with self._datareadfp(df) as df: | |
1354 | df.seek(realoffset) |
|
1356 | df.seek(realoffset) | |
1355 | d = df.read(reallength) |
|
1357 | d = df.read(reallength) | |
|
1358 | ||||
1356 | self._cachesegment(realoffset, d) |
|
1359 | self._cachesegment(realoffset, d) | |
1357 | if offset != realoffset or reallength != length: |
|
1360 | if offset != realoffset or reallength != length: | |
1358 |
ret |
|
1361 | startoffset = offset - realoffset | |
|
1362 | if len(d) - startoffset < length: | |||
|
1363 | raise error.RevlogError( | |||
|
1364 | _('partial read of revlog %s; expected %d bytes from ' | |||
|
1365 | 'offset %d, got %d') % | |||
|
1366 | (self.indexfile if self._inline else self.datafile, | |||
|
1367 | length, realoffset, len(d) - startoffset)) | |||
|
1368 | ||||
|
1369 | return util.buffer(d, startoffset, length) | |||
|
1370 | ||||
|
1371 | if len(d) < length: | |||
|
1372 | raise error.RevlogError( | |||
|
1373 | _('partial read of revlog %s; expected %d bytes from offset ' | |||
|
1374 | '%d, got %d') % | |||
|
1375 | (self.indexfile if self._inline else self.datafile, | |||
|
1376 | length, offset, len(d))) | |||
|
1377 | ||||
1359 | return d |
|
1378 | return d | |
1360 |
|
1379 | |||
1361 | def _getsegment(self, offset, length, df=None): |
|
1380 | def _getsegment(self, offset, length, df=None): |
General Comments 0
You need to be logged in to leave comments.
Login now