Patchwork D10831: index: use an explicit constant for INDEX_HEADER format and use it for docket

login
register
mail settings
Submitter phabricator
Date June 2, 2021, 8:15 a.m.
Message ID <differential-rev-PHID-DREV-lhndntheuukeex2w3xdu-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49151/
State Superseded
Headers show

Comments

phabricator - June 2, 2021, 8:15 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This avoid leaking python-3.6 compatibility details too much.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlogutils/constants.py
  mercurial/revlogutils/docket.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlogutils/docket.py b/mercurial/revlogutils/docket.py
--- a/mercurial/revlogutils/docket.py
+++ b/mercurial/revlogutils/docket.py
@@ -95,9 +95,7 @@ 
 # * 8 bytes: size of data
 # * 8 bytes: pending size of data
 # * 1 bytes: default compression header
-S_HEADER = struct.Struct(
-    pycompat.sysstr(constants.INDEX_HEADER.format) + 'BBLLLLc'
-)
+S_HEADER = struct.Struct(constants.INDEX_HEADER_FMT + b'BBLLLLc')
 
 
 class RevlogDocket(object):
diff --git a/mercurial/revlogutils/constants.py b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -29,7 +29,9 @@ 
 
 ### main revlog header
 
-INDEX_HEADER = struct.Struct(b">I")
+# We cannot rely on  Struct.format is inconsistent for python <=3.6 versus above
+INDEX_HEADER_FMT = b">I"
+INDEX_HEADER = struct.Struct(INDEX_HEADER_FMT)
 
 ## revlog version
 REVLOGV0 = 0