annotate mercurial/upgrade_utils/actions.py @ 46626:ee91966aec0f

requirements: add constant for revlog v1 requirement Since this series is adding a new requirement, we might as well clean up while we're here. Differential Revision: https://phab.mercurial-scm.org/D10105
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 03 Mar 2021 14:00:45 +0100
parents 60ea95471b83
children f4c325bf80fc
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 (
46048
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
12 error,
31893
165428b05fca upgrade: import 'localrepo' globally
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31875
diff changeset
13 localrepo,
45372
77b8588dd84e requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45371
diff changeset
14 requirements,
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
15 revlog,
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
16 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
17 )
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
18
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
19 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
20
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
21 # 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
22 RECLONES_REQUIREMENTS = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
23 b'generaldelta',
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
24 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
25 }
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
26
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
27
35302
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
28 def preservedrequirements(repo):
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
29 return set()
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
30
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
31
46206
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
32 FORMAT_VARIANT = b'deficiency'
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
33 OPTIMISATION = b'optimization'
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
34
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
35
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
36 class improvement(object):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
37 """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
38
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
39 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
40
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
41 name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
42 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
43 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
44
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
45 type
46206
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
46 Either ``FORMAT_VARIANT`` or ``OPTIMISATION``.
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
47 A format variant is where we change the storage format. Not all format
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
48 variant changes are an obvious problem.
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
49 An optimization is an action (sometimes optional) that
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
50 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
51
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
52 description
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
53 Message intended for humans explaining the improvement in more detail,
46206
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
54 including the implications of it. For ``FORMAT_VARIANT`` types, should be
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
55 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
56 worded in the future tense.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
57
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
58 upgrademessage
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
59 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
60 issue will do. Should be worded in the future tense.
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
61
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
62 postupgrademessage
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
63 Message intended for humans which will be shown post an upgrade
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
64 operation when the improvement will be added
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
65
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
66 postdowngrademessage
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
67 Message intended for humans which will be shown post an upgrade
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
68 operation in which this improvement was removed
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
69
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
70 touches_filelogs (bool)
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
71 Whether this improvement touches filelogs
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
72
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
73 touches_manifests (bool)
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
74 Whether this improvement touches manifests
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
75
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
76 touches_changelog (bool)
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
77 Whether this improvement touches changelog
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
78
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
79 touches_requirements (bool)
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
80 Whether this improvement changes repository requirements
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
81 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
82
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
83 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
84 self.name = name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
85 self.type = type
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
86 self.description = description
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
87 self.upgrademessage = upgrademessage
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
88 self.postupgrademessage = None
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
89 self.postdowngrademessage = None
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
90 # By default for now, we assume every improvement touches
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
91 # all the things
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
92 self.touches_filelogs = True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
93 self.touches_manifests = True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
94 self.touches_changelog = True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
95 self.touches_requirements = True
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
96
31902
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
97 def __eq__(self, other):
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
98 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
99 # 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
100 return NotImplemented
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
101 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
102
32028
99f63f476a72 upgrade: implement '__ne__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31904
diff changeset
103 def __ne__(self, other):
40997
038108a9811c upgrade: correct implementation of improvement.__ne__
Benjamin Peterson <benjamin@python.org>
parents: 40918
diff changeset
104 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
105
32029
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
106 def __hash__(self):
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
107 return hash(self.name)
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
108
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
109
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
110 allformatvariant = []
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
111
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
112
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
113 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
114 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
115 return cls
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
116
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
117
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
118 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
119 """an improvement subclass dedicated to repository format"""
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
120
46206
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
121 type = FORMAT_VARIANT
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
122 ### 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
123
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
124 # 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
125 # 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
126 name = None
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
127
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
128 # message intended for humans explaining the improvement in more detail,
46206
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
129 # including the implications of it ``FORMAT_VARIANT`` types, should be
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
130 # 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
131 # 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
132 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
133
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
134 # 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
135 # 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
136 upgrademessage = None
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
137
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
138 # 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
139 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
140
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
141 # Message intended for humans which will be shown post an upgrade
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
142 # operation when the improvement will be added
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
143 postupgrademessage = None
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
144
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
145 # Message intended for humans which will be shown post an upgrade
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
146 # operation in which this improvement was removed
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
147 postdowngrademessage = None
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
148
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
149 # By default for now, we assume every improvement touches all the things
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
150 touches_filelogs = True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
151 touches_manifests = True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
152 touches_changelog = True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
153 touches_requirements = True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
154
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
155 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
156 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
157
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
158 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
159 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
160 """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
161 raise NotImplementedError()
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
162
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
163 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
164 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
165 """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
166 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
167
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
168
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
169 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
170 """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
171
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
172 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
173 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
174 """
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
175
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
176 # 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
177 _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
178
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
179 @staticmethod
39546
41aa5dced975 localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39243
diff changeset
180 def _newreporequirements(ui):
39996
dbcb466d0065 localrepo: define storage backend in creation options (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39870
diff changeset
181 return localrepo.newreporequirements(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
182 ui, localrepo.defaultcreateopts(ui)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
183 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
184
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
185 @classmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
186 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
187 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
188 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
189
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
190 @classmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
191 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
192 assert cls._requirement is not None
39546
41aa5dced975 localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39243
diff changeset
193 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
194
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
195
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
196 @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
197 class fncache(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
198 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
199
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
200 _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
201
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
202 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
203
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
204 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
205 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
206 b'repository performance is sub-optimal'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
207 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
208
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
209 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
210 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
211 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
212 b'operations should be improved'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
213 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
214
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
215
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
216 @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
217 class dotencode(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
218 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
219
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
220 _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
221
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
222 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
223
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
224 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
225 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
226 b'space may not work correctly'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
227 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
228
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
229 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
230 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
231 b'beginning with a space or period'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
232 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
233
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
234
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
235 @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
236 class generaldelta(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
237 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
238
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
239 _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
240
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
241 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
242
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
243 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
244 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
245 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
246 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
247 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
248 b'resources, making "hg push" and "hg pull" slower'
43076
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
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
251 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
252 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
253 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
254 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
255 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
256 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
257 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
258 b'faster'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
259 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
260
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
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
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
263 class sharesafe(requirementformatvariant):
46334
4b0192f592cf share: move share safe functionality out of experimental
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46230
diff changeset
264 name = b'share-safe'
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
265 _requirement = requirements.SHARESAFE_REQUIREMENT
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
266
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
267 default = False
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
268
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
269 description = _(
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
270 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
271 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
272 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
273 b'extensions are enabled.'
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
274 )
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
275
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
276 upgrademessage = _(
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
277 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
278 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
279 )
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
280
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
281 postdowngrademessage = _(
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
282 b'repository downgraded to not use share safe mode, '
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
283 b'existing shares will not work and needs to'
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
284 b' be reshared.'
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
285 )
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
286
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
287 postupgrademessage = _(
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
288 b'repository upgraded to share safe mode, existing'
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
289 b' shares will still work in old non-safe mode. '
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
290 b'Re-share existing shares to use them in safe mode'
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
291 b' New shares will be created in safe mode.'
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
292 )
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
293
46377
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
294 # upgrade only needs to change the requirements
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
295 touches_filelogs = False
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
296 touches_manifests = False
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
297 touches_changelog = False
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
298 touches_requirements = True
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
299
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
300
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
301 @registerformatvariant
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
302 class sparserevlog(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
303 name = b'sparserevlog'
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
304
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
305 _requirement = requirements.SPARSEREVLOG_REQUIREMENT
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
306
40918
3764330f76a6 sparse-revlog: enabled by default
Boris Feld <boris.feld@octobus.net>
parents: 40837
diff changeset
307 default = True
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
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'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
311 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
312 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
313 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
314 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
315 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
316 b'exchange.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
317 )
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
318
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
319 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
320 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
321 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
322 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
323 b'better compression and faster exchange with server.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
324 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
325
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
326
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
327 @registerformatvariant
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
328 class sidedata(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
329 name = b'sidedata'
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
330
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
331 _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
332
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
333 default = False
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
334
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
335 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
336 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
337 b'unlocking various caching options.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
338 )
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
339
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
340 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
341
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
342
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
343 @registerformatvariant
44799
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
344 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
345 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
346
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
347 _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
348
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
349 default = False
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
350
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
351 description = _(
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
352 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
353 )
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
354
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
355 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
356
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
357
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
358 @registerformatvariant
43138
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
359 class copiessdc(requirementformatvariant):
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
360 name = b'copies-sdc'
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
361
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
362 _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
363
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
364 default = False
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
365
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
366 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
367
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
368 upgrademessage = _(
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
369 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
370 )
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
371
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
372
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
373 @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
374 class removecldeltachain(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
375 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
376
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
377 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
378
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
379 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
380 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
381 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
382 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
383 b'than they could be'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
384 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
385
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
386 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
387 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
388 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
389 b'faster; changelog size may be reduced'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
390 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
391
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
392 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
393 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
394 # 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
395 # 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
396 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
397 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
398 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
399
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
400 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
401 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
402 return True
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
403
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
404
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
405 @registerformatvariant
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
406 class compressionengine(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
407 name = b'compression'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
408 default = b'zlib'
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
409
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
410 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
411 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
412 b'Some engine are faster than other'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
413 )
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
414
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
415 upgrademessage = _(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43089
diff changeset
416 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
417 )
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
418
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
419 @classmethod
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
420 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
421 # 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
422 # 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
423 #
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
424 # 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
425 compression = b'zlib'
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
426 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
427 prefix = req.startswith
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
428 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
429 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
430 return compression
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
431
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
432 @classmethod
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
433 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
434 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
435 # 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
436 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
437 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
438 return comp
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
439
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
440 # 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
441 return b','.join(compengines)
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
442
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
443
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
444 @registerformatvariant
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
445 class compressionlevel(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
446 name = b'compression-level'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
447 default = b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
448
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
449 description = _(b'compression level')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
450
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
451 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
452
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
453 @classmethod
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
454 def fromrepo(cls, repo):
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
455 comp = compressionengine.fromrepo(repo)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
456 level = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
457 if comp == b'zlib':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
458 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
459 elif comp == b'zstd':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
460 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
461 if level is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
462 return b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
463 return bytes(level)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
464
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
465 @classmethod
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
466 def fromconfig(cls, repo):
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
467 comp = compressionengine.fromconfig(repo)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
468 level = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
469 if comp == b'zlib':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
470 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
471 elif comp == b'zstd':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
472 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
473 if level is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
474 return b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
475 return bytes(level)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
476
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
477
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
478 def find_format_upgrades(repo):
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
479 """returns a list of format upgrades which can be perform on the repo"""
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
480 upgrades = []
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
481
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
482 # 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
483 # 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
484 # requirements, so let's not bother.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
485
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
486 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
487 if not fv.fromrepo(repo):
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
488 upgrades.append(fv)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
489
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
490 return upgrades
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
491
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
492
46212
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
493 def find_format_downgrades(repo):
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
494 """returns a list of format downgrades which will be performed on the repo
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
495 because of disabled config option for them"""
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
496
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
497 downgrades = []
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
498
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
499 for fv in allformatvariant:
46230
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
500 if fv.name == b'compression':
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
501 # If there is a compression change between repository
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
502 # and config, destination repository compression will change
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
503 # and current compression will be removed.
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
504 if fv.fromrepo(repo) != fv.fromconfig(repo):
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
505 downgrades.append(fv)
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
506 continue
46212
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
507 # format variant exist in repo but does not exist in new repository
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
508 # config
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
509 if fv.fromrepo(repo) and not fv.fromconfig(repo):
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
510 downgrades.append(fv)
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
511
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
512 return downgrades
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
513
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
514
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
515 ALL_OPTIMISATIONS = []
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
516
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
517
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
518 def register_optimization(obj):
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
519 ALL_OPTIMISATIONS.append(obj)
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
520 return obj
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
521
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
522
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
523 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
524 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
525 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
526 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
527 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
528 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
529 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
530 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
531 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
532 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
533 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
534 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
535 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
536 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
537 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
538 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
539 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
540 )
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 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
544 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
545 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
546 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
547 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
548 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
549 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
550 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
551 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
552 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
553 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
554 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
555 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
556 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
557 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
558 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
559 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
560 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
561 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
562 b'significantly'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
563 ),
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 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
568 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
569 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
570 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
571 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
572 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
573 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
574 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
575 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
576 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
577 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
578 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
579 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
580 b'execution time'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
581 ),
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 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
584
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
585 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
586 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
587 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
588 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
589 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
590 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
591 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
592 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
593 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
594 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
595 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
596 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
597 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
598 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
599 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
600 b'it'
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 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
603 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
604
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
605
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
606 def findoptimizations(repo):
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
607 """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
608 # 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
609 # 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
610 return list(ALL_OPTIMISATIONS)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
611
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
612
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
613 def determine_upgrade_actions(
46209
a51d345f1404 upgrade: move optimization addition to determineactions()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46206
diff changeset
614 repo, format_upgrades, optimizations, sourcereqs, destreqs
a51d345f1404 upgrade: move optimization addition to determineactions()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46206
diff changeset
615 ):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
616 """Determine upgrade actions that will be performed.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
617
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
618 Given a list of improvements as returned by ``find_format_upgrades`` and
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
619 ``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
620 will be performed.
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
621
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
622 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
623 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
624 etc.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
625
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
626 Returns a list of action names.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
627 """
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
628 newactions = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
629
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
630 for d in format_upgrades:
44746
c36a3fcfc36b upgrade: properly filter action depending on planned work
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44452
diff changeset
631 name = d._requirement
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
632
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
633 # 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
634 # 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
635 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
636 continue
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
637
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
638 newactions.append(d)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
639
46209
a51d345f1404 upgrade: move optimization addition to determineactions()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46206
diff changeset
640 newactions.extend(o for o in sorted(optimizations) if o not in newactions)
a51d345f1404 upgrade: move optimization addition to determineactions()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46206
diff changeset
641
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
642 # 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
643 # 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
644
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
645 return newactions
46048
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
646
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
647
46056
c407513a44a3 upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46052
diff changeset
648 class UpgradeOperation(object):
c407513a44a3 upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46052
diff changeset
649 """represent the work to be done during an upgrade"""
c407513a44a3 upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46052
diff changeset
650
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
651 def __init__(
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
652 self,
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
653 ui,
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
654 new_requirements,
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
655 current_requirements,
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
656 upgrade_actions,
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
657 removed_actions,
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
658 revlogs_to_process,
46375
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46334
diff changeset
659 backup_store,
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
660 ):
46188
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
661 self.ui = ui
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
662 self.new_requirements = new_requirements
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
663 self.current_requirements = current_requirements
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
664 # list of upgrade actions the operation will perform
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
665 self.upgrade_actions = upgrade_actions
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
666 self._upgrade_actions_names = set([a.name for a in upgrade_actions])
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
667 self.removed_actions = removed_actions
46056
c407513a44a3 upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46052
diff changeset
668 self.revlogs_to_process = revlogs_to_process
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
669 # requirements which will be added by the operation
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
670 self._added_requirements = (
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
671 self.new_requirements - self.current_requirements
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
672 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
673 # requirements which will be removed by the operation
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
674 self._removed_requirements = (
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
675 self.current_requirements - self.new_requirements
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
676 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
677 # requirements which will be preserved by the operation
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
678 self._preserved_requirements = (
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
679 self.current_requirements & self.new_requirements
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
680 )
46192
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
681 # optimizations which are not used and it's recommended that they
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
682 # should use them
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
683 all_optimizations = findoptimizations(None)
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
684 self.unused_optimizations = [
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
685 i for i in all_optimizations if i not in self.upgrade_actions
46192
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
686 ]
46056
c407513a44a3 upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46052
diff changeset
687
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
688 # delta reuse mode of this upgrade operation
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
689 self.delta_reuse_mode = revlog.revlog.DELTAREUSEALWAYS
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
690 if b're-delta-all' in self._upgrade_actions_names:
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
691 self.delta_reuse_mode = revlog.revlog.DELTAREUSENEVER
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
692 elif b're-delta-parent' in self._upgrade_actions_names:
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
693 self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
694 elif b're-delta-multibase' in self._upgrade_actions_names:
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
695 self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
696 elif b're-delta-fulladd' in self._upgrade_actions_names:
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
697 self.delta_reuse_mode = revlog.revlog.DELTAREUSEFULLADD
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
698
46218
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
699 # should this operation force re-delta of both parents
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
700 self.force_re_delta_both_parents = (
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
701 b're-delta-multibase' in self._upgrade_actions_names
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
702 )
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
703
46375
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46334
diff changeset
704 # should this operation create a backup of the store
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46334
diff changeset
705 self.backup_store = backup_store
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46334
diff changeset
706
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
707 # whether the operation touches different revlogs at all or not
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
708 self.touches_filelogs = self._touches_filelogs()
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
709 self.touches_manifests = self._touches_manifests()
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
710 self.touches_changelog = self._touches_changelog()
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
711 # whether the operation touches requirements file or not
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
712 self.touches_requirements = self._touches_requirements()
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
713 self.touches_store = (
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
714 self.touches_filelogs
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
715 or self.touches_manifests
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
716 or self.touches_changelog
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
717 )
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
718 # does the operation only touches repository requirement
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
719 self.requirements_only = (
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
720 self.touches_requirements and not self.touches_store
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
721 )
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
722
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
723 def _touches_filelogs(self):
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
724 for a in self.upgrade_actions:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
725 # in optimisations, we re-process the revlogs again
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
726 if a.type == OPTIMISATION:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
727 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
728 elif a.touches_filelogs:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
729 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
730 for a in self.removed_actions:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
731 if a.touches_filelogs:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
732 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
733 return False
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
734
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
735 def _touches_manifests(self):
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
736 for a in self.upgrade_actions:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
737 # in optimisations, we re-process the revlogs again
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
738 if a.type == OPTIMISATION:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
739 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
740 elif a.touches_manifests:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
741 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
742 for a in self.removed_actions:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
743 if a.touches_manifests:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
744 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
745 return False
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
746
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
747 def _touches_changelog(self):
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
748 for a in self.upgrade_actions:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
749 # in optimisations, we re-process the revlogs again
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
750 if a.type == OPTIMISATION:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
751 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
752 elif a.touches_changelog:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
753 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
754 for a in self.removed_actions:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
755 if a.touches_changelog:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
756 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
757 return False
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
758
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
759 def _touches_requirements(self):
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
760 for a in self.upgrade_actions:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
761 # optimisations are used to re-process revlogs and does not result
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
762 # in a requirement being added or removed
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
763 if a.type == OPTIMISATION:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
764 pass
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
765 elif a.touches_requirements:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
766 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
767 for a in self.removed_actions:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
768 if a.touches_requirements:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
769 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
770
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
771 return False
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
772
46190
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
773 def _write_labeled(self, l, label):
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
774 """
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
775 Utility function to aid writing of a list under one label
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
776 """
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
777 first = True
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
778 for r in sorted(l):
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
779 if not first:
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
780 self.ui.write(b', ')
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
781 self.ui.write(r, label=label)
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
782 first = False
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
783
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
784 def print_requirements(self):
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
785 self.ui.write(_(b'requirements\n'))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
786 self.ui.write(_(b' preserved: '))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
787 self._write_labeled(
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
788 self._preserved_requirements, "upgrade-repo.requirement.preserved"
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
789 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
790 self.ui.write((b'\n'))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
791 if self._removed_requirements:
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
792 self.ui.write(_(b' removed: '))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
793 self._write_labeled(
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
794 self._removed_requirements, "upgrade-repo.requirement.removed"
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
795 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
796 self.ui.write((b'\n'))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
797 if self._added_requirements:
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
798 self.ui.write(_(b' added: '))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
799 self._write_labeled(
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
800 self._added_requirements, "upgrade-repo.requirement.added"
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
801 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
802 self.ui.write((b'\n'))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
803 self.ui.write(b'\n')
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
804
46190
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
805 def print_optimisations(self):
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
806 optimisations = [
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
807 a for a in self.upgrade_actions if a.type == OPTIMISATION
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
808 ]
46190
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
809 optimisations.sort(key=lambda a: a.name)
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
810 if optimisations:
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
811 self.ui.write(_(b'optimisations: '))
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
812 self._write_labeled(
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
813 [a.name for a in optimisations],
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
814 "upgrade-repo.optimisation.performed",
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
815 )
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
816 self.ui.write(b'\n\n')
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
817
46189
dfddcbb0c244 upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46188
diff changeset
818 def print_upgrade_actions(self):
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
819 for a in self.upgrade_actions:
46189
dfddcbb0c244 upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46188
diff changeset
820 self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage))
dfddcbb0c244 upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46188
diff changeset
821
46188
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
822 def print_affected_revlogs(self):
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
823 if not self.revlogs_to_process:
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
824 self.ui.write((b'no revlogs to process\n'))
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
825 else:
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
826 self.ui.write((b'processed revlogs:\n'))
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
827 for r in sorted(self.revlogs_to_process):
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
828 self.ui.write((b' - %s\n' % r))
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
829 self.ui.write((b'\n'))
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
830
46192
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
831 def print_unused_optimizations(self):
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
832 for i in self.unused_optimizations:
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
833 self.ui.status(_(b'%s\n %s\n\n') % (i.name, i.description))
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
834
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
835 def has_upgrade_action(self, name):
46189
dfddcbb0c244 upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46188
diff changeset
836 """ Check whether the upgrade operation will perform this action """
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
837 return name in self._upgrade_actions_names
46189
dfddcbb0c244 upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46188
diff changeset
838
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
839 def print_post_op_messages(self):
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
840 """ print post upgrade operation warning messages """
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
841 for a in self.upgrade_actions:
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
842 if a.postupgrademessage is not None:
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
843 self.ui.warn(b'%s\n' % a.postupgrademessage)
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
844 for a in self.removed_actions:
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
845 if a.postdowngrademessage is not None:
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
846 self.ui.warn(b'%s\n' % a.postdowngrademessage)
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
847
46056
c407513a44a3 upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46052
diff changeset
848
46049
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
849 ### Code checking if a repository can got through the upgrade process at all. #
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
850
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
851
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
852 def requiredsourcerequirements(repo):
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
853 """Obtain requirements required to be present to upgrade a repo.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
854
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
855 An upgrade will not be allowed if the repository doesn't have the
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
856 requirements returned by this function.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
857 """
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
858 return {
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
859 # Introduced in Mercurial 0.9.2.
46626
ee91966aec0f requirements: add constant for revlog v1 requirement
Raphaël Gomès <rgomes@octobus.net>
parents: 46377
diff changeset
860 requirements.REVLOGV1_REQUIREMENT,
46049
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
861 # Introduced in Mercurial 0.9.2.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
862 b'store',
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
863 }
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
864
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
865
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
866 def blocksourcerequirements(repo):
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
867 """Obtain requirements that will prevent an upgrade from occurring.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
868
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
869 An upgrade cannot be performed if the source repository contains a
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
870 requirements in the returned set.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
871 """
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
872 return {
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
873 # The upgrade code does not yet support these experimental features.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
874 # This is an artificial limitation.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
875 requirements.TREEMANIFEST_REQUIREMENT,
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
876 # This was a precursor to generaldelta and was never enabled by default.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
877 # It should (hopefully) not exist in the wild.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
878 b'parentdelta',
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
879 # Upgrade should operate on the actual store, not the shared link.
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
880 requirements.SHARED_REQUIREMENT,
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
881 }
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
882
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
883
46048
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
884 def check_source_requirements(repo):
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
885 """Ensure that no existing requirements prevent the repository upgrade"""
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
886
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
887 required = requiredsourcerequirements(repo)
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
888 missingreqs = required - repo.requirements
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
889 if missingreqs:
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
890 msg = _(b'cannot upgrade repository; requirement missing: %s')
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
891 missingreqs = b', '.join(sorted(missingreqs))
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
892 raise error.Abort(msg % missingreqs)
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
893
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
894 blocking = blocksourcerequirements(repo)
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
895 blockingreqs = blocking & repo.requirements
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
896 if blockingreqs:
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
897 m = _(b'cannot upgrade repository; unsupported source requirement: %s')
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
898 blockingreqs = b', '.join(sorted(blockingreqs))
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
899 raise error.Abort(m % blockingreqs)
46051
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
900
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
901
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
902 ### Verify the validity of the planned requirement changes ####################
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
903
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
904
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
905 def supportremovedrequirements(repo):
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
906 """Obtain requirements that can be removed during an upgrade.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
907
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
908 If an upgrade were to create a repository that dropped a requirement,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
909 the dropped requirement must appear in the returned set for the upgrade
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
910 to be allowed.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
911 """
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
912 supported = {
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
913 requirements.SPARSEREVLOG_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
914 requirements.SIDEDATA_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
915 requirements.COPIESSDC_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
916 requirements.NODEMAP_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
917 requirements.SHARESAFE_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
918 }
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
919 for name in compression.compengines:
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
920 engine = compression.compengines[name]
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
921 if engine.available() and engine.revlogheader():
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
922 supported.add(b'exp-compression-%s' % name)
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
923 if engine.name() == b'zstd':
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
924 supported.add(b'revlog-compression-zstd')
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
925 return supported
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
926
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
927
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
928 def supporteddestrequirements(repo):
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
929 """Obtain requirements that upgrade supports in the destination.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
930
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
931 If the result of the upgrade would create requirements not in this set,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
932 the upgrade is disallowed.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
933
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
934 Extensions should monkeypatch this to add their custom requirements.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
935 """
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
936 supported = {
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
937 b'dotencode',
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
938 b'fncache',
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
939 b'generaldelta',
46626
ee91966aec0f requirements: add constant for revlog v1 requirement
Raphaël Gomès <rgomes@octobus.net>
parents: 46377
diff changeset
940 requirements.REVLOGV1_REQUIREMENT,
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
941 b'store',
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
942 requirements.SPARSEREVLOG_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
943 requirements.SIDEDATA_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
944 requirements.COPIESSDC_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
945 requirements.NODEMAP_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
946 requirements.SHARESAFE_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
947 }
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
948 for name in compression.compengines:
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
949 engine = compression.compengines[name]
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
950 if engine.available() and engine.revlogheader():
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
951 supported.add(b'exp-compression-%s' % name)
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
952 if engine.name() == b'zstd':
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
953 supported.add(b'revlog-compression-zstd')
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
954 return supported
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
955
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
956
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
957 def allowednewrequirements(repo):
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
958 """Obtain requirements that can be added to a repository during upgrade.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
959
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
960 This is used to disallow proposed requirements from being added when
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
961 they weren't present before.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
962
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
963 We use a list of allowed requirement additions instead of a list of known
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
964 bad additions because the whitelist approach is safer and will prevent
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
965 future, unknown requirements from accidentally being added.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
966 """
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
967 supported = {
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
968 b'dotencode',
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
969 b'fncache',
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
970 b'generaldelta',
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
971 requirements.SPARSEREVLOG_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
972 requirements.SIDEDATA_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
973 requirements.COPIESSDC_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
974 requirements.NODEMAP_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
975 requirements.SHARESAFE_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
976 }
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
977 for name in compression.compengines:
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
978 engine = compression.compengines[name]
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
979 if engine.available() and engine.revlogheader():
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
980 supported.add(b'exp-compression-%s' % name)
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
981 if engine.name() == b'zstd':
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
982 supported.add(b'revlog-compression-zstd')
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
983 return supported
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
984
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
985
46051
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
986 def check_requirements_changes(repo, new_reqs):
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
987 old_reqs = repo.requirements
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
988
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
989 support_removal = supportremovedrequirements(repo)
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
990 no_remove_reqs = old_reqs - new_reqs - support_removal
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
991 if no_remove_reqs:
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
992 msg = _(b'cannot upgrade repository; requirement would be removed: %s')
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
993 no_remove_reqs = b', '.join(sorted(no_remove_reqs))
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
994 raise error.Abort(msg % no_remove_reqs)
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
995
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
996 support_addition = allowednewrequirements(repo)
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
997 no_add_reqs = new_reqs - old_reqs - support_addition
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
998 if no_add_reqs:
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
999 m = _(b'cannot upgrade repository; do not support adding requirement: ')
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1000 no_add_reqs = b', '.join(sorted(no_add_reqs))
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1001 raise error.Abort(m + no_add_reqs)
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1002
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1003 supported = supporteddestrequirements(repo)
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1004 unsupported_reqs = new_reqs - supported
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1005 if unsupported_reqs:
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1006 msg = _(
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1007 b'cannot upgrade repository; do not support destination '
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1008 b'requirement: %s'
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1009 )
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1010 unsupported_reqs = b', '.join(sorted(unsupported_reqs))
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1011 raise error.Abort(msg % unsupported_reqs)