author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Mon, 05 Apr 2021 12:20:52 +0200 | |
changeset 46856 | 34e1fa4b548a |
parent 46855 | aba724bf550e |
child 46857 | cc65cea90edb |
permissions | -rw-r--r-- |
39356
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
1 |
# revlogdeltas.py - constant used for revlog logic |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
2 |
# |
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 |
39356
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
15 |
|
46855
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
16 |
### main revlog header |
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
17 |
|
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
18 |
## revlog version |
39356
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
19 |
REVLOGV0 = 0 |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
20 |
REVLOGV1 = 1 |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
21 |
# 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
|
22 |
REVLOGV2 = 0xDEAD |
46855
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
23 |
|
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
24 |
## global revlog header flags |
41202
e7a2cc84dbc0
revlog: always enable generaldelta on version 2 revlogs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40048
diff
changeset
|
25 |
# Shared across v1 and v2. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
26 |
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
|
27 |
# Only used by v1, implied by v2. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
28 |
FLAG_GENERALDELTA = 1 << 17 |
39356
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
29 |
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
|
30 |
REVLOG_DEFAULT_FORMAT = REVLOGV1 |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
31 |
REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
32 |
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
|
33 |
REVLOGV2_FLAGS = FLAG_INLINE_DATA |
39356
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
34 |
|
46855
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
35 |
### individual entry |
aba724bf550e
revlog: add some comment in the header sections
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
36 |
|
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
|
37 |
## 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
|
38 |
# 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
|
39 |
# 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
|
40 |
# 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
|
41 |
# 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
|
42 |
# 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
|
43 |
# 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
|
44 |
# 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
|
45 |
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
|
46 |
|
39356
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
47 |
# revlog index flags |
40048
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39523
diff
changeset
|
48 |
|
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39523
diff
changeset
|
49 |
# 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
|
50 |
# 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
|
51 |
|
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39523
diff
changeset
|
52 |
# 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
|
53 |
REVIDX_ISCENSORED = repository.REVISION_FLAG_CENSORED |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39523
diff
changeset
|
54 |
# 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
|
55 |
REVIDX_ELLIPSIS = repository.REVISION_FLAG_ELLIPSIS |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39523
diff
changeset
|
56 |
# revision data is stored externally |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39523
diff
changeset
|
57 |
REVIDX_EXTSTORED = repository.REVISION_FLAG_EXTSTORED |
43032
a12a9af7536c
sidedata: add a new revision flag constant for side data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42823
diff
changeset
|
58 |
# revision data contains extra metadata not part of the official digest |
a12a9af7536c
sidedata: add a new revision flag constant for side data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42823
diff
changeset
|
59 |
REVIDX_SIDEDATA = repository.REVISION_FLAG_SIDEDATA |
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
|
60 |
# 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
|
61 |
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
|
62 |
REVIDX_DEFAULT_FLAGS = 0 |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
63 |
# 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
|
64 |
REVIDX_FLAGS_ORDER = [ |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
65 |
REVIDX_ISCENSORED, |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
66 |
REVIDX_ELLIPSIS, |
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
67 |
REVIDX_EXTSTORED, |
43032
a12a9af7536c
sidedata: add a new revision flag constant for side data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42823
diff
changeset
|
68 |
REVIDX_SIDEDATA, |
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
|
69 |
REVIDX_HASCOPIESINFO, |
39356
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
70 |
] |
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
|
71 |
|
39356
729082bb9938
revlog: split constants into a new `revlogutils.constants` module
Boris Feld <boris.feld@octobus.net>
parents:
diff
changeset
|
72 |
# bitmark for flags that could cause rawdata content change |
43032
a12a9af7536c
sidedata: add a new revision flag constant for side data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42823
diff
changeset
|
73 |
REVIDX_RAWTEXT_CHANGING_FLAGS = ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
74 |
REVIDX_ISCENSORED | REVIDX_EXTSTORED | REVIDX_SIDEDATA |
43032
a12a9af7536c
sidedata: add a new revision flag constant for side data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42823
diff
changeset
|
75 |
) |
39523
b66ea3fc3a86
sparse-revlog: set max delta chain length to on thousand
Boris Feld <boris.feld@octobus.net>
parents:
39357
diff
changeset
|
76 |
|
b66ea3fc3a86
sparse-revlog: set max delta chain length to on thousand
Boris Feld <boris.feld@octobus.net>
parents:
39357
diff
changeset
|
77 |
SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000 |