mercurial/revlogutils/__init__.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sun, 30 May 2021 16:19:36 +0200
changeset 47400 ac60a1366a49
parent 44035 ab595920de0e
child 47401 a669404f0f4a
permissions -rw-r--r--
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

# mercurial.revlogutils -- basic utilities for revlog
#
# Copyright 2019 Pierre-Yves David <pierre-yves.david@octobus.net>
#
# This software may be used and distributed according to the terms of the
# 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)