comparison mercurial/revlogutils/rewrite.py @ 51019:66c139d33cfe

censors: simply use `revlog.reading` to keep things open dring rewrite We have a dedicated context now, we can simply use it. In practice, we cannot "simply" use it, as `finddeltainfo` still requires the file pointer to be passed explicitly. We will keep the old context manager open for a small bit until we get rid of it in a future changeset.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 25 Sep 2023 16:47:55 +0200
parents 862e3a13da44
children 509f0f7fc89e
comparison
equal deleted inserted replaced
51018:720e5a5f2b95 51019:66c139d33cfe
232 Return a mapping: {rev → (new_base, data_start, data_end, compression_mode)} 232 Return a mapping: {rev → (new_base, data_start, data_end, compression_mode)}
233 """ 233 """
234 dc = deltas.deltacomputer(revlog) 234 dc = deltas.deltacomputer(revlog)
235 rewritten_entries = {} 235 rewritten_entries = {}
236 first_excl_rev = min(excluded_revs) 236 first_excl_rev = min(excluded_revs)
237 with revlog._segmentfile._open_read() as dfh: 237 with revlog.reading(), revlog._segmentfile._open_read() as dfh:
238 for rev in range(first_excl_rev, len(old_index)): 238 for rev in range(first_excl_rev, len(old_index)):
239 if rev in excluded_revs: 239 if rev in excluded_revs:
240 # this revision will be preserved as is, so we don't need to 240 # this revision will be preserved as is, so we don't need to
241 # consider recomputing a delta. 241 # consider recomputing a delta.
242 continue 242 continue
248 if entry[ENTRY_DATA_UNCOMPRESSED_LENGTH] == 0: 248 if entry[ENTRY_DATA_UNCOMPRESSED_LENGTH] == 0:
249 # this revision is empty, we can delta against nullrev 249 # this revision is empty, we can delta against nullrev
250 rewritten_entries[rev] = (nullrev, 0, 0, COMP_MODE_PLAIN) 250 rewritten_entries[rev] = (nullrev, 0, 0, COMP_MODE_PLAIN)
251 else: 251 else:
252 252
253 text = revlog.rawdata(rev, _df=dfh) 253 text = revlog.rawdata(rev)
254 info = revlogutils.revisioninfo( 254 info = revlogutils.revisioninfo(
255 node=entry[ENTRY_NODE_ID], 255 node=entry[ENTRY_NODE_ID],
256 p1=revlog.node(entry[ENTRY_PARENT_1]), 256 p1=revlog.node(entry[ENTRY_PARENT_1]),
257 p2=revlog.node(entry[ENTRY_PARENT_2]), 257 p2=revlog.node(entry[ENTRY_PARENT_2]),
258 btext=[text], 258 btext=[text],