diff mercurial/revlogutils/revlogv0.py @ 47394:ac60a1366a49

revlog: move `offset_type` to `revlogutils` This multiple module are using this so it make sense to move it at the utility level. Differential Revision: https://phab.mercurial-scm.org/D10792
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 30 May 2021 16:19:36 +0200
parents 9d1a8829f959
children 8f87dcb46f53
line wrap: on
line diff
--- a/mercurial/revlogutils/revlogv0.py	Sat May 22 00:06:22 2021 +0200
+++ b/mercurial/revlogutils/revlogv0.py	Sun May 30 16:19:36 2021 +0200
@@ -18,6 +18,7 @@
     error,
     node,
     pycompat,
+    revlogutils,
     util,
 )
 
@@ -35,12 +36,6 @@
     return int(q & 0xFFFF)
 
 
-def offset_type(offset, type):
-    if (type & ~flagutil.REVIDX_KNOWN_FLAGS) != 0:
-        raise ValueError(b'unknown revlog index flags')
-    return int(int(offset) << 16 | type)
-
-
 class revlogoldindex(list):
     rust_ext_compat = 0
     entry_size = INDEX_ENTRY_V0.size
@@ -143,7 +138,7 @@
         e = INDEX_ENTRY_V0.unpack(cur)
         # transform to revlogv1 format
         e2 = (
-            offset_type(e[0], 0),
+            revlogutils.offset_type(e[0], 0),
             e[1],
             -1,
             e[2],