##// END OF EJS Templates
revlog: move _getsegmentforrevs on the internal object...
marmoute -
r51980:df50a159 default
parent child Browse files
Show More
@@ -3720,11 +3720,15 b' def perfrevlogchunks(ui, repo, file_=Non'
3720
3720
3721 rl = cmdutil.openrevlog(repo, b'perfrevlogchunks', file_, opts)
3721 rl = cmdutil.openrevlog(repo, b'perfrevlogchunks', file_, opts)
3722
3722
3723 # _chunkraw was renamed to _getsegmentforrevs.
3723 # - _chunkraw was renamed to _getsegmentforrevs
3724 # - _getsegmentforrevs was moved on the inner object
3724 try:
3725 try:
3725 segmentforrevs = rl._getsegmentforrevs
3726 segmentforrevs = rl._inner.get_segment_for_revs
3726 except AttributeError:
3727 except AttributeError:
3727 segmentforrevs = rl._chunkraw
3728 try:
3729 segmentforrevs = rl._getsegmentforrevs
3730 except AttributeError:
3731 segmentforrevs = rl._chunkraw
3728
3732
3729 # Verify engines argument.
3733 # Verify engines argument.
3730 if engines:
3734 if engines:
@@ -3894,9 +3898,12 b' def perfrevlogrevision(ui, repo, file_, '
3894
3898
3895 # _chunkraw was renamed to _getsegmentforrevs.
3899 # _chunkraw was renamed to _getsegmentforrevs.
3896 try:
3900 try:
3897 segmentforrevs = r._getsegmentforrevs
3901 segmentforrevs = r._inner.get_segment_for_revs
3898 except AttributeError:
3902 except AttributeError:
3899 segmentforrevs = r._chunkraw
3903 try:
3904 segmentforrevs = r._getsegmentforrevs
3905 except AttributeError:
3906 segmentforrevs = r._chunkraw
3900
3907
3901 node = r.lookup(rev)
3908 node = r.lookup(rev)
3902 rev = r.rev(node)
3909 rev = r.rev(node)
@@ -508,6 +508,43 b' class _InnerRevlog:'
508 atomictemp=True,
508 atomictemp=True,
509 )
509 )
510
510
511 def get_segment_for_revs(self, startrev, endrev):
512 """Obtain a segment of raw data corresponding to a range of revisions.
513
514 Accepts the start and end revisions and an optional already-open
515 file handle to be used for reading. If the file handle is read, its
516 seek position will not be preserved.
517
518 Requests for data may be satisfied by a cache.
519
520 Returns a 2-tuple of (offset, data) for the requested range of
521 revisions. Offset is the integer offset from the beginning of the
522 revlog and data is a str or buffer of the raw byte data.
523
524 Callers will need to call ``self.start(rev)`` and ``self.length(rev)``
525 to determine where each revision's data begins and ends.
526
527 API: we should consider making this a private part of the InnerRevlog
528 at some point.
529 """
530 # Inlined self.start(startrev) & self.end(endrev) for perf reasons
531 # (functions are expensive).
532 index = self.index
533 istart = index[startrev]
534 start = int(istart[0] >> 16)
535 if startrev == endrev:
536 end = start + istart[1]
537 else:
538 iend = index[endrev]
539 end = int(iend[0] >> 16) + iend[1]
540
541 if self.inline:
542 start += (startrev + 1) * self.index.entry_size
543 end += (endrev + 1) * self.index.entry_size
544 length = end - start
545
546 return start, self._segmentfile.read_chunk(start, length)
547
511
548
512 class revlog:
549 class revlog:
513 """
550 """
@@ -1000,7 +1037,7 b' class revlog:'
1000 header = self.index.pack_header(header)
1037 header = self.index.pack_header(header)
1001 idx = header + idx
1038 idx = header + idx
1002 yield idx
1039 yield idx
1003 yield self._getsegmentforrevs(rev, rev)[1]
1040 yield self._inner.get_segment_for_revs(rev, rev)[1]
1004
1041
1005 inline_stream = get_stream()
1042 inline_stream = get_stream()
1006 next(inline_stream)
1043 next(inline_stream)
@@ -2153,40 +2190,6 b' class revlog:'
2153 p1, p2 = self.parents(node)
2190 p1, p2 = self.parents(node)
2154 return storageutil.hashrevisionsha1(text, p1, p2) != node
2191 return storageutil.hashrevisionsha1(text, p1, p2) != node
2155
2192
2156 def _getsegmentforrevs(self, startrev, endrev):
2157 """Obtain a segment of raw data corresponding to a range of revisions.
2158
2159 Accepts the start and end revisions and an optional already-open
2160 file handle to be used for reading. If the file handle is read, its
2161 seek position will not be preserved.
2162
2163 Requests for data may be satisfied by a cache.
2164
2165 Returns a 2-tuple of (offset, data) for the requested range of
2166 revisions. Offset is the integer offset from the beginning of the
2167 revlog and data is a str or buffer of the raw byte data.
2168
2169 Callers will need to call ``self.start(rev)`` and ``self.length(rev)``
2170 to determine where each revision's data begins and ends.
2171 """
2172 # Inlined self.start(startrev) & self.end(endrev) for perf reasons
2173 # (functions are expensive).
2174 index = self.index
2175 istart = index[startrev]
2176 start = int(istart[0] >> 16)
2177 if startrev == endrev:
2178 end = start + istart[1]
2179 else:
2180 iend = index[endrev]
2181 end = int(iend[0] >> 16) + iend[1]
2182
2183 if self._inline:
2184 start += (startrev + 1) * self.index.entry_size
2185 end += (endrev + 1) * self.index.entry_size
2186 length = end - start
2187
2188 return start, self._inner._segmentfile.read_chunk(start, length)
2189
2190 def _chunk(self, rev):
2193 def _chunk(self, rev):
2191 """Obtain a single decompressed chunk for a revision.
2194 """Obtain a single decompressed chunk for a revision.
2192
2195
@@ -2197,7 +2200,7 b' class revlog:'
2197 Returns a str holding uncompressed data for the requested revision.
2200 Returns a str holding uncompressed data for the requested revision.
2198 """
2201 """
2199 compression_mode = self.index[rev][10]
2202 compression_mode = self.index[rev][10]
2200 data = self._getsegmentforrevs(rev, rev)[1]
2203 data = self._inner.get_segment_for_revs(rev, rev)[1]
2201 if compression_mode == COMP_MODE_PLAIN:
2204 if compression_mode == COMP_MODE_PLAIN:
2202 return data
2205 return data
2203 elif compression_mode == COMP_MODE_DEFAULT:
2206 elif compression_mode == COMP_MODE_DEFAULT:
@@ -2248,7 +2251,10 b' class revlog:'
2248 break
2251 break
2249
2252
2250 try:
2253 try:
2251 offset, data = self._getsegmentforrevs(firstrev, lastrev)
2254 offset, data = self._inner.get_segment_for_revs(
2255 firstrev,
2256 lastrev,
2257 )
2252 except OverflowError:
2258 except OverflowError:
2253 # issue4215 - we can't cache a run of chunks greater than
2259 # issue4215 - we can't cache a run of chunks greater than
2254 # 2G on Windows
2260 # 2G on Windows
@@ -2616,7 +2622,7 b' class revlog:'
2616 try:
2622 try:
2617 with self.reading():
2623 with self.reading():
2618 for r in self:
2624 for r in self:
2619 new_dfh.write(self._getsegmentforrevs(r, r)[1])
2625 new_dfh.write(self._inner.get_segment_for_revs(r, r)[1])
2620 new_dfh.flush()
2626 new_dfh.flush()
2621
2627
2622 if side_write:
2628 if side_write:
@@ -411,8 +411,8 b' def debug_revlog(ui, revlog):'
411 numother_nad += 1
411 numother_nad += 1
412
412
413 # Obtain data on the raw chunks in the revlog.
413 # Obtain data on the raw chunks in the revlog.
414 if hasattr(r, '_getsegmentforrevs'):
414 if hasattr(r, '_inner'):
415 segment = r._getsegmentforrevs(rev, rev)[1]
415 segment = r._inner.get_segment_for_revs(rev, rev)[1]
416 else:
416 else:
417 segment = r._revlog._getsegmentforrevs(rev, rev)[1]
417 segment = r._revlog._getsegmentforrevs(rev, rev)[1]
418 if segment:
418 if segment:
@@ -126,7 +126,8 b' def v1_censor(rl, tr, censornode, tombst'
126 rl.opener.rename(newrl._datafile, rl._datafile)
126 rl.opener.rename(newrl._datafile, rl._datafile)
127
127
128 rl.clearcaches()
128 rl.clearcaches()
129 rl._loadindex()
129 chunk_cache = rl._loadindex()
130 rl._load_inner(chunk_cache)
130
131
131
132
132 def v2_censor(revlog, tr, censornode, tombstone=b''):
133 def v2_censor(revlog, tr, censornode, tombstone=b''):
General Comments 0
You need to be logged in to leave comments. Login now