[Request] [+- ] D10903: censor: migrate the logic to a set of `censor_revs`
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Tue Jun 22 23:27:48 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
Instead of considering a special unique censored revision within the code, we
consider a set of revision (currently always of size 1). This make the main code
less censor-centric and prepare for the usage of a similar approach for
stripping changesets.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10903
AFFECTED FILES
mercurial/revlogutils/rewrite.py
CHANGE DETAILS
diff --git a/mercurial/revlogutils/rewrite.py b/mercurial/revlogutils/rewrite.py
--- a/mercurial/revlogutils/rewrite.py
+++ b/mercurial/revlogutils/rewrite.py
@@ -146,20 +146,22 @@
old_index = revlog.index
docket = revlog._docket
- censor_rev = revlog.rev(censornode)
+ censor_revs = {revlog.rev(censornode)}
tombstone = storageutil.packmeta({b'censored': tombstone}, b'')
- censored_entry = revlog.index[censor_rev]
- index_cutoff = revlog.index.entry_size * censor_rev
- data_cutoff = censored_entry[ENTRY_DATA_OFFSET] >> 16
- sidedata_cutoff = revlog.sidedata_cut_off(censor_rev)
+ first_excl_rev = min(censor_revs)
+
+ first_excl_entry = revlog.index[first_excl_rev]
+ index_cutoff = revlog.index.entry_size * first_excl_rev
+ data_cutoff = first_excl_entry[ENTRY_DATA_OFFSET] >> 16
+ sidedata_cutoff = revlog.sidedata_cut_off(first_excl_rev)
with pycompat.unnamedtempfile(mode=b"w+b") as tmp_storage:
# rev â (new_base, data_start, data_end, compression_mode)
rewritten_entries = _precompute_rewritten_delta(
revlog,
old_index,
- {censor_rev},
+ censor_revs,
tmp_storage,
)
@@ -182,24 +184,26 @@
) = open_files
# writing the censored revision
- _rewrite_censor(
- revlog,
- old_index,
- open_files,
- censor_rev,
- tombstone,
- )
# Writing all subsequent revisions
- for rev in range(censor_rev + 1, len(old_index)):
- _rewrite_simple(
- revlog,
- old_index,
- open_files,
- rev,
- rewritten_entries,
- tmp_storage,
- )
+ for rev in range(first_excl_rev, len(old_index)):
+ if rev in censor_revs:
+ _rewrite_censor(
+ revlog,
+ old_index,
+ open_files,
+ rev,
+ tombstone,
+ )
+ else:
+ _rewrite_simple(
+ revlog,
+ old_index,
+ open_files,
+ rev,
+ rewritten_entries,
+ tmp_storage,
+ )
docket.write(transaction=None, stripping=True)
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210622/52ba7dd5/attachment-0001.html>
More information about the Mercurial-patches
mailing list