annotate mercurial/revlogutils/__init__.py @ 52292:085cc409847d

sslutil: bump the default minimum TLS version of the client to 1.2 (BC) TLS v1.0 and v1.1 are deprecated by RFC8996[1]: These versions lack support for current and recommended cryptographic algorithms and mechanisms, and various government and industry profiles of applications using TLS now mandate avoiding these old TLS versions. TLS version 1.2 became the recommended version for IETF protocols in 2008 (subsequently being obsoleted by TLS version 1.3 in 2018)... Various browsers have disabled or removed it[2][3][4], as have various internet services, and Windows 11 has it disabled by default[5]. We should move on too. (We should also bump it on the server side, as this config only affects clients not allowing a server to negotiate down. But the only server-side config is a `devel` option to pick exactly one protocol version and is commented as a footgun, so I'm hesitant to touch that. See 7dec5e441bf7 for details, which states that using `hg serve` directly isn't expected for a web service.) I'm not knowledgeable enough in this area to know if we should follow up with disabling certain ciphers too. But this should provide better security on its own. [1] https://datatracker.ietf.org/doc/rfc8996/ [2] https://learn.microsoft.com/en-us/DeployEdge/microsoft-edge-policies#sslversionmin [3] https://hacks.mozilla.org/2020/02/its-the-boot-for-tls-1-0-and-tls-1-1/ [4] https://security.googleblog.com/2018/10/modernizing-transport-security.html [5] https://techcommunity.microsoft.com/blog/windows-itpro-blog/tls-1-0-and-tls-1-1-soon-to-be-disabled-in-windows/3887947
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 11 Nov 2024 21:25:03 -0500
parents f4733654f144
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43524
a7c0c5b5a50f revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39329
diff changeset
1 # mercurial.revlogutils -- basic utilities for revlog
a7c0c5b5a50f revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39329
diff changeset
2 #
a7c0c5b5a50f revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39329
diff changeset
3 # Copyright 2019 Pierre-Yves David <pierre-yves.david@octobus.net>
a7c0c5b5a50f revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39329
diff changeset
4 #
a7c0c5b5a50f revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39329
diff changeset
5 # This software may be used and distributed according to the terms of the
a7c0c5b5a50f revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39329
diff changeset
6 # GNU General Public License version 2 or any later version.
a7c0c5b5a50f revlog: introduce an explicit NodeMap class for pure code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 39329
diff changeset
7
51863
f4733654f144 typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51729
diff changeset
8 from __future__ import annotations
47394
ac60a1366a49 revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44034
diff changeset
9
51729
278af66e6595 typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents: 51329
diff changeset
10 import typing
278af66e6595 typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents: 51329
diff changeset
11
47399
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
12 from ..thirdparty import attr
51729
278af66e6595 typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents: 51329
diff changeset
13
278af66e6595 typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents: 51329
diff changeset
14 # Force pytype to use the non-vendored package
278af66e6595 typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents: 51329
diff changeset
15 if typing.TYPE_CHECKING:
278af66e6595 typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents: 51329
diff changeset
16 # noinspection PyPackageRequirements
278af66e6595 typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents: 51329
diff changeset
17 import attr
278af66e6595 typing: induce pytype to use the standard `attr` instead of the vendored copy
Matt Harbison <matt_harbison@yahoo.com>
parents: 51329
diff changeset
18
47394
ac60a1366a49 revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44034
diff changeset
19 from ..interfaces import repository
ac60a1366a49 revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44034
diff changeset
20
47395
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
21 # See mercurial.revlogutils.constants for doc
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
22 COMP_MODE_INLINE = 2
48499
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47399
diff changeset
23 RANK_UNKNOWN = -1
47395
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
24
47394
ac60a1366a49 revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44034
diff changeset
25
ac60a1366a49 revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44034
diff changeset
26 def offset_type(offset, type):
ac60a1366a49 revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44034
diff changeset
27 if (type & ~repository.REVISION_FLAGS_KNOWN) != 0:
ac60a1366a49 revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44034
diff changeset
28 raise ValueError(b'unknown revlog index flags: %d' % type)
ac60a1366a49 revlog: move `offset_type` to `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44034
diff changeset
29 return int(int(offset) << 16 | type)
47395
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
30
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
31
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
32 def entry(
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
33 data_offset,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
34 data_compressed_length,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
35 data_delta_base,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
36 link_rev,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
37 parent_rev_1,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
38 parent_rev_2,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
39 node_id,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
40 flags=0,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
41 data_uncompressed_length=-1,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
42 data_compression_mode=COMP_MODE_INLINE,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
43 sidedata_offset=0,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
44 sidedata_compressed_length=0,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
45 sidedata_compression_mode=COMP_MODE_INLINE,
48499
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47399
diff changeset
46 rank=RANK_UNKNOWN,
47395
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
47 ):
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
48 """Build one entry from symbolic name
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
49
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
50 This is useful to abstract the actual detail of how we build the entry
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
51 tuple for caller who don't care about it.
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
52
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
53 This should always be called using keyword arguments. Some arguments have
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
54 default value, this match the value used by index version that does not store such data.
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
55 """
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
56 return (
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
57 offset_type(data_offset, flags),
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
58 data_compressed_length,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
59 data_uncompressed_length,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
60 data_delta_base,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
61 link_rev,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
62 parent_rev_1,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
63 parent_rev_2,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
64 node_id,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
65 sidedata_offset,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
66 sidedata_compressed_length,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
67 data_compression_mode,
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
68 sidedata_compression_mode,
48499
52034c42c09d rank: add a "rank" value to the revlog-entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47399
diff changeset
69 rank,
47395
a669404f0f4a revlog: add a function to build index entry tuple
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47394
diff changeset
70 )
47399
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
71
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
72
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
73 @attr.s(slots=True, frozen=True)
48946
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
74 class revisioninfo:
47399
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
75 """Information about a revision that allows building its fulltext
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
76 node: expected hash of the revision
51329
398a105b16a0 delta-find: clarify that revisioninfo.p1/p2 constains nodeid
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49677
diff changeset
77 p1, p2: parent revs of the revision (as node)
47399
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
78 btext: built text cache consisting of a one-element list
49677
05db41701ece find-delta: pass the cache-delta usage policy alongside the cache-delta
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48946
diff changeset
79 cachedelta: (baserev, uncompressed_delta, usage_mode) or None
47399
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
80 flags: flags associated to the revision storage
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
81
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
82 One of btext[0] or cachedelta must be set.
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
83 """
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
84
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
85 node = attr.ib()
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
86 p1 = attr.ib()
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
87 p2 = attr.ib()
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
88 btext = attr.ib()
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
89 textlen = attr.ib()
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
90 cachedelta = attr.ib()
34cc102c73f5 revlog: move `revisioninfo` in `revlogutils`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47395
diff changeset
91 flags = attr.ib()