mercurial/revlogutils/constants.py
author Yuya Nishihara <yuya@tcha.org>
Sat, 15 Dec 2018 19:05:42 +0900
changeset 41003 49d48489a16b
parent 40048 8e398628a3f2
child 41202 e7a2cc84dbc0
permissions -rw-r--r--
blackbox: resurrect recursion guard If I added ui.log() to hg.repository() function, test-merge-subrepos.t exploded. The problem is that the blackbox may create new repository instance while logging is active, and the created repository owns its new ui derived from the baseui, not from the ui which is processing the active logging. I tried to work around the issue in ui.log(), but that turned out to be not easy. We shouldn't globally lock the ui.log() since there may be more than one active repo/ui instances in threaded environment. We could store the logging state in thread-local storage, but that seems unnecessarily complex. So this patch reintroduces the _inlog flag to per-repository logger instances.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     1
# revlogdeltas.py - constant used for revlog logic
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     2
#
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     3
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     4
# Copyright 2018 Octobus <contact@octobus.net>
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     5
#
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     6
# This software may be used and distributed according to the terms of the
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     7
# GNU General Public License version 2 or any later version.
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     8
"""Helper class to compute deltas stored inside revlogs"""
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     9
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    10
from __future__ import absolute_import
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    11
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    12
from .. import (
40048
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    13
    repository,
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    14
    util,
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    15
)
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    16
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    17
# revlog header flags
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    18
REVLOGV0 = 0
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    19
REVLOGV1 = 1
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    20
# Dummy value until file format is finalized.
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    21
# Reminder: change the bounds check in revlog.__init__ when this is changed.
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    22
REVLOGV2 = 0xDEAD
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    23
FLAG_INLINE_DATA = (1 << 16)
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    24
FLAG_GENERALDELTA = (1 << 17)
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    25
REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    26
REVLOG_DEFAULT_FORMAT = REVLOGV1
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    27
REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    28
REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    29
REVLOGV2_FLAGS = REVLOGV1_FLAGS
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    30
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    31
# revlog index flags
40048
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    32
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    33
# For historical reasons, revlog's internal flags were exposed via the
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    34
# wire protocol and are even exposed in parts of the storage APIs.
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    35
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    36
# revision has censor metadata, must be verified
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    37
REVIDX_ISCENSORED = repository.REVISION_FLAG_CENSORED
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    38
# revision hash does not match data (narrowhg)
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    39
REVIDX_ELLIPSIS = repository.REVISION_FLAG_ELLIPSIS
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    40
# revision data is stored externally
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
    41
REVIDX_EXTSTORED = repository.REVISION_FLAG_EXTSTORED
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    42
REVIDX_DEFAULT_FLAGS = 0
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    43
# stable order in which flags need to be processed and their processors applied
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    44
REVIDX_FLAGS_ORDER = [
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    45
    REVIDX_ISCENSORED,
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    46
    REVIDX_ELLIPSIS,
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    47
    REVIDX_EXTSTORED,
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    48
]
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    49
REVIDX_KNOWN_FLAGS = util.bitsfrom(REVIDX_FLAGS_ORDER)
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    50
# bitmark for flags that could cause rawdata content change
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    51
REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED
39523
b66ea3fc3a86 sparse-revlog: set max delta chain length to on thousand
Boris Feld <boris.feld@octobus.net>
parents: 39357
diff changeset
    52
b66ea3fc3a86 sparse-revlog: set max delta chain length to on thousand
Boris Feld <boris.feld@octobus.net>
parents: 39357
diff changeset
    53
SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000
b66ea3fc3a86 sparse-revlog: set max delta chain length to on thousand
Boris Feld <boris.feld@octobus.net>
parents: 39357
diff changeset
    54