Mercurial > hg
annotate mercurial/revlogutils/constants.py @ 47270:25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
We drop two unused entry. This is mostly a proof of concept before starting to
actually rework the format.
Differential Revision: https://phab.mercurial-scm.org/D10667
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 04 May 2021 11:20:10 +0200 |
parents | 921648d31553 |
children | 298d4400ea68 |
rev | line source |
---|---|
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47234
diff
changeset
|
1 # revlogdeltas.py - constant used for revlog logic. |
39329
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:
46704
diff
changeset
|
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> |
39329
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 |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
15 |
47072
4c041c71ec01
revlog: introduce an explicit tracking of what the revlog is about
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46859
diff
changeset
|
16 ### 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
|
17 |
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 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
|
19 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
|
20 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
|
21 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
|
22 |
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 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 } |
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 |
46855
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
30 ### main revlog header |
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
31 |
46859
c6e23fb4bfb4
revlog: move the "index header" struct inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46858
diff
changeset
|
32 INDEX_HEADER = struct.Struct(b">I") |
c6e23fb4bfb4
revlog: move the "index header" struct inside revlog.utils.constants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46858
diff
changeset
|
33 |
46855
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
34 ## revlog version |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
35 REVLOGV0 = 0 |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
36 REVLOGV1 = 1 |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
37 # 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
|
38 REVLOGV2 = 0xDEAD |
47266
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
39 # Dummy value until file format is finalized. |
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
40 CHANGELOGV2 = 0xD34D |
46855
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
41 |
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
42 ## global revlog header flags |
41202
e7a2cc84dbc0
revlog: always enable generaldelta on version 2 revlogs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
43 # Shared across v1 and v2. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
44 FLAG_INLINE_DATA = 1 << 16 |
41202
e7a2cc84dbc0
revlog: always enable generaldelta on version 2 revlogs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
45 # Only used by v1, implied by v2. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
46 FLAG_GENERALDELTA = 1 << 17 |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
47 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
|
48 REVLOG_DEFAULT_FORMAT = REVLOGV1 |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
49 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS |
47230
0e9105bf54cb
revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47077
diff
changeset
|
50 REVLOGV0_FLAGS = 0 |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
51 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA |
41202
e7a2cc84dbc0
revlog: always enable generaldelta on version 2 revlogs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
52 REVLOGV2_FLAGS = FLAG_INLINE_DATA |
47266
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
53 CHANGELOGV2_FLAGS = 0 |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
54 |
46855
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
55 ### individual entry |
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
56 |
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
|
57 ## 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
|
58 # 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
|
59 # 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
|
60 # 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
|
61 # 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
|
62 # 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
|
63 # 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
|
64 # 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
|
65 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
|
66 |
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
|
67 ## 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
|
68 # 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
|
69 # 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
|
70 # 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
|
71 # 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
|
72 # 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
|
73 # 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
|
74 # 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
|
75 # 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
|
76 # 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
|
77 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
|
78 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
|
79 |
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
|
80 # 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
|
81 # 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
|
82 # 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
|
83 # 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
|
84 # 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
|
85 # 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
|
86 # 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
|
87 # 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
|
88 # 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
|
89 # 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
|
90 # 4 bytes: sidedata compressed length |
47251
6bfa6c2c5f15
revlogv2: preserve the compression mode on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
91 # 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:
47249
diff
changeset
|
92 # 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:
47249
diff
changeset
|
93 INDEX_ENTRY_V2 = struct.Struct(b">Qiiiiii20s12xQiB19x") |
6bfa6c2c5f15
revlogv2: preserve the compression mode on disk
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47249
diff
changeset
|
94 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
|
95 |
47270
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
96 # 6 bytes: offset |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
97 # 2 bytes: flags |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
98 # 4 bytes: compressed length |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
99 # 4 bytes: uncompressed length |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
100 # 4 bytes: parent 1 rev |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
101 # 4 bytes: parent 2 rev |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
102 # 32 bytes: nodeid |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
103 # 8 bytes: sidedata offset |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
104 # 4 bytes: sidedata compressed length |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
105 # 1 bytes: compression mode (2 lower bit are data_compression_mode) |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
106 # 27 bytes: Padding to align to 96 bytes (see RevlogV2Plan wiki page) |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
107 INDEX_ENTRY_CL_V2 = struct.Struct(b">Qiiii20s12xQiB27x") |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
108 assert INDEX_ENTRY_CL_V2.size == 32 * 3, INDEX_ENTRY_V2.size |
25ce16bf724b
changelogv2: use a dedicated on disk format for changelogv2
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47266
diff
changeset
|
109 |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
110 # revlog index flags |
40047
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39506
diff
changeset
|
111 |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39506
diff
changeset
|
112 # 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:
39506
diff
changeset
|
113 # 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:
39506
diff
changeset
|
114 |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39506
diff
changeset
|
115 # revision has censor metadata, must be verified |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39506
diff
changeset
|
116 REVIDX_ISCENSORED = repository.REVISION_FLAG_CENSORED |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39506
diff
changeset
|
117 # revision hash does not match data (narrowhg) |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39506
diff
changeset
|
118 REVIDX_ELLIPSIS = repository.REVISION_FLAG_ELLIPSIS |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39506
diff
changeset
|
119 # revision data is stored externally |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39506
diff
changeset
|
120 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
|
121 # 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
|
122 REVIDX_HASCOPIESINFO = repository.REVISION_FLAG_HASCOPIESINFO |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
123 REVIDX_DEFAULT_FLAGS = 0 |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
124 # 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
|
125 REVIDX_FLAGS_ORDER = [ |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
126 REVIDX_ISCENSORED, |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
127 REVIDX_ELLIPSIS, |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
128 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
|
129 REVIDX_HASCOPIESINFO, |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
130 ] |
42730
92ac6b1697a7
flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41202
diff
changeset
|
131 |
39329
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
132 # bitmark for flags that could cause rawdata content change |
47077
119790e1c67c
cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents:
47072
diff
changeset
|
133 REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED |
39506
b66ea3fc3a86
sparse-revlog: set max delta chain length to on thousand
Boris Feld <boris.feld@octobus.net>
parents:
39330
diff
changeset
|
134 |
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47234
diff
changeset
|
135 ## 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:
47234
diff
changeset
|
136 # 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:
47234
diff
changeset
|
137 # for a chunk. |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47234
diff
changeset
|
138 |
47253
b876f0bf7366
revlog: introduce a plain compression mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47251
diff
changeset
|
139 # 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:
47251
diff
changeset
|
140 # chunk value. Without any header information prefixed. |
b876f0bf7366
revlog: introduce a plain compression mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47251
diff
changeset
|
141 COMP_MODE_PLAIN = 0 |
b876f0bf7366
revlog: introduce a plain compression mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47251
diff
changeset
|
142 |
47255
ff9fd7107d11
revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47253
diff
changeset
|
143 # 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:
47253
diff
changeset
|
144 # revlog docket). A header is still used. |
ff9fd7107d11
revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47253
diff
changeset
|
145 # |
ff9fd7107d11
revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47253
diff
changeset
|
146 # 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:
47253
diff
changeset
|
147 # |
ff9fd7107d11
revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47253
diff
changeset
|
148 # 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:
47253
diff
changeset
|
149 # 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:
47253
diff
changeset
|
150 # revlog v2, disallowing INLINE mode. |
ff9fd7107d11
revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47253
diff
changeset
|
151 COMP_MODE_DEFAULT = 1 |
ff9fd7107d11
revlog: implement a "default compression" mode
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47253
diff
changeset
|
152 |
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47234
diff
changeset
|
153 # 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:
47234
diff
changeset
|
154 # itself. This is the mode always used for revlog version "0" and "1" |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47234
diff
changeset
|
155 COMP_MODE_INLINE = 2 |
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47234
diff
changeset
|
156 |
47230
0e9105bf54cb
revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47077
diff
changeset
|
157 SUPPORTED_FLAGS = { |
0e9105bf54cb
revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47077
diff
changeset
|
158 REVLOGV0: REVLOGV0_FLAGS, |
0e9105bf54cb
revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47077
diff
changeset
|
159 REVLOGV1: REVLOGV1_FLAGS, |
0e9105bf54cb
revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47077
diff
changeset
|
160 REVLOGV2: REVLOGV2_FLAGS, |
47266
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
161 CHANGELOGV2: CHANGELOGV2_FLAGS, |
47230
0e9105bf54cb
revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47077
diff
changeset
|
162 } |
0e9105bf54cb
revlog: unify checks for supported flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47077
diff
changeset
|
163 |
47231
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
164 _no = lambda flags: False |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
165 _yes = lambda flags: True |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
166 |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
167 |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
168 def _from_flag(flag): |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
169 return lambda flags: bool(flags & flag) |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
170 |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
171 |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
172 FEATURES_BY_VERSION = { |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
173 REVLOGV0: { |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
174 b'inline': _no, |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
175 b'generaldelta': _no, |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
176 b'sidedata': False, |
47234
616b8f412676
revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47231
diff
changeset
|
177 b'docket': False, |
47231
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
178 }, |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
179 REVLOGV1: { |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
180 b'inline': _from_flag(FLAG_INLINE_DATA), |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
181 b'generaldelta': _from_flag(FLAG_GENERALDELTA), |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
182 b'sidedata': False, |
47234
616b8f412676
revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47231
diff
changeset
|
183 b'docket': False, |
47231
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
184 }, |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
185 REVLOGV2: { |
47234
616b8f412676
revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47231
diff
changeset
|
186 # 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:
47231
diff
changeset
|
187 # 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:
47231
diff
changeset
|
188 # means to reduce the number of files for revlogv2. |
47231
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
189 b'inline': _no, |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
190 b'generaldelta': _yes, |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
191 b'sidedata': True, |
47234
616b8f412676
revlogv2: introduce a very basic docket file
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47231
diff
changeset
|
192 b'docket': True, |
47231
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
193 }, |
47266
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
194 CHANGELOGV2: { |
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
195 b'inline': _no, |
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
196 # 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:
47255
diff
changeset
|
197 b'generaldelta': _no, |
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
198 b'sidedata': True, |
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
199 b'docket': True, |
921648d31553
changelogv2: use a dedicated version number
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47255
diff
changeset
|
200 }, |
47231
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
201 } |
4d1c893b9095
revlog: unify flag processing when loading index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47230
diff
changeset
|
202 |
47249
130c9f7ed914
revlog: add a "data compression mode" entry in the index tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47234
diff
changeset
|
203 |
39506
b66ea3fc3a86
sparse-revlog: set max delta chain length to on thousand
Boris Feld <boris.feld@octobus.net>
parents:
39330
diff
changeset
|
204 SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000 |