##// END OF EJS Templates
censor: migrate the logic to a set of `censor_revs`...
marmoute -
r48264:c81a5297 default
parent child Browse files
Show More
@@ -146,20 +146,22 b' def v2_censor(revlog, tr, censornode, to'
146 old_index = revlog.index
146 old_index = revlog.index
147 docket = revlog._docket
147 docket = revlog._docket
148
148
149 censor_rev = revlog.rev(censornode)
149 censor_revs = {revlog.rev(censornode)}
150 tombstone = storageutil.packmeta({b'censored': tombstone}, b'')
150 tombstone = storageutil.packmeta({b'censored': tombstone}, b'')
151
151
152 censored_entry = revlog.index[censor_rev]
152 first_excl_rev = min(censor_revs)
153 index_cutoff = revlog.index.entry_size * censor_rev
153
154 data_cutoff = censored_entry[ENTRY_DATA_OFFSET] >> 16
154 first_excl_entry = revlog.index[first_excl_rev]
155 sidedata_cutoff = revlog.sidedata_cut_off(censor_rev)
155 index_cutoff = revlog.index.entry_size * first_excl_rev
156 data_cutoff = first_excl_entry[ENTRY_DATA_OFFSET] >> 16
157 sidedata_cutoff = revlog.sidedata_cut_off(first_excl_rev)
156
158
157 with pycompat.unnamedtempfile(mode=b"w+b") as tmp_storage:
159 with pycompat.unnamedtempfile(mode=b"w+b") as tmp_storage:
158 # rev β†’ (new_base, data_start, data_end, compression_mode)
160 # rev β†’ (new_base, data_start, data_end, compression_mode)
159 rewritten_entries = _precompute_rewritten_delta(
161 rewritten_entries = _precompute_rewritten_delta(
160 revlog,
162 revlog,
161 old_index,
163 old_index,
162 {censor_rev},
164 censor_revs,
163 tmp_storage,
165 tmp_storage,
164 )
166 )
165
167
@@ -182,24 +184,26 b' def v2_censor(revlog, tr, censornode, to'
182 ) = open_files
184 ) = open_files
183
185
184 # writing the censored revision
186 # writing the censored revision
185 _rewrite_censor(
186 revlog,
187 old_index,
188 open_files,
189 censor_rev,
190 tombstone,
191 )
192
187
193 # Writing all subsequent revisions
188 # Writing all subsequent revisions
194 for rev in range(censor_rev + 1, len(old_index)):
189 for rev in range(first_excl_rev, len(old_index)):
195 _rewrite_simple(
190 if rev in censor_revs:
196 revlog,
191 _rewrite_censor(
197 old_index,
192 revlog,
198 open_files,
193 old_index,
199 rev,
194 open_files,
200 rewritten_entries,
195 rev,
201 tmp_storage,
196 tombstone,
202 )
197 )
198 else:
199 _rewrite_simple(
200 revlog,
201 old_index,
202 open_files,
203 rev,
204 rewritten_entries,
205 tmp_storage,
206 )
203 docket.write(transaction=None, stripping=True)
207 docket.write(transaction=None, stripping=True)
204
208
205
209
General Comments 0
You need to be logged in to leave comments. Login now