annotate mercurial/upgrade_utils/actions.py @ 52095:3e7b9357bbb8

tests: add coverage to for `HGCB_BUNDLE_BASENAME` with special characters Per request on IRC, to show the behavior of dropping the quoting of `HGCB_BUNDLE_BASENAME` in the next commit. This current failure is basically the same error and output that currently happens on Windows with any path (even without the embedded quote). The only difference is Windows doesn't print the `cp: cannot stat ...` line.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 21 Oct 2024 15:24:55 -0400
parents f4733654f144
children
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
51863
f4733654f144 typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51394
diff changeset
8 from __future__ import annotations
f4733654f144 typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51394
diff changeset
9
51145
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
10 import random
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
11
51285
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
12 from typing import (
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
13 List,
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
14 Type,
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
15 )
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
16
46047
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
17 from ..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
18 from .. import (
46048
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
19 error,
31893
165428b05fca upgrade: import 'localrepo' globally
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31875
diff changeset
20 localrepo,
45372
77b8588dd84e requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45371
diff changeset
21 requirements,
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
22 revlog,
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
23 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
24 )
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
25
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
26 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
27
51285
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
28 # keeps pyflakes happy
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
29 assert [
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
30 List,
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
31 Type,
9d3721552b6c pytype: import typing directly
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51145
diff changeset
32 ]
47006
e050efe97fbe typing: enable pytype processing on mercurial/upgrade_utils/actions.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 46903
diff changeset
33
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
34 # 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
35 RECLONES_REQUIREMENTS = {
46627
f4c325bf80fc requirements: also add a generaldelta constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46626
diff changeset
36 requirements.GENERALDELTA_REQUIREMENT,
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
37 requirements.SPARSEREVLOG_REQUIREMENT,
47232
33096e77598c revlogv2: mark revlogv2 as requires a full upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47229
diff changeset
38 requirements.REVLOGV2_REQUIREMENT,
47264
60668fce06d0 changelogv2: allow upgrade from and to this format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47263
diff changeset
39 requirements.CHANGELOGV2_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
40 }
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
41
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
42
35302
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
43 def preservedrequirements(repo):
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
44 preserved = {
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
45 requirements.SHARED_REQUIREMENT,
49069
a31e9840178e narrow: support debugupgraderepo
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
46 requirements.NARROW_REQUIREMENT,
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
47 }
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
48 return preserved & repo.requirements
35302
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
49
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
50
46206
9540945e51fd actions: rename DEFICIENCY constant to FORMAT_VARIANT
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46205
diff changeset
51 FORMAT_VARIANT = b'deficiency'
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
52 OPTIMISATION = b'optimization'
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
53
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
54
48946
642e31cb55f0 py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents: 48875
diff changeset
55 class improvement:
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
56 """Represents an improvement that can be made as part of an upgrade."""
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
57
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
58 ### The following attributes should be defined for each subclass:
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
59
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
60 # Either ``FORMAT_VARIANT`` or ``OPTIMISATION``.
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
61 # A format variant is where we change the storage format. Not all format
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
62 # variant changes are an obvious problem.
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
63 # An optimization is an action (sometimes optional) that
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
64 # can be taken to further improve the state of the repository.
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
65 type = None
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
66
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
67 # 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
68 # 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
69 name = None
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
70
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
71 # 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
72 # 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
73 # 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
74 # 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
75 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
76
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
77 # 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
78 # 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
79 upgrademessage = None
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
80
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
81 # 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
82 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
83
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
84 # 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
85 # 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
86 postupgrademessage = None
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
87
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
88 # 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
89 # 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
90 postdowngrademessage = None
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
91
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
92 # By default we assume that every improvement touches requirements and all revlogs
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
93
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
94 # Whether this improvement touches filelogs
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
95 touches_filelogs = True
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
96
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
97 # Whether this improvement touches manifests
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
98 touches_manifests = True
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
99
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
100 # Whether this improvement touches changelog
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
101 touches_changelog = True
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
102
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
103 # Whether this improvement changes repository requirements
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
104 touches_requirements = True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
105
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
106 # Whether this improvement touches the dirstate
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
107 touches_dirstate = False
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
108
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
109 # Can this action be run on a share instead of its mains repository
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
110 compatible_with_share = False
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
111
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
112
51288
8b2ea2246a5f pytype: convert type comment for inline variable too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51285
diff changeset
113 allformatvariant: List[Type['formatvariant']] = []
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
114
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
115
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
116 def registerformatvariant(cls):
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
117 allformatvariant.append(cls)
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
118 return cls
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
119
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
120
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
121 class formatvariant(improvement):
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
122 """an improvement subclass dedicated to repository format"""
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
123
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
124 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
125
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
126 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
127 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
128 """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
129 raise NotImplementedError()
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
130
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 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
132 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
133 """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
134 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
135
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
136
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
137 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
138 """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
139
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
140 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
141 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
142 """
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
143
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
144 # 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
145 _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
146
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
147 @staticmethod
39546
41aa5dced975 localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39243
diff changeset
148 def _newreporequirements(ui):
39996
dbcb466d0065 localrepo: define storage backend in creation options (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39870
diff changeset
149 return localrepo.newreporequirements(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
150 ui, localrepo.defaultcreateopts(ui)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
151 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
152
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
153 @classmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
154 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
155 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
156 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
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 @classmethod
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 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
160 assert cls._requirement is not None
39546
41aa5dced975 localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39243
diff changeset
161 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
162
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
163
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
164 @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
165 class fncache(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
166 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
167
46638
b4c2a2af25e2 requirements: also add a fncache constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46637
diff changeset
168 _requirement = requirements.FNCACHE_REQUIREMENT
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
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
170 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
171
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
172 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
173 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
174 b'repository performance is sub-optimal'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
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
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
177 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
178 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
179 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
180 b'operations should be improved'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
181 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
182
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
183
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
184 @registerformatvariant
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
185 class dirstatev2(requirementformatvariant):
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
186 name = b'dirstate-v2'
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
187 _requirement = requirements.DIRSTATE_V2_REQUIREMENT
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
188
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
189 default = False
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
190
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
191 description = _(
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
192 b'version 1 of the dirstate file format requires '
48295
bf11ff22a9af dirstate-v2: freeze the on-disk format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47646
diff changeset
193 b'reading and parsing it all at once.\n'
bf11ff22a9af dirstate-v2: freeze the on-disk format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47646
diff changeset
194 b'Version 2 has a better structure,'
bf11ff22a9af dirstate-v2: freeze the on-disk format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47646
diff changeset
195 b'better information and lighter update mechanism'
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
196 )
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
197
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
198 upgrademessage = _(b'"hg status" will be faster')
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
199
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
200 touches_filelogs = False
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
201 touches_manifests = False
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
202 touches_changelog = False
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
203 touches_requirements = True
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
204 touches_dirstate = True
48780
6e77083683a7 upgrade: make dirstate-v2 format variant compatible with share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48779
diff changeset
205 compatible_with_share = True
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
206
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
207
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
208 @registerformatvariant
48790
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
209 class dirstatetrackedkey(requirementformatvariant):
48793
6e559391f96e tracked-key: remove the dual write and rename to tracked-hint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48790
diff changeset
210 name = b'tracked-hint'
6e559391f96e tracked-key: remove the dual write and rename to tracked-hint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48790
diff changeset
211 _requirement = requirements.DIRSTATE_TRACKED_HINT_V1
48790
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
212
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
213 default = False
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
214
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
215 description = _(
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
216 b'Add a small file to help external tooling that watch the tracked set'
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
217 )
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
218
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
219 upgrademessage = _(
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
220 b'external tools will be informated of potential change in the tracked set'
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
221 )
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
222
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
223 touches_filelogs = False
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
224 touches_manifests = False
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
225 touches_changelog = False
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
226 touches_requirements = True
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
227 touches_dirstate = True
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
228 compatible_with_share = True
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
229
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
230
5ba24e886cec tracked-key: make it possible to upgrade to and downgrade from the feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48780
diff changeset
231 @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
232 class dotencode(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
233 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
234
46636
c3773636ddbb requirements: also add a dotencode constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46627
diff changeset
235 _requirement = requirements.DOTENCODE_REQUIREMENT
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
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
237 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
238
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
239 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
240 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
241 b'space may not work correctly'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
242 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
243
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
244 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
245 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
246 b'beginning with a space or period'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
247 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
248
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
249
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
250 @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
251 class generaldelta(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
252 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
253
46627
f4c325bf80fc requirements: also add a generaldelta constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46626
diff changeset
254 _requirement = requirements.GENERALDELTA_REQUIREMENT
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
255
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
256 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
257
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
258 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
259 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
260 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
261 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
262 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
263 b'resources, making "hg push" and "hg pull" slower'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
264 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
265
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
266 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
267 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
268 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
269 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
270 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
271 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
272 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
273 b'faster'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
274 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
275
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
276
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
277 @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
278 class sharesafe(requirementformatvariant):
46334
4b0192f592cf share: move share safe functionality out of experimental
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46230
diff changeset
279 name = b'share-safe'
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
280 _requirement = requirements.SHARESAFE_REQUIREMENT
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
281
48669
7ee07e1a25c0 share-safe: enable by default (BC)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48295
diff changeset
282 default = True
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
283
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
284 description = _(
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
285 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
286 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
287 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
288 b'extensions are enabled.'
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
289 )
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
290
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
291 upgrademessage = _(
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
292 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
293 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
294 )
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
295
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
296 postdowngrademessage = _(
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
297 b'repository downgraded to not use share safe mode, '
50992
704c3d0878d9 cleanup: typos, formatting
Joerg Sonnenberger <joerg@bec.de>
parents: 50646
diff changeset
298 b'existing shares will not work and need to be reshared.'
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
299 )
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
300
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
301 postupgrademessage = _(
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
302 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
303 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
304 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
305 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
306 )
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
307
46377
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
308 # 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
309 touches_filelogs = False
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
310 touches_manifests = False
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
311 touches_changelog = False
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
312 touches_requirements = True
60ea95471b83 upgrade: mark sharesafe improvement as only touching requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46376
diff changeset
313
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
314
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
315 @registerformatvariant
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
316 class sparserevlog(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
317 name = b'sparserevlog'
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
318
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
319 _requirement = requirements.SPARSEREVLOG_REQUIREMENT
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
320
40918
3764330f76a6 sparse-revlog: enabled by default
Boris Feld <boris.feld@octobus.net>
parents: 40837
diff changeset
321 default = True
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
322
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
323 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
324 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
325 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
326 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
327 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
328 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
329 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
330 b'exchange.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
331 )
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
332
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
333 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
334 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
335 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
336 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
337 b'better compression and faster exchange with server.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
338 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
339
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
340
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
341 @registerformatvariant
44799
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
342 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
343 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
344
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
345 _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
346
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
347 default = False
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 description = _(
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
350 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
351 )
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
352
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
353 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
354
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
355
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
356 @registerformatvariant
43138
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
357 class copiessdc(requirementformatvariant):
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
358 name = b'copies-sdc'
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
359
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
360 _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
361
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
362 default = False
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 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
365
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
366 upgrademessage = _(
50992
704c3d0878d9 cleanup: typos, formatting
Joerg Sonnenberger <joerg@bec.de>
parents: 50646
diff changeset
367 b'Allows to use more efficient algorithm to deal with copy tracing.'
43138
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
368 )
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
369
49187
04a812f507be copies-sdc: mark upgrade action as changelog only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49186
diff changeset
370 touches_filelogs = False
04a812f507be copies-sdc: mark upgrade action as changelog only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49186
diff changeset
371 touches_manifests = False
04a812f507be copies-sdc: mark upgrade action as changelog only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49186
diff changeset
372
43138
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
373
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
374 @registerformatvariant
46705
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
375 class revlogv2(requirementformatvariant):
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
376 name = b'revlog-v2'
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
377 _requirement = requirements.REVLOGV2_REQUIREMENT
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
378 default = False
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
379 description = _(b'Version 2 of the revlog.')
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
380 upgrademessage = _(b'very experimental')
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
381
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
382
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
383 @registerformatvariant
47263
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
384 class changelogv2(requirementformatvariant):
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
385 name = b'changelog-v2'
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
386 _requirement = requirements.CHANGELOGV2_REQUIREMENT
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
387 default = False
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
388 description = _(b'An iteration of the revlog focussed on changelog needs.')
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
389 upgrademessage = _(b'quite experimental')
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
390
49186
801ef401597e changelog-v2: mark upgrade action as changelog only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49069
diff changeset
391 touches_filelogs = False
801ef401597e changelog-v2: mark upgrade action as changelog only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49069
diff changeset
392 touches_manifests = False
801ef401597e changelog-v2: mark upgrade action as changelog only
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49069
diff changeset
393
47263
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
394
6c84fc9c9a90 changelogv2: introduce a "changelogv2" feature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47232
diff changeset
395 @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
396 class removecldeltachain(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
397 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
398
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
399 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
400
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
401 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
402 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
403 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
404 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
405 b'than they could be'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
406 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
407
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
408 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
409 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
410 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
411 b'faster; changelog size may be reduced'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
412 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
413
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
414 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
415 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
416 # 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
417 # changelogs with deltas.
51145
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
418 cl = repo.unfiltered().changelog
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
419 if len(cl) <= 1000:
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
420 some_rev = list(cl)
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
421 else:
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
422 # do a random sampling to speeds things up Scanning the whole
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
423 # repository can get really slow on bigger repo.
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
424 some_rev = sorted(
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
425 {random.randint(0, len(cl) - 1) for x in range(1000)}
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
426 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
427 chainbase = cl.chainbase
51145
ddf2b33ee388 debugformat: speedup the "plain-cl-delta" check
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
428 return all(rev == chainbase(rev) for rev in some_rev)
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
429
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
430 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
431 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
432 return True
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
433
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
434
46874
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
435 _has_zstd = (
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
436 b'zstd' in util.compengines
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
437 and util.compengines[b'zstd'].available()
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
438 and util.compengines[b'zstd'].revlogheader()
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
439 )
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
440
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
441
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
442 @registerformatvariant
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
443 class compressionengine(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
444 name = b'compression'
46874
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
445
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
446 if _has_zstd:
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
447 default = b'zstd'
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
448 else:
84a93fa7ecfd revlog-compression: use zstd by default (if available)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46851
diff changeset
449 default = b'zlib'
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
450
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
451 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
452 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
453 b'Some engine are faster than other'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
454 )
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
455
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
456 upgrademessage = _(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43089
diff changeset
457 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
458 )
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
459
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
460 @classmethod
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
461 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
462 # 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
463 # 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
464 #
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
465 # 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
466 compression = b'zlib'
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
467 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
468 prefix = req.startswith
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
469 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
470 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
471 return compression
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
472
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
473 @classmethod
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
474 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
475 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
476 # 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
477 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
478 if comp in util.compengines:
46851
3aa78f2aea48 revlog-compression: fix computation of engine availability
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46706
diff changeset
479 e = util.compengines[comp]
3aa78f2aea48 revlog-compression: fix computation of engine availability
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46706
diff changeset
480 if e.available() and e.revlogheader():
3aa78f2aea48 revlog-compression: fix computation of engine availability
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46706
diff changeset
481 return comp
44382
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
482
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
483 # 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
484 return b','.join(compengines)
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
485
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
486
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
487 @registerformatvariant
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
488 class compressionlevel(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
489 name = b'compression-level'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
490 default = b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
491
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
492 description = _(b'compression level')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
493
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
494 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
495
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
496 @classmethod
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
497 def fromrepo(cls, repo):
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
498 comp = compressionengine.fromrepo(repo)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
499 level = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
500 if comp == b'zlib':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
501 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
502 elif comp == b'zstd':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
503 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
504 if level is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
505 return b'default'
51392
e0fc40b95f05 debugformat: fix formatting for compression level
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
506 return b"%d" % level
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
507
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
508 @classmethod
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
509 def fromconfig(cls, repo):
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
510 comp = compressionengine.fromconfig(repo)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
511 level = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
512 if comp == b'zlib':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
513 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
514 elif comp == b'zstd':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
515 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
516 if level is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
517 return b'default'
51392
e0fc40b95f05 debugformat: fix formatting for compression level
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50993
diff changeset
518 return b"%d" % level
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
519
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
520
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
521 def find_format_upgrades(repo):
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
522 """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
523 upgrades = []
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
524
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
525 # 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
526 # 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
527 # requirements, so let's not bother.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
528
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
529 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
530 if not fv.fromrepo(repo):
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
531 upgrades.append(fv)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
532
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
533 return upgrades
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
534
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
535
46212
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
536 def find_format_downgrades(repo):
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
537 """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
538 because of disabled config option for them"""
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
539
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
540 downgrades = []
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
541
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
542 for fv in allformatvariant:
46230
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
543 if fv.name == b'compression':
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
544 # 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
545 # 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
546 # 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
547 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
548 downgrades.append(fv)
1fcab88ab85c downgrade: if a compression is removed, consider that too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
549 continue
46212
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
550 # 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
551 # config
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
552 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
553 downgrades.append(fv)
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
554
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
555 return downgrades
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
556
c97d8e0406a6 actions: introduce function to calculate downgrades
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
557
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
558 ALL_OPTIMISATIONS = []
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
559
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
560
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
561 def register_optimization(obj):
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
562 ALL_OPTIMISATIONS.append(obj)
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
563 return obj
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
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
566 class optimization(improvement):
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
567 """an improvement subclass dedicated to optimizations"""
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
568
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
569 type = OPTIMISATION
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
570
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
571
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
572 @register_optimization
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
573 class redeltaparents(optimization):
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
574 name = b're-delta-parent'
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
575
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
576 type = OPTIMISATION
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
577
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
578 description = _(
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
579 b'deltas within internal storage will be recalculated to '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
580 b'choose an optimal base revision where this was not '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
581 b'already done; the size of the repository may shrink and '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
582 b'various operations may become faster; the first time '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
583 b'this optimization is performed could slow down upgrade '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
584 b'execution considerably; subsequent invocations should '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
585 b'not run noticeably slower'
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
586 )
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
587
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
588 upgrademessage = _(
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
589 b'deltas within internal storage will choose a new '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
590 b'base revision if needed'
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
591 )
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
592
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
593
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
594 @register_optimization
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
595 class redeltamultibase(optimization):
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
596 name = b're-delta-multibase'
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
597
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
598 type = OPTIMISATION
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
599
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
600 description = _(
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
601 b'deltas within internal storage will be recalculated '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
602 b'against multiple base revision and the smallest '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
603 b'difference will be used; the size of the repository may '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
604 b'shrink significantly when there are many merges; this '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
605 b'optimization will slow down execution in proportion to '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
606 b'the number of merges in the repository and the amount '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
607 b'of files in the repository; this slow down should not '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
608 b'be significant unless there are tens of thousands of '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
609 b'files and thousands of merges'
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
610 )
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
611
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
612 upgrademessage = _(
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
613 b'deltas within internal storage will choose an '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
614 b'optimal delta by computing deltas against multiple '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
615 b'parents; may slow down execution time '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
616 b'significantly'
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
617 )
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
618
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
619
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
620 @register_optimization
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
621 class redeltaall(optimization):
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
622 name = b're-delta-all'
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
623
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
624 type = OPTIMISATION
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
625
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
626 description = _(
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
627 b'deltas within internal storage will always be '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
628 b'recalculated without reusing prior deltas; this will '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
629 b'likely make execution run several times slower; this '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
630 b'optimization is typically not needed'
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
631 )
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
632
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
633 upgrademessage = _(
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
634 b'deltas within internal storage will be fully '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
635 b'recomputed; this will likely drastically slow down '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
636 b'execution time'
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
637 )
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
638
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
639
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
640 @register_optimization
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
641 class redeltafulladd(optimization):
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
642 name = b're-delta-fulladd'
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
643
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
644 type = OPTIMISATION
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
645
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
646 description = _(
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
647 b'every revision will be re-added as if it was new '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
648 b'content. It will go through the full storage '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
649 b'mechanism giving extensions a chance to process it '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
650 b'(eg. lfs). This is similar to "re-delta-all" but even '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
651 b'slower since more logic is involved.'
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
652 )
47319
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
653
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
654 upgrademessage = _(
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
655 b'each revision will be added as new content to the '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
656 b'internal storage; this will likely drastically slow '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
657 b'down execution time, but some extensions might need '
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
658 b'it'
e985a36c2aa3 upgrade: Use `improvement` subclasses everywhere, not instances
Simon Sapin <simon.sapin@octobus.net>
parents: 47277
diff changeset
659 )
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
660
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
661
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
662 def findoptimizations(repo):
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
663 """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
664 # 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
665 # 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
666 return list(ALL_OPTIMISATIONS)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
667
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
668
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
669 def determine_upgrade_actions(
46209
a51d345f1404 upgrade: move optimization addition to determineactions()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46206
diff changeset
670 repo, format_upgrades, optimizations, sourcereqs, destreqs
a51d345f1404 upgrade: move optimization addition to determineactions()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46206
diff changeset
671 ):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
672 """Determine upgrade actions that will be performed.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
673
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
674 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
675 ``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
676 will be performed.
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
677
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
678 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
679 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
680 etc.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
681
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
682 Returns a list of action names.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
683 """
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
684 newactions = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
685
46205
53d083fa1f83 upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46192
diff changeset
686 for d in format_upgrades:
50928
d718eddf01d9 safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50646
diff changeset
687 if hasattr(d, '_requirement'):
47646
4259a72fe528 upgrade_utils: fix crash for removecldeltachain action
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 47320
diff changeset
688 name = d._requirement
4259a72fe528 upgrade_utils: fix crash for removecldeltachain action
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 47320
diff changeset
689 else:
4259a72fe528 upgrade_utils: fix crash for removecldeltachain action
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 47320
diff changeset
690 name = None
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
691
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
692 # 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
693 # 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
694 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
695 continue
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
696
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
697 newactions.append(d)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
698
49377
7fe86498e84f repo-upgrade: avoid a crash when multiple optimisation are specified
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49193
diff changeset
699 newactions.extend(
7fe86498e84f repo-upgrade: avoid a crash when multiple optimisation are specified
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49193
diff changeset
700 o
7fe86498e84f repo-upgrade: avoid a crash when multiple optimisation are specified
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49193
diff changeset
701 for o in sorted(optimizations, key=(lambda x: x.name))
7fe86498e84f repo-upgrade: avoid a crash when multiple optimisation are specified
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49193
diff changeset
702 if o not in newactions
7fe86498e84f repo-upgrade: avoid a crash when multiple optimisation are specified
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49193
diff changeset
703 )
46209
a51d345f1404 upgrade: move optimization addition to determineactions()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46206
diff changeset
704
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
705 # 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
706 # 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
707
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
708 return newactions
46048
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
709
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
710
49193
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
711 class BaseOperation:
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
712 """base class that contains the minimum for an upgrade to work
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
713
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
714 (this might need to be extended as the usage for subclass alternative to
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
715 UpgradeOperation extends)
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
716 """
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
717
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
718 def __init__(
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
719 self,
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
720 new_requirements,
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
721 backup_store,
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
722 ):
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
723 self.new_requirements = new_requirements
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
724 # should this operation create a backup of the store
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
725 self.backup_store = backup_store
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
726
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
727
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
728 class UpgradeOperation(BaseOperation):
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
729 """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
730
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
731 def __init__(
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
732 self,
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
733 ui,
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
734 new_requirements,
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
735 current_requirements,
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
736 upgrade_actions,
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
737 removed_actions,
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
738 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
739 backup_store,
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
740 ):
49193
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
741 super().__init__(
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
742 new_requirements,
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
743 backup_store,
566066826e7c upgrade: split some logic from UpgradeOperation
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49187
diff changeset
744 )
46188
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
745 self.ui = ui
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
746 self.current_requirements = current_requirements
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
747 # list of upgrade actions the operation will perform
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
748 self.upgrade_actions = upgrade_actions
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
749 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
750 self.revlogs_to_process = revlogs_to_process
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
751 # requirements which will be added by the operation
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
752 self._added_requirements = (
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
753 self.new_requirements - self.current_requirements
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
754 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
755 # requirements which will be removed by the operation
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
756 self._removed_requirements = (
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
757 self.current_requirements - self.new_requirements
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
758 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
759 # requirements which will be preserved by the operation
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
760 self._preserved_requirements = (
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
761 self.current_requirements & self.new_requirements
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
762 )
46192
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
763 # 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
764 # should use them
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
765 all_optimizations = findoptimizations(None)
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
766 self.unused_optimizations = [
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
767 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
768 ]
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
769
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
770 # delta reuse mode of this upgrade operation
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
771 upgrade_actions_names = self.upgrade_actions_names
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
772 self.delta_reuse_mode = revlog.revlog.DELTAREUSEALWAYS
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
773 if b're-delta-all' in upgrade_actions_names:
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
774 self.delta_reuse_mode = revlog.revlog.DELTAREUSENEVER
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
775 elif b're-delta-parent' in upgrade_actions_names:
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
776 self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
777 elif b're-delta-multibase' in upgrade_actions_names:
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
778 self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
779 elif b're-delta-fulladd' in upgrade_actions_names:
46215
82f3ee1a505f actions: store deltareuse mode of whole operation in UpgradeOperation
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46213
diff changeset
780 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
781
46218
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
782 # 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
783 self.force_re_delta_both_parents = (
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
784 b're-delta-multibase' in upgrade_actions_names
46218
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
785 )
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
786
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
787 @property
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
788 def upgrade_actions_names(self):
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
789 return set([a.name for a in self.upgrade_actions])
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
790
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
791 @property
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
792 def requirements_only(self):
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
793 # does the operation only touches repository requirement
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
794 return (
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
795 self.touches_requirements
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
796 and not self.touches_filelogs
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
797 and not self.touches_manifests
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
798 and not self.touches_changelog
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
799 and not self.touches_dirstate
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
800 )
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
801
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
802 @property
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
803 def touches_filelogs(self):
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
804 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
805 # 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
806 if a.type == OPTIMISATION:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
807 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
808 elif a.touches_filelogs:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
809 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
810 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
811 if a.touches_filelogs:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
812 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
813 return False
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
814
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
815 @property
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
816 def touches_manifests(self):
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
817 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
818 # 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
819 if a.type == OPTIMISATION:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
820 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
821 elif a.touches_manifests:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
822 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
823 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
824 if a.touches_manifests:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
825 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
826 return False
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
827
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
828 @property
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
829 def touches_changelog(self):
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
830 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
831 # 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
832 if a.type == OPTIMISATION:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
833 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
834 elif a.touches_changelog:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
835 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
836 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
837 if a.touches_changelog:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
838 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
839 return False
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
840
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
841 @property
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
842 def touches_requirements(self):
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
843 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
844 # 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
845 # 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
846 if a.type == OPTIMISATION:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
847 pass
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
848 elif a.touches_requirements:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
849 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
850 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
851 if a.touches_requirements:
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
852 return True
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
853
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
854 @property
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
855 def touches_dirstate(self):
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
856 for a in self.upgrade_actions:
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
857 # revlog optimisations do not affect the dirstate
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
858 if a.type == OPTIMISATION:
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
859 pass
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
860 elif a.touches_dirstate:
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
861 return True
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
862 for a in self.removed_actions:
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
863 if a.touches_dirstate:
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
864 return True
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
865
46376
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
866 return False
a83e1496d943 actions: calculate what all parts does the operation touches
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
867
49576
d12446766a35 upgrade: byteify requirement changes written to output
Matt Harbison <matt_harbison@yahoo.com>
parents: 49377
diff changeset
868 def _write_labeled(self, l, label: bytes):
46190
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
869 """
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
870 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
871 """
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
872 first = True
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
873 for r in sorted(l):
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
874 if not first:
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
875 self.ui.write(b', ')
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
876 self.ui.write(r, label=label)
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
877 first = False
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
878
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
879 def print_requirements(self):
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
880 self.ui.write(_(b'requirements\n'))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
881 self.ui.write(_(b' preserved: '))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
882 self._write_labeled(
49576
d12446766a35 upgrade: byteify requirement changes written to output
Matt Harbison <matt_harbison@yahoo.com>
parents: 49377
diff changeset
883 self._preserved_requirements, b"upgrade-repo.requirement.preserved"
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
884 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
885 self.ui.write((b'\n'))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
886 if self._removed_requirements:
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
887 self.ui.write(_(b' removed: '))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
888 self._write_labeled(
49576
d12446766a35 upgrade: byteify requirement changes written to output
Matt Harbison <matt_harbison@yahoo.com>
parents: 49377
diff changeset
889 self._removed_requirements, b"upgrade-repo.requirement.removed"
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
890 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
891 self.ui.write((b'\n'))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
892 if self._added_requirements:
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
893 self.ui.write(_(b' added: '))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
894 self._write_labeled(
49576
d12446766a35 upgrade: byteify requirement changes written to output
Matt Harbison <matt_harbison@yahoo.com>
parents: 49377
diff changeset
895 self._added_requirements, b"upgrade-repo.requirement.added"
46191
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
896 )
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
897 self.ui.write((b'\n'))
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
898 self.ui.write(b'\n')
aba979b1b90b upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46190
diff changeset
899
46190
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
900 def print_optimisations(self):
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
901 optimisations = [
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
902 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
903 ]
46190
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
904 optimisations.sort(key=lambda a: a.name)
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
905 if optimisations:
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
906 self.ui.write(_(b'optimisations: '))
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
907 self._write_labeled(
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
908 [a.name for a in optimisations],
49576
d12446766a35 upgrade: byteify requirement changes written to output
Matt Harbison <matt_harbison@yahoo.com>
parents: 49377
diff changeset
909 b"upgrade-repo.optimisation.performed",
46190
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
910 )
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
911 self.ui.write(b'\n\n')
9ab2ab5bf9af upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46189
diff changeset
912
46189
dfddcbb0c244 upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46188
diff changeset
913 def print_upgrade_actions(self):
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
914 for a in self.upgrade_actions:
46189
dfddcbb0c244 upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46188
diff changeset
915 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
916
46188
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
917 def print_affected_revlogs(self):
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
918 if not self.revlogs_to_process:
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
919 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
920 else:
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
921 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
922 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
923 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
924 self.ui.write((b'\n'))
945b33a7edfd upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46056
diff changeset
925
46192
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
926 def print_unused_optimizations(self):
25d11b24dedf upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
927 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
928 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
929
46210
6b40aac4da8e upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46209
diff changeset
930 def has_upgrade_action(self, name):
47062
f38bf44e077f black: make codebase compatible with black v21.4b2 and v20.8b1
Kyle Lippincott <spectral@google.com>
parents: 47006
diff changeset
931 """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
932 return name in self._upgrade_actions_names
46189
dfddcbb0c244 upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46188
diff changeset
933
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
934 def print_post_op_messages(self):
47062
f38bf44e077f black: make codebase compatible with black v21.4b2 and v20.8b1
Kyle Lippincott <spectral@google.com>
parents: 47006
diff changeset
935 """print post upgrade operation warning messages"""
46213
30310886d423 upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46212
diff changeset
936 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
937 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
938 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
939 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
940 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
941 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
942
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
943
46049
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
944 ### 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
945
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
946
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
947 def requiredsourcerequirements(repo):
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
948 """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
949
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
950 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
951 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
952 """
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
953 return {
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
954 # Introduced in Mercurial 0.9.2.
46637
ab58098bebed requirements: also add a store constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46636
diff changeset
955 requirements.STORE_REQUIREMENT,
46049
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
956 }
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
957
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
958
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
959 def blocksourcerequirements(repo):
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
960 """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
961
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
962 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
963 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
964 """
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
965 return {
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
966 # 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
967 # 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
968 b'parentdelta',
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
969 }
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
970
a2a59cde9b9f upgrade: gather code about source checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46048
diff changeset
971
46705
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
972 def check_revlog_version(reqs):
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
973 """Check that the requirements contain at least one Revlog version"""
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
974 all_revlogs = {
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
975 requirements.REVLOGV1_REQUIREMENT,
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
976 requirements.REVLOGV2_REQUIREMENT,
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
977 }
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
978 if not all_revlogs.intersection(reqs):
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
979 msg = _(b'cannot upgrade repository; missing a revlog version')
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
980 raise error.Abort(msg)
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
981
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
982
46048
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
983 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
984 """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
985
46705
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
986 check_revlog_version(repo.requirements)
46048
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
987 required = requiredsourcerequirements(repo)
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
988 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
989 if missingreqs:
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
990 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
991 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
992 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
993
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
994 blocking = blocksourcerequirements(repo)
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
995 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
996 if blockingreqs:
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
997 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
998 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
999 raise error.Abort(m % blockingreqs)
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1000 # Upgrade should operate on the actual store, not the shared link.
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1001
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1002 bad_share = (
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1003 requirements.SHARED_REQUIREMENT in repo.requirements
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1004 and requirements.SHARESAFE_REQUIREMENT not in repo.requirements
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1005 )
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1006 if bad_share:
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1007 m = _(b'cannot upgrade repository; share repository without share-safe')
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1008 h = _(b'check :hg:`help config.format.use-share-safe`')
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1009 raise error.Abort(m, hint=h)
46051
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1010
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1011
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1012 ### 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
1013
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1014
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1015 def supportremovedrequirements(repo):
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1016 """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
1017
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1018 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
1019 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
1020 to be allowed.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1021 """
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1022 supported = {
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1023 requirements.SPARSEREVLOG_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1024 requirements.COPIESSDC_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1025 requirements.NODEMAP_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1026 requirements.SHARESAFE_REQUIREMENT,
46705
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
1027 requirements.REVLOGV2_REQUIREMENT,
47264
60668fce06d0 changelogv2: allow upgrade from and to this format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47263
diff changeset
1028 requirements.CHANGELOGV2_REQUIREMENT,
46705
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
1029 requirements.REVLOGV1_REQUIREMENT,
48793
6e559391f96e tracked-key: remove the dual write and rename to tracked-hint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48790
diff changeset
1030 requirements.DIRSTATE_TRACKED_HINT_V1,
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
1031 requirements.DIRSTATE_V2_REQUIREMENT,
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1032 }
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1033 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
1034 engine = compression.compengines[name]
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1035 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
1036 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
1037 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
1038 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
1039 return supported
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1040
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1041
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1042 def supporteddestrequirements(repo):
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1043 """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
1044
49069
a31e9840178e narrow: support debugupgraderepo
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
1045 If the result of the upgrade would have requirements not in this set,
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1046 the upgrade is disallowed.
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1047
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1048 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
1049 """
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1050 supported = {
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1051 requirements.CHANGELOGV2_REQUIREMENT,
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1052 requirements.COPIESSDC_REQUIREMENT,
48793
6e559391f96e tracked-key: remove the dual write and rename to tracked-hint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48790
diff changeset
1053 requirements.DIRSTATE_TRACKED_HINT_V1,
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1054 requirements.DIRSTATE_V2_REQUIREMENT,
46636
c3773636ddbb requirements: also add a dotencode constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46627
diff changeset
1055 requirements.DOTENCODE_REQUIREMENT,
46638
b4c2a2af25e2 requirements: also add a fncache constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46637
diff changeset
1056 requirements.FNCACHE_REQUIREMENT,
46627
f4c325bf80fc requirements: also add a generaldelta constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46626
diff changeset
1057 requirements.GENERALDELTA_REQUIREMENT,
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1058 requirements.NODEMAP_REQUIREMENT,
46705
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
1059 requirements.REVLOGV1_REQUIREMENT, # allowed in case of downgrade
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1060 requirements.REVLOGV2_REQUIREMENT,
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1061 requirements.SHARED_REQUIREMENT,
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1062 requirements.SHARESAFE_REQUIREMENT,
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1063 requirements.SPARSEREVLOG_REQUIREMENT,
48779
17eaeb06562c upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48669
diff changeset
1064 requirements.STORE_REQUIREMENT,
50646
c814101560d9 tree-manifest: allow `debugupgraderepo` to run on tree manifest repo
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49576
diff changeset
1065 requirements.TREEMANIFEST_REQUIREMENT,
49069
a31e9840178e narrow: support debugupgraderepo
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 48946
diff changeset
1066 requirements.NARROW_REQUIREMENT,
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1067 }
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1068 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
1069 engine = compression.compengines[name]
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1070 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
1071 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
1072 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
1073 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
1074 return supported
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1075
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1076
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1077 def allowednewrequirements(repo):
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1078 """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
1079
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1080 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
1081 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
1082
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1083 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
1084 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
1085 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
1086 """
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1087 supported = {
46636
c3773636ddbb requirements: also add a dotencode constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46627
diff changeset
1088 requirements.DOTENCODE_REQUIREMENT,
46638
b4c2a2af25e2 requirements: also add a fncache constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46637
diff changeset
1089 requirements.FNCACHE_REQUIREMENT,
46627
f4c325bf80fc requirements: also add a generaldelta constant
Raphaël Gomès <rgomes@octobus.net>
parents: 46626
diff changeset
1090 requirements.GENERALDELTA_REQUIREMENT,
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1091 requirements.SPARSEREVLOG_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1092 requirements.COPIESSDC_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1093 requirements.NODEMAP_REQUIREMENT,
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1094 requirements.SHARESAFE_REQUIREMENT,
46705
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
1095 requirements.REVLOGV1_REQUIREMENT,
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
1096 requirements.REVLOGV2_REQUIREMENT,
47264
60668fce06d0 changelogv2: allow upgrade from and to this format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47263
diff changeset
1097 requirements.CHANGELOGV2_REQUIREMENT,
48793
6e559391f96e tracked-key: remove the dual write and rename to tracked-hint
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48790
diff changeset
1098 requirements.DIRSTATE_TRACKED_HINT_V1,
47320
a43d256c041a dirstate-v2: Add `hg debugupgraderepo` command support
Simon Sapin <simon.sapin@octobus.net>
parents: 47319
diff changeset
1099 requirements.DIRSTATE_V2_REQUIREMENT,
46052
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1100 }
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1101 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
1102 engine = compression.compengines[name]
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1103 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
1104 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
1105 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
1106 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
1107 return supported
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1108
08802795ae90 upgrade: gather code about requirement checking together
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46051
diff changeset
1109
46051
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1110 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
1111 old_reqs = repo.requirements
46705
fd55a9eb1507 revlogv2: allow upgrading to v2
Raphaël Gomès <rgomes@octobus.net>
parents: 46638
diff changeset
1112 check_revlog_version(repo.requirements)
46051
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1113 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
1114 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
1115 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
1116 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
1117 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
1118 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
1119
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1120 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
1121 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
1122 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
1123 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
1124 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
1125 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
1126
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1127 supported = supporteddestrequirements(repo)
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1128 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
1129 if unsupported_reqs:
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1130 msg = _(
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1131 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
1132 b'requirement: %s'
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1133 )
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46049
diff changeset
1134 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
1135 raise error.Abort(msg % unsupported_reqs)