Patchwork D11937: rank: actually persist revision's rank in changelog-v2

login
register
mail settings
Submitter phabricator
Date Dec. 16, 2021, 5:44 p.m.
Message ID <differential-rev-PHID-DREV-2o7yprdyj6gwp4axssy5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50263/
State New
Headers show

Comments

phabricator - Dec. 16, 2021, 5:44 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The changelog v2 format is now persisting whatever "rank" value is recorded.
  However keep in mind that for we do not record any value.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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(