[Updated] D10903: censor: migrate the logic to a set of `censor_revs`

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Thu Jul 1 10:21:33 UTC 2021


Closed by commit rHGc81a5297f185: censor: migrate the logic to a set of `censor_revs` (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10903?vs=28682&id=28714

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10903/new/

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, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210701/f82c9662/attachment-0002.html>


More information about the Mercurial-patches mailing list