Mercurial > hg
comparison mercurial/revlog.py @ 51105:af96fbb8f739
revlog: add a `canonical_index_file` attribute on inner revlog
This is currently the same and the index_file but it will become more complex
when we start doing delayed write.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 26 Oct 2023 05:37:37 +0200 |
parents | 594f912818ab |
children | d83d788590a8 |
comparison
equal
deleted
inserted
replaced
51104:1c0f3994d733 | 51105:af96fbb8f739 |
---|---|
409 def clear_cache(self): | 409 def clear_cache(self): |
410 self._revisioncache = None | 410 self._revisioncache = None |
411 self._segmentfile.clear_cache() | 411 self._segmentfile.clear_cache() |
412 self._segmentfile_sidedata.clear_cache() | 412 self._segmentfile_sidedata.clear_cache() |
413 | 413 |
414 @property | |
415 def canonical_index_file(self): | |
416 return self.index_file | |
417 | |
414 # Derived from index values. | 418 # Derived from index values. |
415 | 419 |
416 def start(self, rev): | 420 def start(self, rev): |
417 """the offset of the data chunk for this revision""" | 421 """the offset of the data chunk for this revision""" |
418 return int(self.index[rev][0] >> 16) | 422 return int(self.index[rev][0] >> 16) |
1032 curr = len(self.index) - 1 | 1036 curr = len(self.index) - 1 |
1033 if not self.inline: | 1037 if not self.inline: |
1034 transaction.add(self.data_file, offset) | 1038 transaction.add(self.data_file, offset) |
1035 if self.sidedata_file: | 1039 if self.sidedata_file: |
1036 transaction.add(self.sidedata_file, sidedata_offset) | 1040 transaction.add(self.sidedata_file, sidedata_offset) |
1037 transaction.add(self.index_file, curr * len(entry)) | 1041 transaction.add(self.canonical_index_file, curr * len(entry)) |
1038 if data[0]: | 1042 if data[0]: |
1039 dfh.write(data[0]) | 1043 dfh.write(data[0]) |
1040 dfh.write(data[1]) | 1044 dfh.write(data[1]) |
1041 if sidedata: | 1045 if sidedata: |
1042 sdfh.write(sidedata) | 1046 sdfh.write(sidedata) |
1043 ifh.write(entry) | 1047 ifh.write(entry) |
1044 else: | 1048 else: |
1045 offset += curr * self.index.entry_size | 1049 offset += curr * self.index.entry_size |
1046 transaction.add(self.index_file, offset) | 1050 transaction.add(self.canonical_index_file, offset) |
1047 ifh.write(entry) | 1051 ifh.write(entry) |
1048 ifh.write(data[0]) | 1052 ifh.write(data[0]) |
1049 ifh.write(data[1]) | 1053 ifh.write(data[1]) |
1050 assert not sidedata | 1054 assert not sidedata |
1051 return ( | 1055 return ( |
2831 | 2835 |
2832 if self._docket is not None: | 2836 if self._docket is not None: |
2833 msg = b"inline revlog should not have a docket" | 2837 msg = b"inline revlog should not have a docket" |
2834 raise error.ProgrammingError(msg) | 2838 raise error.ProgrammingError(msg) |
2835 | 2839 |
2836 troffset = tr.findoffset(self._indexfile) | 2840 troffset = tr.findoffset(self._inner.canonical_index_file) |
2837 if troffset is None: | 2841 if troffset is None: |
2838 raise error.RevlogError( | 2842 raise error.RevlogError( |
2839 _(b"%s not found in the transaction") % self._indexfile | 2843 _(b"%s not found in the transaction") % self._indexfile |
2840 ) | 2844 ) |
2841 if troffset: | 2845 if troffset: |
2842 tr.addbackup(self._indexfile, for_offset=True) | 2846 tr.addbackup(self._inner.canonical_index_file, for_offset=True) |
2843 tr.add(self._datafile, 0) | 2847 tr.add(self._datafile, 0) |
2844 | 2848 |
2845 new_index_file_path = None | 2849 new_index_file_path = None |
2846 if side_write: | 2850 if side_write: |
2847 old_index_file_path = self._indexfile | 2851 old_index_file_path = self._indexfile |