1755 to be used for reading. If used, the seek position of the file will not |
1756 to be used for reading. If used, the seek position of the file will not |
1756 be preserved. |
1757 be preserved. |
1757 |
1758 |
1758 Returns a str holding uncompressed data for the requested revision. |
1759 Returns a str holding uncompressed data for the requested revision. |
1759 """ |
1760 """ |
1760 return self.decompress(self._getsegmentforrevs(rev, rev, df=df)[1]) |
1761 compression_mode = self.index[rev][10] |
|
1762 data = self._getsegmentforrevs(rev, rev, df=df)[1] |
|
1763 if compression_mode == COMP_MODE_PLAIN: |
|
1764 return data |
|
1765 elif compression_mode == COMP_MODE_INLINE: |
|
1766 return self.decompress(data) |
|
1767 else: |
|
1768 msg = 'unknown compression mode %d' |
|
1769 msg %= compression_mode |
|
1770 raise error.RevlogError(msg) |
1761 |
1771 |
1762 def _chunks(self, revs, df=None, targetsize=None): |
1772 def _chunks(self, revs, df=None, targetsize=None): |
1763 """Obtain decompressed chunks for the specified revisions. |
1773 """Obtain decompressed chunks for the specified revisions. |
1764 |
1774 |
1765 Accepts an iterable of numeric revisions that are assumed to be in |
1775 Accepts an iterable of numeric revisions that are assumed to be in |
1808 for rev in revschunk: |
1818 for rev in revschunk: |
1809 chunkstart = start(rev) |
1819 chunkstart = start(rev) |
1810 if inline: |
1820 if inline: |
1811 chunkstart += (rev + 1) * iosize |
1821 chunkstart += (rev + 1) * iosize |
1812 chunklength = length(rev) |
1822 chunklength = length(rev) |
|
1823 comp_mode = self.index[rev][10] |
1813 c = buffer(data, chunkstart - offset, chunklength) |
1824 c = buffer(data, chunkstart - offset, chunklength) |
1814 ladd(decomp(c)) |
1825 if comp_mode == COMP_MODE_PLAIN: |
|
1826 ladd(c) |
|
1827 elif comp_mode == COMP_MODE_INLINE: |
|
1828 ladd(decomp(c)) |
|
1829 else: |
|
1830 msg = 'unknown compression mode %d' |
|
1831 msg %= comp_mode |
|
1832 raise error.RevlogError(msg) |
1815 |
1833 |
1816 return l |
1834 return l |
1817 |
1835 |
1818 def _chunkclear(self): |
1836 def _chunkclear(self): |
1819 """Clear the raw chunk cache.""" |
1837 """Clear the raw chunk cache.""" |
2459 |
2477 |
2460 revinfo = _revisioninfo(node, p1, p2, btext, textlen, cachedelta, flags) |
2478 revinfo = _revisioninfo(node, p1, p2, btext, textlen, cachedelta, flags) |
2461 |
2479 |
2462 deltainfo = deltacomputer.finddeltainfo(revinfo, fh) |
2480 deltainfo = deltacomputer.finddeltainfo(revinfo, fh) |
2463 |
2481 |
|
2482 compression_mode = COMP_MODE_INLINE |
|
2483 if self._docket is not None: |
|
2484 h, d = deltainfo.data |
|
2485 if not h and not d: |
|
2486 # not data to store at all... declare them uncompressed |
|
2487 compression_mode = COMP_MODE_PLAIN |
|
2488 elif not h and d[0:1] == b'\0': |
|
2489 compression_mode = COMP_MODE_PLAIN |
|
2490 elif h == b'u': |
|
2491 # we have a more efficient way to declare uncompressed |
|
2492 h = b'' |
|
2493 compression_mode = COMP_MODE_PLAIN |
|
2494 deltainfo = deltautil.drop_u_compression(deltainfo) |
|
2495 |
2464 if sidedata and self.hassidedata: |
2496 if sidedata and self.hassidedata: |
2465 serialized_sidedata = sidedatautil.serialize_sidedata(sidedata) |
2497 serialized_sidedata = sidedatautil.serialize_sidedata(sidedata) |
2466 sidedata_offset = offset + deltainfo.deltalen |
2498 sidedata_offset = offset + deltainfo.deltalen |
2467 else: |
2499 else: |
2468 serialized_sidedata = b"" |
2500 serialized_sidedata = b"" |