##// END OF EJS Templates
revlog: move `sidedata` in the inner object...
marmoute -
r51991:49d75cc1 default
parent child Browse files
Show More
@@ -938,6 +938,44 b' class _InnerRevlog:'
938 del basetext # let us have a chance to free memory early
938 del basetext # let us have a chance to free memory early
939 return (rev, rawtext, False)
939 return (rev, rawtext, False)
940
940
941 def sidedata(self, rev, sidedata_end):
942 """Return the sidedata for a given revision number."""
943 index_entry = self.index[rev]
944 sidedata_offset = index_entry[8]
945 sidedata_size = index_entry[9]
946
947 if self.inline:
948 sidedata_offset += self.index.entry_size * (1 + rev)
949 if sidedata_size == 0:
950 return {}
951
952 if sidedata_end < sidedata_offset + sidedata_size:
953 filename = self.sidedata_file
954 end = sidedata_end
955 offset = sidedata_offset
956 length = sidedata_size
957 m = FILE_TOO_SHORT_MSG % (filename, length, offset, end)
958 raise error.RevlogError(m)
959
960 comp_segment = self._segmentfile_sidedata.read_chunk(
961 sidedata_offset, sidedata_size
962 )
963
964 comp = self.index[rev][11]
965 if comp == COMP_MODE_PLAIN:
966 segment = comp_segment
967 elif comp == COMP_MODE_DEFAULT:
968 segment = self._decompressor(comp_segment)
969 elif comp == COMP_MODE_INLINE:
970 segment = self.decompress(comp_segment)
971 else:
972 msg = b'unknown compression mode %d'
973 msg %= comp
974 raise error.RevlogError(msg)
975
976 sidedata = sidedatautil.deserialize_sidedata(segment)
977 return sidedata
978
941
979
942 class revlog:
980 class revlog:
943 """
981 """
@@ -2631,41 +2669,10 b' class revlog:'
2631
2669
2632 def _sidedata(self, rev):
2670 def _sidedata(self, rev):
2633 """Return the sidedata for a given revision number."""
2671 """Return the sidedata for a given revision number."""
2634 index_entry = self.index[rev]
2672 sidedata_end = None
2635 sidedata_offset = index_entry[8]
2673 if self._docket is not None:
2636 sidedata_size = index_entry[9]
2674 sidedata_end = self._docket.sidedata_end
2637
2675 return self._inner.sidedata(rev, sidedata_end)
2638 if self._inline:
2639 sidedata_offset += self.index.entry_size * (1 + rev)
2640 if sidedata_size == 0:
2641 return {}
2642
2643 if self._docket.sidedata_end < sidedata_offset + sidedata_size:
2644 filename = self._sidedatafile
2645 end = self._docket.sidedata_end
2646 offset = sidedata_offset
2647 length = sidedata_size
2648 m = FILE_TOO_SHORT_MSG % (filename, length, offset, end)
2649 raise error.RevlogError(m)
2650
2651 comp_segment = self._inner._segmentfile_sidedata.read_chunk(
2652 sidedata_offset, sidedata_size
2653 )
2654
2655 comp = self.index[rev][11]
2656 if comp == COMP_MODE_PLAIN:
2657 segment = comp_segment
2658 elif comp == COMP_MODE_DEFAULT:
2659 segment = self._inner._decompressor(comp_segment)
2660 elif comp == COMP_MODE_INLINE:
2661 segment = self._inner.decompress(comp_segment)
2662 else:
2663 msg = b'unknown compression mode %d'
2664 msg %= comp
2665 raise error.RevlogError(msg)
2666
2667 sidedata = sidedatautil.deserialize_sidedata(segment)
2668 return sidedata
2669
2676
2670 def rawdata(self, nodeorrev):
2677 def rawdata(self, nodeorrev):
2671 """return an uncompressed raw data of a given node or revision number."""
2678 """return an uncompressed raw data of a given node or revision number."""
General Comments 0
You need to be logged in to leave comments. Login now