diff mercurial/revlogutils/__init__.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 ab595920de0e
children a669404f0f4a
line wrap: on
line diff
--- a/mercurial/revlogutils/__init__.py	Sat May 22 00:06:22 2021 +0200
+++ b/mercurial/revlogutils/__init__.py	Sun May 30 16:19:36 2021 +0200
@@ -6,3 +6,11 @@
 # GNU General Public License version 2 or any later version.
 
 from __future__ import absolute_import
+
+from ..interfaces import repository
+
+
+def offset_type(offset, type):
+    if (type & ~repository.REVISION_FLAGS_KNOWN) != 0:
+        raise ValueError(b'unknown revlog index flags: %d' % type)
+    return int(int(offset) << 16 | type)