annotate mercurial/upgrade_utils/actions.py @ 46047:4b89cf08d8dc

upgrade: split definition and management of the actions from the main code This is a second step to clarify and clean up this code. The code responsible for definition which action exist, are possible and their compatibility if moved into a sub module. This clarify the main code and prepare further cleanup. Differential Revision: https://phab.mercurial-scm.org/D9477
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 01 Dec 2020 15:11:06 +0100
parents mercurial/upgrade.py@f105c49e89cd
children f4f956342cf1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31894
9379689b6c10 upgrade: update the header comment
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31893
diff changeset
1 # upgrade.py - functions for in place upgrade of Mercurial repository
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
2 #
31895
783b4c9bd5f5 upgrade: update the copyright statement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31894
diff changeset
3 # Copyright (c) 2016-present, Gregory Szorc
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
4 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8073
diff changeset
5 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9150
diff changeset
6 # GNU General Public License version 2 or any later version.
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
7
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
8 from __future__ import absolute_import
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
9
46047
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
10 from ..i18n import _
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
11 from .. import (
31893
165428b05fca upgrade: import 'localrepo' globally
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31875
diff changeset
12 localrepo,
45372
77b8588dd84e requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45371
diff changeset
13 requirements,
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
14 util,
46046
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
15 )
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
16
46047
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
17 from ..utils import compression
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
18
42832
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
19 # list of requirements that request a clone of all revlog if added/removed
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
20 RECLONES_REQUIREMENTS = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
21 b'generaldelta',
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
22 requirements.SPARSEREVLOG_REQUIREMENT,
42832
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
23 }
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
24
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
25
31865
5dcaa0f4455b upgrade: drop the prefix to the 'requiredsourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31864
diff changeset
26 def requiredsourcerequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
27 """Obtain requirements required to be present to upgrade a repo.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
28
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
29 An upgrade will not be allowed if the repository doesn't have the
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
30 requirements returned by this function.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
31 """
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
32 return {
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
33 # Introduced in Mercurial 0.9.2.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
34 b'revlogv1',
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
35 # Introduced in Mercurial 0.9.2.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
36 b'store',
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
37 }
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
38
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
39
31866
1454726b6d7c upgrade: drop the prefix to the 'blocksourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31865
diff changeset
40 def blocksourcerequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
41 """Obtain requirements that will prevent an upgrade from occurring.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
42
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
43 An upgrade cannot be performed if the source repository contains a
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
44 requirements in the returned set.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
45 """
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
46 return {
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
47 # The upgrade code does not yet support these experimental features.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
48 # This is an artificial limitation.
45372
77b8588dd84e requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45371
diff changeset
49 requirements.TREEMANIFEST_REQUIREMENT,
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
50 # This was a precursor to generaldelta and was never enabled by default.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
51 # It should (hopefully) not exist in the wild.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
52 b'parentdelta',
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
53 # Upgrade should operate on the actual store, not the shared link.
45386
034d94f8761b requirements: introduce constants for `shared` and `relshared` requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45373
diff changeset
54 requirements.SHARED_REQUIREMENT,
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
55 }
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
56
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
57
31867
cc60b6c36637 upgrade: drop the prefix to the 'supportremovedrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31866
diff changeset
58 def supportremovedrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
59 """Obtain requirements that can be removed during an upgrade.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
60
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
61 If an upgrade were to create a repository that dropped a requirement,
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
62 the dropped requirement must appear in the returned set for the upgrade
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
63 to be allowed.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
64 """
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
65 supported = {
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
66 requirements.SPARSEREVLOG_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
67 requirements.SIDEDATA_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
68 requirements.COPIESSDC_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
69 requirements.NODEMAP_REQUIREMENT,
46003
c6a1fa42e325 upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46002
diff changeset
70 requirements.SHARESAFE_REQUIREMENT,
38720
d12415b8f833 upgrade: enable adding or removing sparse-revlog requirement
Paul Morelle <paul.morelle@octobus.net>
parents: 38719
diff changeset
71 }
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
72 for name in compression.compengines:
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
73 engine = compression.compengines[name]
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
74 if engine.available() and engine.revlogheader():
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
75 supported.add(b'exp-compression-%s' % name)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
76 if engine.name() == b'zstd':
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
77 supported.add(b'revlog-compression-zstd')
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
78 return supported
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
79
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
80
31870
49011f1cedd4 upgrade: drop the prefix to the 'supporteddestrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31869
diff changeset
81 def supporteddestrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
82 """Obtain requirements that upgrade supports in the destination.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
83
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
84 If the result of the upgrade would create requirements not in this set,
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
85 the upgrade is disallowed.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
86
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
87 Extensions should monkeypatch this to add their custom requirements.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
88 """
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
89 supported = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
90 b'dotencode',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
91 b'fncache',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
92 b'generaldelta',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
93 b'revlogv1',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
94 b'store',
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
95 requirements.SPARSEREVLOG_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
96 requirements.SIDEDATA_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
97 requirements.COPIESSDC_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
98 requirements.NODEMAP_REQUIREMENT,
45487
78f0bb37f52d upgrade: support running upgrade if repository has share-safe requirement
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45386
diff changeset
99 requirements.SHARESAFE_REQUIREMENT,
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
100 }
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
101 for name in compression.compengines:
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
102 engine = compression.compengines[name]
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
103 if engine.available() and engine.revlogheader():
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
104 supported.add(b'exp-compression-%s' % name)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
105 if engine.name() == b'zstd':
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
106 supported.add(b'revlog-compression-zstd')
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
107 return supported
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
108
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
109
31869
fe5e30b58934 upgrade: drop the prefix to the 'allowednewrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31868
diff changeset
110 def allowednewrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
111 """Obtain requirements that can be added to a repository during upgrade.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
112
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
113 This is used to disallow proposed requirements from being added when
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
114 they weren't present before.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
115
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
116 We use a list of allowed requirement additions instead of a list of known
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
117 bad additions because the whitelist approach is safer and will prevent
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
118 future, unknown requirements from accidentally being added.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
119 """
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
120 supported = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
121 b'dotencode',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
122 b'fncache',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
123 b'generaldelta',
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
124 requirements.SPARSEREVLOG_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
125 requirements.SIDEDATA_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
126 requirements.COPIESSDC_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
127 requirements.NODEMAP_REQUIREMENT,
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
128 requirements.SHARESAFE_REQUIREMENT,
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
129 }
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
130 for name in compression.compengines:
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
131 engine = compression.compengines[name]
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
132 if engine.available() and engine.revlogheader():
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
133 supported.add(b'exp-compression-%s' % name)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
134 if engine.name() == b'zstd':
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
135 supported.add(b'revlog-compression-zstd')
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
136 return supported
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
137
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
138
35302
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
139 def preservedrequirements(repo):
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
140 return set()
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
141
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
142
45993
8037d0641146 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45981
diff changeset
143 DEFICIENCY = b'deficiency'
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
144 OPTIMISATION = b'optimization'
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
145
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
146
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
147 class improvement(object):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
148 """Represents an improvement that can be made as part of an upgrade.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
149
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
150 The following attributes are defined on each instance:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
151
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
152 name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
153 Machine-readable string uniquely identifying this improvement. It
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
154 will be mapped to an action later in the upgrade process.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
155
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
156 type
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
157 Either ``DEFICIENCY`` or ``OPTIMISATION``. A deficiency is an obvious
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
158 problem. An optimization is an action (sometimes optional) that
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
159 can be taken to further improve the state of the repository.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
160
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
161 description
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
162 Message intended for humans explaining the improvement in more detail,
45993
8037d0641146 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45981
diff changeset
163 including the implications of it. For ``DEFICIENCY`` types, should be
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
164 worded in the present tense. For ``OPTIMISATION`` types, should be
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
165 worded in the future tense.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
166
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
167 upgrademessage
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
168 Message intended for humans explaining what an upgrade addressing this
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
169 issue will do. Should be worded in the future tense.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
170 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
171
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
172 def __init__(self, name, type, description, upgrademessage):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
173 self.name = name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
174 self.type = type
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
175 self.description = description
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
176 self.upgrademessage = upgrademessage
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
177
31902
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
178 def __eq__(self, other):
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
179 if not isinstance(other, improvement):
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
180 # This is what python tell use to do
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
181 return NotImplemented
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
182 return self.name == other.name
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
183
32028
99f63f476a72 upgrade: implement '__ne__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31904
diff changeset
184 def __ne__(self, other):
40997
038108a9811c upgrade: correct implementation of improvement.__ne__
Benjamin Peterson <benjamin@python.org>
parents: 40918
diff changeset
185 return not (self == other)
32028
99f63f476a72 upgrade: implement '__ne__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31904
diff changeset
186
32029
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
187 def __hash__(self):
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
188 return hash(self.name)
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
189
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
190
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
191 allformatvariant = []
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
192
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
193
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
194 def registerformatvariant(cls):
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
195 allformatvariant.append(cls)
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
196 return cls
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
197
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
198
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
199 class formatvariant(improvement):
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
200 """an improvement subclass dedicated to repository format"""
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
201
45993
8037d0641146 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45981
diff changeset
202 type = DEFICIENCY
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
203 ### The following attributes should be defined for each class:
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
204
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
205 # machine-readable string uniquely identifying this improvement. it will be
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
206 # mapped to an action later in the upgrade process.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
207 name = None
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
208
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
209 # message intended for humans explaining the improvement in more detail,
45993
8037d0641146 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45981
diff changeset
210 # including the implications of it ``DEFICIENCY`` types, should be worded
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
211 # in the present tense.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
212 description = None
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
213
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
214 # message intended for humans explaining what an upgrade addressing this
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
215 # issue will do. should be worded in the future tense.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
216 upgrademessage = None
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
217
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
218 # value of current Mercurial default for new repository
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
219 default = None
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
220
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
221 def __init__(self):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
222 raise NotImplementedError()
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
223
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
224 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
225 def fromrepo(repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
226 """current value of the variant in the repository"""
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
227 raise NotImplementedError()
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
228
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
229 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
230 def fromconfig(repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
231 """current value of the variant in the configuration"""
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
232 raise NotImplementedError()
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
233
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
234
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
235 class requirementformatvariant(formatvariant):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
236 """formatvariant based on a 'requirement' name.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
237
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
238 Many format variant are controlled by a 'requirement'. We define a small
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
239 subclass to factor the code.
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
240 """
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
241
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
242 # the requirement that control this format variant
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
243 _requirement = None
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
244
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
245 @staticmethod
39546
41aa5dced975 localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39243
diff changeset
246 def _newreporequirements(ui):
39996
dbcb466d0065 localrepo: define storage backend in creation options (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39870
diff changeset
247 return localrepo.newreporequirements(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
248 ui, localrepo.defaultcreateopts(ui)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
249 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
250
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
251 @classmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
252 def fromrepo(cls, repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
253 assert cls._requirement is not None
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
254 return cls._requirement in repo.requirements
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
255
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
256 @classmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
257 def fromconfig(cls, repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
258 assert cls._requirement is not None
39546
41aa5dced975 localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39243
diff changeset
259 return cls._requirement in cls._newreporequirements(repo.ui)
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
260
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
261
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
262 @registerformatvariant
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
263 class fncache(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
264 name = b'fncache'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
265
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
266 _requirement = b'fncache'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
267
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
268 default = True
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
269
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
270 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
271 b'long and reserved filenames may not work correctly; '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
272 b'repository performance is sub-optimal'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
273 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
274
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
275 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
276 b'repository will be more resilient to storing '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
277 b'certain paths and performance of certain '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
278 b'operations should be improved'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
279 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
280
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
281
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
282 @registerformatvariant
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
283 class dotencode(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
284 name = b'dotencode'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
285
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
286 _requirement = b'dotencode'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
287
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
288 default = True
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
289
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
290 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
291 b'storage of filenames beginning with a period or '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
292 b'space may not work correctly'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
293 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
294
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
295 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
296 b'repository will be better able to store files '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
297 b'beginning with a space or period'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
298 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
299
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
300
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
301 @registerformatvariant
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
302 class generaldelta(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
303 name = b'generaldelta'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
304
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
305 _requirement = b'generaldelta'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
306
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
307 default = True
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
308
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
309 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
310 b'deltas within internal storage are unable to '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
311 b'choose optimal revisions; repository is larger and '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
312 b'slower than it could be; interaction with other '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
313 b'repositories may require extra network and CPU '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
314 b'resources, making "hg push" and "hg pull" slower'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
315 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
316
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
317 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
318 b'repository storage will be able to create '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
319 b'optimal deltas; new repository data will be '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
320 b'smaller and read times should decrease; '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
321 b'interacting with other repositories using this '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
322 b'storage model should require less network and '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
323 b'CPU resources, making "hg push" and "hg pull" '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
324 b'faster'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
325 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
326
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
327
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
328 @registerformatvariant
46047
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
329 class sharesafe(requirementformatvariant):
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
330 name = b'exp-sharesafe'
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
331 _requirement = requirements.SHARESAFE_REQUIREMENT
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
332
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
333 default = False
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
334
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
335 description = _(
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
336 b'old shared repositories do not share source repository '
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
337 b'requirements and config. This leads to various problems '
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
338 b'when the source repository format is upgraded or some new '
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
339 b'extensions are enabled.'
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
340 )
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
341
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
342 upgrademessage = _(
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
343 b'Upgrades a repository to share-safe format so that future '
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
344 b'shares of this repository share its requirements and configs.'
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
345 )
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
346
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
347
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
348 @registerformatvariant
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
349 class sparserevlog(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
350 name = b'sparserevlog'
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
351
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
352 _requirement = requirements.SPARSEREVLOG_REQUIREMENT
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
353
40918
3764330f76a6 sparse-revlog: enabled by default
Boris Feld <boris.feld@octobus.net>
parents: 40837
diff changeset
354 default = True
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
355
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
356 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
357 b'in order to limit disk reading and memory usage on older '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
358 b'version, the span of a delta chain from its root to its '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
359 b'end is limited, whatever the relevant data in this span. '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
360 b'This can severly limit Mercurial ability to build good '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
361 b'chain of delta resulting is much more storage space being '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
362 b'taken and limit reusability of on disk delta during '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
363 b'exchange.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
364 )
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
365
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
366 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
367 b'Revlog supports delta chain with more unused data '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
368 b'between payload. These gaps will be skipped at read '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
369 b'time. This allows for better delta chains, making a '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
370 b'better compression and faster exchange with server.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
371 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
372
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
373
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
374 @registerformatvariant
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
375 class sidedata(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
376 name = b'sidedata'
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
377
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
378 _requirement = requirements.SIDEDATA_REQUIREMENT
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
379
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
380 default = False
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
381
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
382 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
383 b'Allows storage of extra data alongside a revision, '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
384 b'unlocking various caching options.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
385 )
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
386
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
387 upgrademessage = _(b'Allows storage of extra data alongside a revision.')
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
388
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
389
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
390 @registerformatvariant
44799
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
391 class persistentnodemap(requirementformatvariant):
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
392 name = b'persistent-nodemap'
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
393
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
394 _requirement = requirements.NODEMAP_REQUIREMENT
44799
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
395
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
396 default = False
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
397
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
398 description = _(
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
399 b'persist the node -> rev mapping on disk to speedup lookup'
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
400 )
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
401
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
402 upgrademessage = _(b'Speedup revision lookup by node id.')
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
403
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
404
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
405 @registerformatvariant
43138
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
406 class copiessdc(requirementformatvariant):
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
407 name = b'copies-sdc'
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
408
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
409 _requirement = requirements.COPIESSDC_REQUIREMENT
43138
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
410
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
411 default = False
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
412
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
413 description = _(b'Stores copies information alongside changesets.')
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
414
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
415 upgrademessage = _(
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
416 b'Allows to use more efficient algorithm to deal with ' b'copy tracing.'
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
417 )
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
418
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
419
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
420 @registerformatvariant
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
421 class removecldeltachain(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
422 name = b'plain-cl-delta'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
423
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
424 default = True
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
425
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
426 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
427 b'changelog storage is using deltas instead of '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
428 b'raw entries; changelog reading and any '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
429 b'operation relying on changelog data are slower '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
430 b'than they could be'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
431 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
432
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
433 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
434 b'changelog storage will be reformated to '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
435 b'store raw entries; changelog reading will be '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
436 b'faster; changelog size may be reduced'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
437 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
438
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
439 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
440 def fromrepo(repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
441 # Mercurial 4.0 changed changelogs to not use delta chains. Search for
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
442 # changelogs with deltas.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
443 cl = repo.changelog
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
444 chainbase = cl.chainbase
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
445 return all(rev == chainbase(rev) for rev in cl)
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
446
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
447 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
448 def fromconfig(repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
449 return True
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
450
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
451
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
452 @registerformatvariant
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
453 class compressionengine(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
454 name = b'compression'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
455 default = b'zlib'
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
456
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
457 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
458 b'Compresion algorithm used to compress data. '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
459 b'Some engine are faster than other'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
460 )
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
461
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
462 upgrademessage = _(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43089
diff changeset
463 b'revlog content will be recompressed with the new algorithm.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
464 )
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
465
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
466 @classmethod
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
467 def fromrepo(cls, repo):
42136
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
468 # we allow multiple compression engine requirement to co-exist because
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
469 # strickly speaking, revlog seems to support mixed compression style.
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
470 #
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
471 # The compression used for new entries will be "the last one"
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
472 compression = b'zlib'
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
473 for req in repo.requirements:
42136
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
474 prefix = req.startswith
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
475 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
476 compression = req.split(b'-', 2)[2]
42136
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
477 return compression
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
478
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
479 @classmethod
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
480 def fromconfig(cls, repo):
44382
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
481 compengines = repo.ui.configlist(b'format', b'revlog-compression')
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
482 # return the first valid value as the selection code would do
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
483 for comp in compengines:
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
484 if comp in util.compengines:
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
485 return comp
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
486
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
487 # no valide compression found lets display it all for clarity
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
488 return b','.join(compengines)
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
489
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
490
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
491 @registerformatvariant
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
492 class compressionlevel(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
493 name = b'compression-level'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
494 default = b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
495
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
496 description = _(b'compression level')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
497
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
498 upgrademessage = _(b'revlog content will be recompressed')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
499
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
500 @classmethod
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
501 def fromrepo(cls, repo):
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
502 comp = compressionengine.fromrepo(repo)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
503 level = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
504 if comp == b'zlib':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
505 level = repo.ui.configint(b'storage', b'revlog.zlib.level')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
506 elif comp == b'zstd':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
507 level = repo.ui.configint(b'storage', b'revlog.zstd.level')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
508 if level is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
509 return b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
510 return bytes(level)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
511
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
512 @classmethod
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
513 def fromconfig(cls, repo):
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
514 comp = compressionengine.fromconfig(repo)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
515 level = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
516 if comp == b'zlib':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
517 level = repo.ui.configint(b'storage', b'revlog.zlib.level')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
518 elif comp == b'zstd':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
519 level = repo.ui.configint(b'storage', b'revlog.zstd.level')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
520 if level is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
521 return b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
522 return bytes(level)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
523
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
524
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
525 def finddeficiencies(repo):
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
526 """returns a list of deficiencies that the repo suffer from"""
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
527 deficiencies = []
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
528
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
529 # We could detect lack of revlogv1 and store here, but they were added
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
530 # in 0.9.2 and we don't support upgrading repos without these
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
531 # requirements, so let's not bother.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
532
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
533 for fv in allformatvariant:
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
534 if not fv.fromrepo(repo):
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
535 deficiencies.append(fv)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
536
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
537 return deficiencies
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
538
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
539
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
540 ALL_OPTIMISATIONS = []
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
541
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
542
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
543 def register_optimization(obj):
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
544 ALL_OPTIMISATIONS.append(obj)
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
545 return obj
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
546
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
547
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
548 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
549 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
550 name=b're-delta-parent',
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
551 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
552 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
553 b'deltas within internal storage will be recalculated to '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
554 b'choose an optimal base revision where this was not '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
555 b'already done; the size of the repository may shrink and '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
556 b'various operations may become faster; the first time '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
557 b'this optimization is performed could slow down upgrade '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
558 b'execution considerably; subsequent invocations should '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
559 b'not run noticeably slower'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
560 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
561 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
562 b'deltas within internal storage will choose a new '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
563 b'base revision if needed'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
564 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
565 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
566 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
567
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
568 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
569 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
570 name=b're-delta-multibase',
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
571 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
572 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
573 b'deltas within internal storage will be recalculated '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
574 b'against multiple base revision and the smallest '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
575 b'difference will be used; the size of the repository may '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
576 b'shrink significantly when there are many merges; this '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
577 b'optimization will slow down execution in proportion to '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
578 b'the number of merges in the repository and the amount '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
579 b'of files in the repository; this slow down should not '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
580 b'be significant unless there are tens of thousands of '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
581 b'files and thousands of merges'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
582 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
583 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
584 b'deltas within internal storage will choose an '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
585 b'optimal delta by computing deltas against multiple '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
586 b'parents; may slow down execution time '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
587 b'significantly'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
588 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
589 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
590 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
591
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
592 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
593 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
594 name=b're-delta-all',
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
595 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
596 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
597 b'deltas within internal storage will always be '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
598 b'recalculated without reusing prior deltas; this will '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
599 b'likely make execution run several times slower; this '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
600 b'optimization is typically not needed'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
601 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
602 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
603 b'deltas within internal storage will be fully '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
604 b'recomputed; this will likely drastically slow down '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
605 b'execution time'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
606 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
607 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
608 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
609
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
610 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
611 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
612 name=b're-delta-fulladd',
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
613 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
614 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
615 b'every revision will be re-added as if it was new '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
616 b'content. It will go through the full storage '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
617 b'mechanism giving extensions a chance to process it '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
618 b'(eg. lfs). This is similar to "re-delta-all" but even '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
619 b'slower since more logic is involved.'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
620 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
621 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
622 b'each revision will be added as new content to the '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
623 b'internal storage; this will likely drastically slow '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
624 b'down execution time, but some extensions might need '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
625 b'it'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
626 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
627 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
628 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
629
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
630
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
631 def findoptimizations(repo):
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
632 """Determine optimisation that could be used during upgrade"""
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
633 # These are unconditionally added. There is logic later that figures out
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
634 # which ones to apply.
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
635 return list(ALL_OPTIMISATIONS)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
636
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
637
31900
0f0d7005b9ad upgrade: simplify 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31899
diff changeset
638 def determineactions(repo, deficiencies, sourcereqs, destreqs):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
639 """Determine upgrade actions that will be performed.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
640
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
641 Given a list of improvements as returned by ``finddeficiencies`` and
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
642 ``findoptimizations``, determine the list of upgrade actions that
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
643 will be performed.
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
644
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
645 The role of this function is to filter improvements if needed, apply
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
646 recommended optimizations from the improvements list that make sense,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
647 etc.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
648
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
649 Returns a list of action names.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
650 """
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
651 newactions = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
652
31900
0f0d7005b9ad upgrade: simplify 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31899
diff changeset
653 for d in deficiencies:
44746
c36a3fcfc36b upgrade: properly filter action depending on planned work
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44452
diff changeset
654 name = d._requirement
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
655
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
656 # If the action is a requirement that doesn't show up in the
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
657 # destination requirements, prune the action.
44746
c36a3fcfc36b upgrade: properly filter action depending on planned work
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44452
diff changeset
658 if name is not None and name not in destreqs:
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
659 continue
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
660
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
661 newactions.append(d)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
662
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
663 # FUTURE consider adding some optimizations here for certain transitions.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
664 # e.g. adding generaldelta could schedule parent redeltas.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
665
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
666 return newactions