Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 51104:c2d2e5b65def
revlog: minor refactor in the chunk gather process
We will introduce some caching in this method in the next changeset, we make
some of the most "disruptive" change first as touching this could break (and
maybe did during the development process).
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 27 Oct 2023 02:57:09 +0200 |
parents | d83d788590a8 |
children | 0250e45040f1 |
comparison
equal
deleted
inserted
replaced
51103:d83d788590a8 | 51104:c2d2e5b65def |
---|---|
899 iosize = self.index.entry_size | 899 iosize = self.index.entry_size |
900 buffer = util.buffer | 900 buffer = util.buffer |
901 | 901 |
902 l = [] | 902 l = [] |
903 ladd = l.append | 903 ladd = l.append |
904 chunks = [] | |
905 ladd = chunks.append | |
904 | 906 |
905 if not self.data_config.with_sparse_read: | 907 if not self.data_config.with_sparse_read: |
906 slicedchunks = (revs,) | 908 slicedchunks = (revs,) |
907 else: | 909 else: |
908 slicedchunks = deltautil.slicechunk( | 910 slicedchunks = deltautil.slicechunk( |
921 try: | 923 try: |
922 offset, data = self.get_segment_for_revs(firstrev, lastrev) | 924 offset, data = self.get_segment_for_revs(firstrev, lastrev) |
923 except OverflowError: | 925 except OverflowError: |
924 # issue4215 - we can't cache a run of chunks greater than | 926 # issue4215 - we can't cache a run of chunks greater than |
925 # 2G on Windows | 927 # 2G on Windows |
926 return [self._chunk(rev) for rev in revschunk] | 928 for rev in revschunk: |
929 ladd((rev, self._chunk(rev))) | |
927 | 930 |
928 decomp = self.decompress | 931 decomp = self.decompress |
929 # self._decompressor might be None, but will not be used in that case | 932 # self._decompressor might be None, but will not be used in that case |
930 def_decomp = self._decompressor | 933 def_decomp = self._decompressor |
931 for rev in revschunk: | 934 for rev in revschunk: |
934 chunkstart += (rev + 1) * iosize | 937 chunkstart += (rev + 1) * iosize |
935 chunklength = length(rev) | 938 chunklength = length(rev) |
936 comp_mode = self.index[rev][10] | 939 comp_mode = self.index[rev][10] |
937 c = buffer(data, chunkstart - offset, chunklength) | 940 c = buffer(data, chunkstart - offset, chunklength) |
938 if comp_mode == COMP_MODE_PLAIN: | 941 if comp_mode == COMP_MODE_PLAIN: |
939 ladd(c) | 942 c = c |
940 elif comp_mode == COMP_MODE_INLINE: | 943 elif comp_mode == COMP_MODE_INLINE: |
941 ladd(decomp(c)) | 944 c = decomp(c) |
942 elif comp_mode == COMP_MODE_DEFAULT: | 945 elif comp_mode == COMP_MODE_DEFAULT: |
943 ladd(def_decomp(c)) | 946 c = def_decomp(c) |
944 else: | 947 else: |
945 msg = b'unknown compression mode %d' | 948 msg = b'unknown compression mode %d' |
946 msg %= comp_mode | 949 msg %= comp_mode |
947 raise error.RevlogError(msg) | 950 raise error.RevlogError(msg) |
948 | 951 ladd((rev, c)) |
949 return l | 952 |
953 return [x[1] for x in chunks] | |
950 | 954 |
951 def raw_text(self, node, rev): | 955 def raw_text(self, node, rev): |
952 """return the possibly unvalidated rawtext for a revision | 956 """return the possibly unvalidated rawtext for a revision |
953 | 957 |
954 returns (rev, rawtext, validated) | 958 returns (rev, rawtext, validated) |