annotate mercurial/revlogutils/constants.py @ 48813:2bb75c65fa6c stable

ci: use the `v1.0` flavor of the docker images in the CI This new versioning will help us to maintain backward compatibility in the docker image. This will be useful to deal with mismatch between default/stable in version and the re-run CI on older changesets in the future. Once this changeset land on stable, we will have to merge it in default. Then we can start make backward incompatible changes in a new image version. Differential Revision: https://phab.mercurial-scm.org/D12388
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 18 Mar 2022 18:09:46 +0100
parents c5d6c874766a
children 6000f5b25c9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47260
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
1 # revlogdeltas.py - constant used for revlog logic.
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
2 #
46819
d4ba4d51f85f contributor: change mentions of mpm to olivia
Rapha?l Gom?s <rgomes@octobus.net>
parents: 46717
diff changeset
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
39356
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
46856
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
12 import struct
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
13
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
14 from ..interfaces import repository
47401
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47399
diff changeset
15 from .. import revlogutils
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
16
47089
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
17 ### Internal utily constants
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
18
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
19 KIND_CHANGELOG = 1001 # over 256 to not be comparable with a bytes
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
20 KIND_MANIFESTLOG = 1002
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
21 KIND_FILELOG = 1003
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
22 KIND_OTHER = 1004
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
23
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
24 ALL_KINDS = {
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
25 KIND_CHANGELOG,
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
26 KIND_MANIFESTLOG,
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
27 KIND_FILELOG,
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
28 KIND_OTHER,
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
29 }
4c041c71ec01 revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46859
diff changeset
30
47399
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
31 ### Index entry key
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
32 #
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
33 #
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
34 # Internal details
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
35 # ----------------
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
36 #
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
37 # A large part of the revlog logic deals with revisions' "index entries", tuple
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
38 # objects that contains the same "items" whatever the revlog version.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
39 # Different versions will have different ways of storing these items (sometimes
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
40 # not having them at all), but the tuple will always be the same. New fields
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
41 # are usually added at the end to avoid breaking existing code that relies
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
42 # on the existing order. The field are defined as follows:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
43
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
44 # [0] offset:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
45 # The byte index of the start of revision data chunk.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
46 # That value is shifted up by 16 bits. use "offset = field >> 16" to
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
47 # retrieve it.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
48 #
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
49 # flags:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
50 # A flag field that carries special information or changes the behavior
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
51 # of the revision. (see `REVIDX_*` constants for details)
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
52 # The flag field only occupies the first 16 bits of this field,
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
53 # use "flags = field & 0xFFFF" to retrieve the value.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
54 ENTRY_DATA_OFFSET = 0
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
55
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
56 # [1] compressed length:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
57 # The size, in bytes, of the chunk on disk
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
58 ENTRY_DATA_COMPRESSED_LENGTH = 1
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
59
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
60 # [2] uncompressed length:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
61 # The size, in bytes, of the full revision once reconstructed.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
62 ENTRY_DATA_UNCOMPRESSED_LENGTH = 2
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
63
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
64 # [3] base rev:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
65 # Either the base of the revision delta chain (without general
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
66 # delta), or the base of the delta (stored in the data chunk)
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
67 # with general delta.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
68 ENTRY_DELTA_BASE = 3
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
69
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
70 # [4] link rev:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
71 # Changelog revision number of the changeset introducing this
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
72 # revision.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
73 ENTRY_LINK_REV = 4
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
74
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
75 # [5] parent 1 rev:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
76 # Revision number of the first parent
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
77 ENTRY_PARENT_1 = 5
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
78
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
79 # [6] parent 2 rev:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
80 # Revision number of the second parent
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
81 ENTRY_PARENT_2 = 6
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
82
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
83 # [7] node id:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
84 # The node id of the current revision
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
85 ENTRY_NODE_ID = 7
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
86
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
87 # [8] sidedata offset:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
88 # The byte index of the start of the revision's side-data chunk.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
89 ENTRY_SIDEDATA_OFFSET = 8
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
90
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
91 # [9] sidedata chunk length:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
92 # The size, in bytes, of the revision's side-data chunk.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
93 ENTRY_SIDEDATA_COMPRESSED_LENGTH = 9
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
94
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
95 # [10] data compression mode:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
96 # two bits that detail the way the data chunk is compressed on disk.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
97 # (see "COMP_MODE_*" constants for details). For revlog version 0 and
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
98 # 1 this will always be COMP_MODE_INLINE.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
99 ENTRY_DATA_COMPRESSION_MODE = 10
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
100
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
101 # [11] side-data compression mode:
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
102 # two bits that detail the way the sidedata chunk is compressed on disk.
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
103 # (see "COMP_MODE_*" constants for details)
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
104 ENTRY_SIDEDATA_COMPRESSION_MODE = 11
7a0ec25d5836 revlog: move entry documentation alongside new related constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47377
diff changeset
105
48536
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
106 # [12] Revision rank:
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
107 # The number of revision under this one.
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
108 #
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
109 # Formally this is defined as : rank(X) = len(ancestors(X) + X)
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
110 #
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
111 # If rank == -1; then we do not have this information available.
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
112 # Only `null` has a rank of 0.
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
113 ENTRY_RANK = 12
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
114
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
115 RANK_UNKNOWN = -1
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48535
diff changeset
116
46855
aba724bf550e revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46819
diff changeset
117 ### main revlog header
aba724bf550e revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46819
diff changeset
118
47377
298d4400ea68 index: use an explicit constant for INDEX_HEADER format and use it for docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47281
diff changeset
119 # We cannot rely on Struct.format is inconsistent for python <=3.6 versus above
298d4400ea68 index: use an explicit constant for INDEX_HEADER format and use it for docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47281
diff changeset
120 INDEX_HEADER_FMT = b">I"
298d4400ea68 index: use an explicit constant for INDEX_HEADER format and use it for docket
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47281
diff changeset
121 INDEX_HEADER = struct.Struct(INDEX_HEADER_FMT)
46859
c6e23fb4bfb4 revlog: move the "index header" struct inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46858
diff changeset
122
46855
aba724bf550e revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46819
diff changeset
123 ## revlog version
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
124 REVLOGV0 = 0
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
125 REVLOGV1 = 1
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
126 # 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
127 REVLOGV2 = 0xDEAD
47277
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
128 # Dummy value until file format is finalized.
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
129 CHANGELOGV2 = 0xD34D
46855
aba724bf550e revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46819
diff changeset
130
aba724bf550e revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46819
diff changeset
131 ## global revlog header flags
41202
e7a2cc84dbc0 revlog: always enable generaldelta on version 2 revlogs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40048
diff changeset
132 # Shared across v1 and v2.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
133 FLAG_INLINE_DATA = 1 << 16
41202
e7a2cc84dbc0 revlog: always enable generaldelta on version 2 revlogs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40048
diff changeset
134 # Only used by v1, implied by v2.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
135 FLAG_GENERALDELTA = 1 << 17
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
136 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
137 REVLOG_DEFAULT_FORMAT = REVLOGV1
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
138 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
47241
0e9105bf54cb revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47094
diff changeset
139 REVLOGV0_FLAGS = 0
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
140 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
41202
e7a2cc84dbc0 revlog: always enable generaldelta on version 2 revlogs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40048
diff changeset
141 REVLOGV2_FLAGS = FLAG_INLINE_DATA
47277
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
142 CHANGELOGV2_FLAGS = 0
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
143
46855
aba724bf550e revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46819
diff changeset
144 ### individual entry
aba724bf550e revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46819
diff changeset
145
46856
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
146 ## index v0:
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
147 # 4 bytes: offset
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
148 # 4 bytes: compressed length
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
149 # 4 bytes: base rev
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
150 # 4 bytes: link rev
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
151 # 20 bytes: parent 1 nodeid
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
152 # 20 bytes: parent 2 nodeid
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
153 # 20 bytes: nodeid
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
154 INDEX_ENTRY_V0 = struct.Struct(b">4l20s20s20s")
34e1fa4b548a revlog: move the details of revlog "v0" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46855
diff changeset
155
46857
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
156 ## index v1
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
157 # 6 bytes: offset
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
158 # 2 bytes: flags
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
159 # 4 bytes: compressed length
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
160 # 4 bytes: uncompressed length
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
161 # 4 bytes: base rev
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
162 # 4 bytes: link rev
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
163 # 4 bytes: parent 1 rev
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
164 # 4 bytes: parent 2 rev
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
165 # 32 bytes: nodeid
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
166 INDEX_ENTRY_V1 = struct.Struct(b">Qiiiiii20s12x")
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
167 assert INDEX_ENTRY_V1.size == 32 * 2
cc65cea90edb revlog: move the details of revlog "v1" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46856
diff changeset
168
46858
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
169 # 6 bytes: offset
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
170 # 2 bytes: flags
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
171 # 4 bytes: compressed length
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
172 # 4 bytes: uncompressed length
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
173 # 4 bytes: base rev
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
174 # 4 bytes: link rev
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
175 # 4 bytes: parent 1 rev
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
176 # 4 bytes: parent 2 rev
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
177 # 32 bytes: nodeid
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
178 # 8 bytes: sidedata offset
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
179 # 4 bytes: sidedata compressed length
47262
6bfa6c2c5f15 revlogv2: preserve the compression mode on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47260
diff changeset
180 # 1 bytes: compression mode (2 lower bit are data_compression_mode)
6bfa6c2c5f15 revlogv2: preserve the compression mode on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47260
diff changeset
181 # 19 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page)
6bfa6c2c5f15 revlogv2: preserve the compression mode on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47260
diff changeset
182 INDEX_ENTRY_V2 = struct.Struct(b">Qiiiiii20s12xQiB19x")
6bfa6c2c5f15 revlogv2: preserve the compression mode on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47260
diff changeset
183 assert INDEX_ENTRY_V2.size == 32 * 3, INDEX_ENTRY_V2.size
46858
85e3a630cad9 revlog: move the details of revlog "v2" index inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46857
diff changeset
184
47281
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
185 # 6 bytes: offset
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
186 # 2 bytes: flags
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
187 # 4 bytes: compressed length
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
188 # 4 bytes: uncompressed length
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
189 # 4 bytes: parent 1 rev
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
190 # 4 bytes: parent 2 rev
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
191 # 32 bytes: nodeid
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
192 # 8 bytes: sidedata offset
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
193 # 4 bytes: sidedata compressed length
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
194 # 1 bytes: compression mode (2 lower bit are data_compression_mode)
48537
c5d6c874766a rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48536
diff changeset
195 # 4 bytes: changeset rank (i.e. `len(::REV)`)
c5d6c874766a rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48536
diff changeset
196 # 23 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page)
c5d6c874766a rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48536
diff changeset
197 INDEX_ENTRY_CL_V2 = struct.Struct(b">Qiiii20s12xQiBi23x")
48535
d5137c00ab17 changelog-v2: fix an assertion error to display the right data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48534
diff changeset
198 assert INDEX_ENTRY_CL_V2.size == 32 * 3, INDEX_ENTRY_CL_V2.size
48534
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
199 INDEX_ENTRY_V2_IDX_OFFSET = 0
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
200 INDEX_ENTRY_V2_IDX_COMPRESSED_LENGTH = 1
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
201 INDEX_ENTRY_V2_IDX_UNCOMPRESSED_LENGTH = 2
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
202 INDEX_ENTRY_V2_IDX_PARENT_1 = 3
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
203 INDEX_ENTRY_V2_IDX_PARENT_2 = 4
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
204 INDEX_ENTRY_V2_IDX_NODEID = 5
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
205 INDEX_ENTRY_V2_IDX_SIDEDATA_OFFSET = 6
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
206 INDEX_ENTRY_V2_IDX_SIDEDATA_COMPRESSED_LENGTH = 7
2c6084f67a86 changelog-v2: use helper constant in the code to pack/unpack entries
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47401
diff changeset
207 INDEX_ENTRY_V2_IDX_COMPRESSION_MODE = 8
48537
c5d6c874766a rank: actually persist revision's rank in changelog-v2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48536
diff changeset
208 INDEX_ENTRY_V2_IDX_RANK = 9
47281
25ce16bf724b changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47277
diff changeset
209
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
210 # revlog index flags
40048
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
211
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
212 # 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
213 # 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
214
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
215 # 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
216 REVIDX_ISCENSORED = repository.REVISION_FLAG_CENSORED
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
217 # 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
218 REVIDX_ELLIPSIS = repository.REVISION_FLAG_ELLIPSIS
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
219 # revision data is stored externally
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39523
diff changeset
220 REVIDX_EXTSTORED = repository.REVISION_FLAG_EXTSTORED
45671
2d6aea053153 copies: add a HASCOPIESINFO flag to highlight rev with useful data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
221 # revision changes files in a way that could affect copy tracing.
2d6aea053153 copies: add a HASCOPIESINFO flag to highlight rev with useful data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
222 REVIDX_HASCOPIESINFO = repository.REVISION_FLAG_HASCOPIESINFO
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
223 REVIDX_DEFAULT_FLAGS = 0
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
224 # 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
225 REVIDX_FLAGS_ORDER = [
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
226 REVIDX_ISCENSORED,
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
227 REVIDX_ELLIPSIS,
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
228 REVIDX_EXTSTORED,
45671
2d6aea053153 copies: add a HASCOPIESINFO flag to highlight rev with useful data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
229 REVIDX_HASCOPIESINFO,
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
230 ]
42747
92ac6b1697a7 flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41202
diff changeset
231
39356
729082bb9938 revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
232 # bitmark for flags that could cause rawdata content change
47094
119790e1c67c cg4: introduce protocol flag to signify the presence of sidedata
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47089
diff changeset
233 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
234
47260
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
235 ## chunk compression mode constants:
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
236 # These constants are used in revlog version >=2 to denote the compression used
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
237 # for a chunk.
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
238
47264
b876f0bf7366 revlog: introduce a plain compression mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47262
diff changeset
239 # Chunk use no compression, the data stored on disk can be directly use as
b876f0bf7366 revlog: introduce a plain compression mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47262
diff changeset
240 # chunk value. Without any header information prefixed.
b876f0bf7366 revlog: introduce a plain compression mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47262
diff changeset
241 COMP_MODE_PLAIN = 0
b876f0bf7366 revlog: introduce a plain compression mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47262
diff changeset
242
47266
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
243 # Chunk use the "default compression" for the revlog (usually defined in the
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
244 # revlog docket). A header is still used.
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
245 #
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
246 # XXX: keeping a header is probably not useful and we should probably drop it.
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
247 #
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
248 # XXX: The value of allow mixed type of compression in the revlog is unclear
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
249 # and we should consider making PLAIN/DEFAULT the only available mode for
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
250 # revlog v2, disallowing INLINE mode.
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
251 COMP_MODE_DEFAULT = 1
ff9fd7107d11 revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47264
diff changeset
252
47260
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
253 # Chunk use a compression mode stored "inline" at the start of the chunk
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
254 # itself. This is the mode always used for revlog version "0" and "1"
47401
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47399
diff changeset
255 COMP_MODE_INLINE = revlogutils.COMP_MODE_INLINE
47260
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
256
47241
0e9105bf54cb revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47094
diff changeset
257 SUPPORTED_FLAGS = {
0e9105bf54cb revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47094
diff changeset
258 REVLOGV0: REVLOGV0_FLAGS,
0e9105bf54cb revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47094
diff changeset
259 REVLOGV1: REVLOGV1_FLAGS,
0e9105bf54cb revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47094
diff changeset
260 REVLOGV2: REVLOGV2_FLAGS,
47277
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
261 CHANGELOGV2: CHANGELOGV2_FLAGS,
47241
0e9105bf54cb revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47094
diff changeset
262 }
0e9105bf54cb revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47094
diff changeset
263
47242
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
264 _no = lambda flags: False
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
265 _yes = lambda flags: True
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
266
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
267
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
268 def _from_flag(flag):
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
269 return lambda flags: bool(flags & flag)
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
270
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
271
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
272 FEATURES_BY_VERSION = {
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
273 REVLOGV0: {
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
274 b'inline': _no,
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
275 b'generaldelta': _no,
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
276 b'sidedata': False,
47245
616b8f412676 revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47242
diff changeset
277 b'docket': False,
47242
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
278 },
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
279 REVLOGV1: {
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
280 b'inline': _from_flag(FLAG_INLINE_DATA),
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
281 b'generaldelta': _from_flag(FLAG_GENERALDELTA),
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
282 b'sidedata': False,
47245
616b8f412676 revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47242
diff changeset
283 b'docket': False,
47242
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
284 },
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
285 REVLOGV2: {
47245
616b8f412676 revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47242
diff changeset
286 # The point of inline-revlog is to reduce the number of files used in
616b8f412676 revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47242
diff changeset
287 # the store. Using a docket defeat this purpose. So we needs other
616b8f412676 revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47242
diff changeset
288 # means to reduce the number of files for revlogv2.
47242
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
289 b'inline': _no,
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
290 b'generaldelta': _yes,
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
291 b'sidedata': True,
47245
616b8f412676 revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47242
diff changeset
292 b'docket': True,
47242
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
293 },
47277
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
294 CHANGELOGV2: {
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
295 b'inline': _no,
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
296 # General delta is useless for changelog since we don't do any delta
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
297 b'generaldelta': _no,
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
298 b'sidedata': True,
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
299 b'docket': True,
921648d31553 changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47266
diff changeset
300 },
47242
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
301 }
4d1c893b9095 revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47241
diff changeset
302
47260
130c9f7ed914 revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47245
diff changeset
303
39523
b66ea3fc3a86 sparse-revlog: set max delta chain length to on thousand
Boris Feld <boris.feld@octobus.net>
parents: 39357
diff changeset
304 SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000