changeset 47377:298d4400ea68

index: use an explicit constant for INDEX_HEADER format and use it for docket This avoid leaking python-3.6 compatibility details too much. Differential Revision: https://phab.mercurial-scm.org/D10831
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 03 Jun 2021 16:12:03 +0200
parents ab5fd39cb402
children 9e6e12e1a87e
files mercurial/revlogutils/constants.py mercurial/revlogutils/docket.py
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/constants.py	Tue Jun 01 09:18:27 2021 +0200
+++ b/mercurial/revlogutils/constants.py	Thu Jun 03 16:12:03 2021 +0200
@@ -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
--- a/mercurial/revlogutils/docket.py	Tue Jun 01 09:18:27 2021 +0200
+++ b/mercurial/revlogutils/docket.py	Thu Jun 03 16:12:03 2021 +0200
@@ -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):