[Updated] D11937: rank: actually persist revision's rank in changelog-v2

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Fri Dec 17 14:01:48 UTC 2021


Closed by commit rHGc5d6c874766a: rank: actually persist revision's rank in changelog-v2 (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/D11937?vs=31503&id=31534

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

REVISION DETAIL
  https://phab.mercurial-scm.org/D11937

AFFECTED FILES
  mercurial/configitems.py
  mercurial/pure/parsers.py
  mercurial/revlogutils/constants.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/constants.py b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -192,8 +192,9 @@
 #  8 bytes: sidedata offset
 #  4 bytes: sidedata compressed length
 #  1 bytes: compression mode (2 lower bit are data_compression_mode)
-#  27 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page)
-INDEX_ENTRY_CL_V2 = struct.Struct(b">Qiiii20s12xQiB27x")
+#  4 bytes: changeset rank (i.e. `len(::REV)`)
+#  23 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page)
+INDEX_ENTRY_CL_V2 = struct.Struct(b">Qiiii20s12xQiBi23x")
 assert INDEX_ENTRY_CL_V2.size == 32 * 3, INDEX_ENTRY_CL_V2.size
 INDEX_ENTRY_V2_IDX_OFFSET = 0
 INDEX_ENTRY_V2_IDX_COMPRESSED_LENGTH = 1
@@ -204,6 +205,7 @@
 INDEX_ENTRY_V2_IDX_SIDEDATA_OFFSET = 6
 INDEX_ENTRY_V2_IDX_SIDEDATA_COMPRESSED_LENGTH = 7
 INDEX_ENTRY_V2_IDX_COMPRESSION_MODE = 8
+INDEX_ENTRY_V2_IDX_RANK = 9
 
 # revlog index flags
 
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -880,6 +880,12 @@
 class IndexChangelogV2(IndexObject2):
     index_format = revlog_constants.INDEX_ENTRY_CL_V2
 
+    null_item = (
+        IndexObject2.null_item[: revlog_constants.ENTRY_RANK]
+        + (0,)  # rank of null is 0
+        + IndexObject2.null_item[revlog_constants.ENTRY_RANK :]
+    )
+
     def _unpack_entry(self, rev, data, r=True):
         items = self.index_format.unpack(data)
         return (
@@ -898,7 +904,7 @@
             items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] & 3,
             (items[revlog_constants.INDEX_ENTRY_V2_IDX_COMPRESSION_MODE] >> 2)
             & 3,
-            revlog_constants.RANK_UNKNOWN,
+            items[revlog_constants.INDEX_ENTRY_V2_IDX_RANK],
         )
 
     def _pack_entry(self, rev, entry):
@@ -919,6 +925,7 @@
             entry[revlog_constants.ENTRY_DATA_COMPRESSION_MODE] & 3
             | (entry[revlog_constants.ENTRY_SIDEDATA_COMPRESSION_MODE] & 3)
             << 2,
+            entry[revlog_constants.ENTRY_RANK],
         )
         return self.index_format.pack(*data)
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1357,10 +1357,10 @@
 )
 # Experimental TODOs:
 #
-# * Same as for evlogv2 (but for the reduction of the number of files)
+# * Same as for revlogv2 (but for the reduction of the number of files)
+# * Actually computing the rank of changesets
 # * Improvement to investigate
 #   - storing .hgtags fnode
-#   - storing `rank` of changesets
 #   - storing branch related identifier
 
 coreconfigitem(



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/20211217/f651f333/attachment-0002.html>


More information about the Mercurial-patches mailing list