Mercurial > hg
comparison mercurial/revlog.py @ 47136:84b176ad2860
revlog: replace REVLOGV2 check related to sidedata with `hassidedata` checks
This is more flexible and semantically more correct. The associated revlog's
attribute exist since 827cb4fe62a3, so well we start linking sidedata to
revlogv2.
Differential Revision: https://phab.mercurial-scm.org/D10562
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 03 May 2021 12:19:09 +0200 |
parents | 1b33e38d4b6d |
children | f58a13c52726 |
comparison
equal
deleted
inserted
replaced
47135:1352cc14cce2 | 47136:84b176ad2860 |
---|---|
713 | 713 |
714 def length(self, rev): | 714 def length(self, rev): |
715 return self.index[rev][1] | 715 return self.index[rev][1] |
716 | 716 |
717 def sidedata_length(self, rev): | 717 def sidedata_length(self, rev): |
718 if self.version & 0xFFFF != REVLOGV2: | 718 if not self.hassidedata: |
719 return 0 | 719 return 0 |
720 return self.index[rev][9] | 720 return self.index[rev][9] |
721 | 721 |
722 def rawsize(self, rev): | 722 def rawsize(self, rev): |
723 """return the length of the uncompressed text for a given revision""" | 723 """return the length of the uncompressed text for a given revision""" |
1769 | 1769 |
1770 # ``rawtext`` is the text as stored inside the revlog. Might be the | 1770 # ``rawtext`` is the text as stored inside the revlog. Might be the |
1771 # revision or might need to be processed to retrieve the revision. | 1771 # revision or might need to be processed to retrieve the revision. |
1772 rev, rawtext, validated = self._rawtext(node, rev, _df=_df) | 1772 rev, rawtext, validated = self._rawtext(node, rev, _df=_df) |
1773 | 1773 |
1774 if self.version & 0xFFFF == REVLOGV2: | 1774 if self.hassidedata: |
1775 if rev is None: | 1775 if rev is None: |
1776 rev = self.rev(node) | 1776 rev = self.rev(node) |
1777 sidedata = self._sidedata(rev) | 1777 sidedata = self._sidedata(rev) |
1778 else: | 1778 else: |
1779 sidedata = {} | 1779 sidedata = {} |
2244 | 2244 |
2245 revinfo = _revisioninfo(node, p1, p2, btext, textlen, cachedelta, flags) | 2245 revinfo = _revisioninfo(node, p1, p2, btext, textlen, cachedelta, flags) |
2246 | 2246 |
2247 deltainfo = deltacomputer.finddeltainfo(revinfo, fh) | 2247 deltainfo = deltacomputer.finddeltainfo(revinfo, fh) |
2248 | 2248 |
2249 if sidedata and self.version & 0xFFFF == REVLOGV2: | 2249 if sidedata and self.hassidedata: |
2250 serialized_sidedata = sidedatautil.serialize_sidedata(sidedata) | 2250 serialized_sidedata = sidedatautil.serialize_sidedata(sidedata) |
2251 sidedata_offset = offset + deltainfo.deltalen | 2251 sidedata_offset = offset + deltainfo.deltalen |
2252 else: | 2252 else: |
2253 serialized_sidedata = b"" | 2253 serialized_sidedata = b"" |
2254 # Don't store the offset if the sidedata is empty, that way | 2254 # Don't store the offset if the sidedata is empty, that way |
3070 ) | 3070 ) |
3071 | 3071 |
3072 return d | 3072 return d |
3073 | 3073 |
3074 def rewrite_sidedata(self, helpers, startrev, endrev): | 3074 def rewrite_sidedata(self, helpers, startrev, endrev): |
3075 if self.version & 0xFFFF != REVLOGV2: | 3075 if not self.hassidedata: |
3076 return | 3076 return |
3077 # inline are not yet supported because they suffer from an issue when | 3077 # inline are not yet supported because they suffer from an issue when |
3078 # rewriting them (since it's not an append-only operation). | 3078 # rewriting them (since it's not an append-only operation). |
3079 # See issue6485. | 3079 # See issue6485. |
3080 assert not self._inline | 3080 assert not self._inline |