author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Tue, 01 Dec 2020 15:45:23 +0100 | |
changeset 46048 | f4f956342cf1 |
parent 46047 | 4b89cf08d8dc |
child 46050 | ad9dd4d333be |
permissions | -rw-r--r-- |
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 | 6 |
# GNU General Public License version 2 or any later version. |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
|
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
8 |
from __future__ import absolute_import |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
9 |
|
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
10 |
from .i18n import _ |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
11 |
from . import ( |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26425
diff
changeset
|
12 |
error, |
35343
06987c6971be
upgrade: more standard creation of the temporary repository
Boris Feld <boris.feld@octobus.net>
parents:
35342
diff
changeset
|
13 |
hg, |
31893
165428b05fca
upgrade: import 'localrepo' globally
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31875
diff
changeset
|
14 |
localrepo, |
38165
2ce60954b1b7
py3: wrap tempfile.mkdtemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents:
37444
diff
changeset
|
15 |
pycompat, |
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
16 |
) |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
17 |
|
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
18 |
from .upgrade_utils import ( |
46047
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46046
diff
changeset
|
19 |
actions as upgrade_actions, |
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
20 |
engine as upgrade_engine, |
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
21 |
) |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
22 |
|
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
|
23 |
allformatvariant = upgrade_actions.allformatvariant |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
24 |
|
41088
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
25 |
# search without '-' to support older form on newer client. |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
26 |
# |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
27 |
# We don't enforce backward compatibility for debug command so this |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
28 |
# might eventually be dropped. However, having to use two different |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
29 |
# forms in script when comparing result is anoying enough to add |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
30 |
# backward compatibility for a while. |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
31 |
legacy_opts_map = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
32 |
b'redeltaparent': b're-delta-parent', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
33 |
b'redeltamultibase': b're-delta-multibase', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
34 |
b'redeltaall': b're-delta-all', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
35 |
b'redeltafulladd': b're-delta-fulladd', |
41088
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
36 |
} |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
37 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
38 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
39 |
def upgraderepo( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
40 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
41 |
repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
42 |
run=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
43 |
optimize=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
44 |
backup=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
45 |
manifest=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
46 |
changelog=None, |
45997
7c539f0febbe
upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45995
diff
changeset
|
47 |
filelogs=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
48 |
): |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
49 |
"""Upgrade a repository in place.""" |
41088
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
50 |
if optimize is None: |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
51 |
optimize = [] |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44382
diff
changeset
|
52 |
optimize = {legacy_opts_map.get(o, o) for o in optimize} |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
53 |
repo = repo.unfiltered() |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
54 |
|
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
55 |
revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS) |
45981
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45980
diff
changeset
|
56 |
specentries = ( |
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
57 |
(upgrade_engine.UPGRADE_CHANGELOG, changelog), |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
58 |
(upgrade_engine.UPGRADE_MANIFEST, manifest), |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
59 |
(upgrade_engine.UPGRADE_FILELOGS, filelogs), |
45981
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45980
diff
changeset
|
60 |
) |
42830
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
61 |
specified = [(y, x) for (y, x) in specentries if x is not None] |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
62 |
if specified: |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
63 |
# we have some limitation on revlogs to be recloned |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
64 |
if any(x for y, x in specified): |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
65 |
revlogs = set() |
45981
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45980
diff
changeset
|
66 |
for upgrade, enabled in specified: |
42830
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
67 |
if enabled: |
45981
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45980
diff
changeset
|
68 |
revlogs.add(upgrade) |
42830
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
69 |
else: |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
70 |
# none are enabled |
45981
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45980
diff
changeset
|
71 |
for upgrade, __ in specified: |
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45980
diff
changeset
|
72 |
revlogs.discard(upgrade) |
42830
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
73 |
|
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
74 |
# Ensure the repository can be upgraded. |
46048
f4f956342cf1
upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46047
diff
changeset
|
75 |
upgrade_actions.check_source_requirements(repo) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
76 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
77 |
# FUTURE there is potentially a need to control the wanted requirements via |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
78 |
# command arguments or via an extension hook point. |
39996
dbcb466d0065
localrepo: define storage backend in creation options (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39870
diff
changeset
|
79 |
newreqs = localrepo.newreporequirements( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
80 |
repo.ui, localrepo.defaultcreateopts(repo.ui) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
81 |
) |
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
|
82 |
newreqs.update(upgrade_actions.preservedrequirements(repo)) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
83 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
84 |
noremovereqs = ( |
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
|
85 |
repo.requirements |
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
|
86 |
- newreqs |
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
|
87 |
- upgrade_actions.supportremovedrequirements(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
88 |
) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
89 |
if noremovereqs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
90 |
raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
91 |
_( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
92 |
b'cannot upgrade repository; requirement would be ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
93 |
b'removed: %s' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
94 |
) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
95 |
% _(b', ').join(sorted(noremovereqs)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
96 |
) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
97 |
|
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
|
98 |
noaddreqs = ( |
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
|
99 |
newreqs |
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
|
100 |
- repo.requirements |
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
|
101 |
- upgrade_actions.allowednewrequirements(repo) |
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
|
102 |
) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
103 |
if noaddreqs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
104 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
105 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
106 |
b'cannot upgrade repository; do not support adding ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
107 |
b'requirement: %s' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
108 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
109 |
% _(b', ').join(sorted(noaddreqs)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
110 |
) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
111 |
|
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
|
112 |
unsupportedreqs = newreqs - upgrade_actions.supporteddestrequirements(repo) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
113 |
if unsupportedreqs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
114 |
raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
115 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 |
b'cannot upgrade repository; do not support ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
117 |
b'destination requirement: %s' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
118 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
119 |
% _(b', ').join(sorted(unsupportedreqs)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
120 |
) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
121 |
|
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
122 |
# Find and validate all improvements that can be made. |
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
|
123 |
alloptimizations = upgrade_actions.findoptimizations(repo) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
124 |
|
31899
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
125 |
# Apply and Validate arguments. |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
126 |
optimizations = [] |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
127 |
for o in alloptimizations: |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
128 |
if o.name in optimize: |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
129 |
optimizations.append(o) |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
130 |
optimize.discard(o.name) |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
131 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
132 |
if optimize: # anything left is unknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
133 |
raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
134 |
_(b'unknown optimization action requested: %s') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
135 |
% b', '.join(sorted(optimize)), |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43089
diff
changeset
|
136 |
hint=_(b'run without arguments to see valid optimizations'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
137 |
) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
138 |
|
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
|
139 |
deficiencies = upgrade_actions.finddeficiencies(repo) |
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
|
140 |
actions = upgrade_actions.determineactions( |
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
|
141 |
repo, deficiencies, repo.requirements, newreqs |
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
|
142 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
143 |
actions.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
144 |
o |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
145 |
for o in sorted(optimizations) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
146 |
# determineactions could have added optimisation |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
147 |
if o not in actions |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
148 |
) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
149 |
|
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
|
150 |
removedreqs = repo.requirements - newreqs |
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
|
151 |
addedreqs = newreqs - repo.requirements |
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
|
152 |
|
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
153 |
if revlogs != upgrade_engine.UPGRADE_ALL_REVLOGS: |
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
|
154 |
incompatible = upgrade_actions.RECLONES_REQUIREMENTS & ( |
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
|
155 |
removedreqs | addedreqs |
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
|
156 |
) |
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
|
157 |
if incompatible: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
158 |
msg = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
159 |
b'ignoring revlogs selection flags, format requirements ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
160 |
b'change: %s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
161 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
162 |
ui.warn(msg % b', '.join(sorted(incompatible))) |
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
163 |
revlogs = upgrade_engine.UPGRADE_ALL_REVLOGS |
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
|
164 |
|
43805
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
165 |
def write_labeled(l, label): |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
166 |
first = True |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
167 |
for r in sorted(l): |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
168 |
if not first: |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
169 |
ui.write(b', ') |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
170 |
ui.write(r, label=label) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
171 |
first = False |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
172 |
|
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
173 |
def printrequirements(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
174 |
ui.write(_(b'requirements\n')) |
43805
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
175 |
ui.write(_(b' preserved: ')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
176 |
write_labeled( |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
177 |
newreqs & repo.requirements, "upgrade-repo.requirement.preserved" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
178 |
) |
43805
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
179 |
ui.write((b'\n')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
180 |
removed = repo.requirements - newreqs |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
181 |
if repo.requirements - newreqs: |
43805
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
182 |
ui.write(_(b' removed: ')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
183 |
write_labeled(removed, "upgrade-repo.requirement.removed") |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
184 |
ui.write((b'\n')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
185 |
added = newreqs - repo.requirements |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
186 |
if added: |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
187 |
ui.write(_(b' added: ')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
188 |
write_labeled(added, "upgrade-repo.requirement.added") |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
189 |
ui.write((b'\n')) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
190 |
ui.write(b'\n') |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
191 |
|
44797
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
192 |
def printoptimisations(): |
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
|
193 |
optimisations = [ |
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
|
194 |
a for a in actions if a.type == upgrade_actions.OPTIMISATION |
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
|
195 |
] |
44797
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
196 |
optimisations.sort(key=lambda a: a.name) |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
197 |
if optimisations: |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
198 |
ui.write(_(b'optimisations: ')) |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
199 |
write_labeled( |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
200 |
[a.name for a in optimisations], |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
201 |
"upgrade-repo.optimisation.performed", |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
202 |
) |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
203 |
ui.write(b'\n\n') |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
204 |
|
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
205 |
def printupgradeactions(): |
31903
fa1088de2119
upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31902
diff
changeset
|
206 |
for a in actions: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
207 |
ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage)) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
208 |
|
46035
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
209 |
def print_affected_revlogs(): |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
210 |
if not revlogs: |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
211 |
ui.write((b'no revlogs to process\n')) |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
212 |
else: |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
213 |
ui.write((b'processed revlogs:\n')) |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
214 |
for r in sorted(revlogs): |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
215 |
ui.write((b' - %s\n' % r)) |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
216 |
ui.write((b'\n')) |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
217 |
|
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
218 |
if not run: |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
219 |
fromconfig = [] |
31904
3c77f03f16b3
upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31903
diff
changeset
|
220 |
onlydefault = [] |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
221 |
|
31901
9bdedb050d8d
upgrade: simplify some of the initial dispatch for dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31900
diff
changeset
|
222 |
for d in deficiencies: |
32031
11a2461fc9b1
upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32030
diff
changeset
|
223 |
if d.fromconfig(repo): |
31901
9bdedb050d8d
upgrade: simplify some of the initial dispatch for dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31900
diff
changeset
|
224 |
fromconfig.append(d) |
32031
11a2461fc9b1
upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32030
diff
changeset
|
225 |
elif d.default: |
31904
3c77f03f16b3
upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31903
diff
changeset
|
226 |
onlydefault.append(d) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
227 |
|
31904
3c77f03f16b3
upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31903
diff
changeset
|
228 |
if fromconfig or onlydefault: |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
229 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
230 |
if fromconfig: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
231 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
232 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
233 |
b'repository lacks features recommended by ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
234 |
b'current config options:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
235 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
236 |
) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
237 |
for i in fromconfig: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
238 |
ui.status(b'%s\n %s\n\n' % (i.name, i.description)) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
239 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
240 |
if onlydefault: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
241 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
242 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
243 |
b'repository lacks features used by the default ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
244 |
b'config options:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
245 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
246 |
) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
247 |
for i in onlydefault: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
248 |
ui.status(b'%s\n %s\n\n' % (i.name, i.description)) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
249 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
250 |
ui.status(b'\n') |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
251 |
else: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
252 |
ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
253 |
_( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
254 |
b'(no feature deficiencies found in existing ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
255 |
b'repository)\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
256 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
257 |
) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
258 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
259 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
260 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
261 |
b'performing an upgrade with "--run" will make the following ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
262 |
b'changes:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
263 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
264 |
) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
265 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
266 |
printrequirements() |
44797
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
267 |
printoptimisations() |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
268 |
printupgradeactions() |
46035
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
269 |
print_affected_revlogs() |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
270 |
|
31903
fa1088de2119
upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31902
diff
changeset
|
271 |
unusedoptimize = [i for i in alloptimizations if i not in actions] |
fa1088de2119
upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31902
diff
changeset
|
272 |
|
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
273 |
if unusedoptimize: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
274 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
275 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
276 |
b'additional optimizations are available by specifying ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
277 |
b'"--optimize <name>":\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
278 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
279 |
) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
280 |
for i in unusedoptimize: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
281 |
ui.status(_(b'%s\n %s\n\n') % (i.name, i.description)) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
282 |
return |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
283 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
284 |
# Else we're in the run=true case. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
285 |
ui.write(_(b'upgrade will perform the following actions:\n\n')) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
286 |
printrequirements() |
44797
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44746
diff
changeset
|
287 |
printoptimisations() |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
288 |
printupgradeactions() |
46035
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
289 |
print_affected_revlogs() |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
290 |
|
31903
fa1088de2119
upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31902
diff
changeset
|
291 |
upgradeactions = [a.name for a in actions] |
fa1088de2119
upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31902
diff
changeset
|
292 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
293 |
ui.status(_(b'beginning upgrade...\n')) |
33438 | 294 |
with repo.wlock(), repo.lock(): |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
295 |
ui.status(_(b'repository locked and read-only\n')) |
33438 | 296 |
# Our strategy for upgrading the repository is to create a new, |
297 |
# temporary repository, write data to it, then do a swap of the |
|
298 |
# data. There are less heavyweight ways to do this, but it is easier |
|
299 |
# to create a new repo object than to instantiate all the components |
|
300 |
# (like the store) separately. |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
301 |
tmppath = pycompat.mkdtemp(prefix=b'upgrade.', dir=repo.path) |
33438 | 302 |
backuppath = None |
303 |
try: |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
304 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
305 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
306 |
b'creating temporary repository to stage migrated ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
307 |
b'data: %s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
308 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
309 |
% tmppath |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
310 |
) |
35342
75520786ad2f
upgrade: use the repository 'ui' as the base for the new repository
Boris Feld <boris.feld@octobus.net>
parents:
35340
diff
changeset
|
311 |
|
35379
6c28956ba2d4
upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents:
35345
diff
changeset
|
312 |
# clone ui without using ui.copy because repo.ui is protected |
6c28956ba2d4
upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents:
35345
diff
changeset
|
313 |
repoui = repo.ui.__class__(repo.ui) |
6c28956ba2d4
upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents:
35345
diff
changeset
|
314 |
dstrepo = hg.repository(repoui, path=tmppath, create=True) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
315 |
|
33438 | 316 |
with dstrepo.wlock(), dstrepo.lock(): |
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
317 |
backuppath = upgrade_engine.upgrade( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
318 |
ui, repo, dstrepo, newreqs, upgradeactions, revlogs=revlogs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
319 |
) |
41089
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
41088
diff
changeset
|
320 |
if not (backup or backuppath is None): |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
321 |
ui.status( |
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
322 |
_(b'removing old repository content%s\n') % backuppath |
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
323 |
) |
41089
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
41088
diff
changeset
|
324 |
repo.vfs.rmtree(backuppath, forcibly=True) |
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
41088
diff
changeset
|
325 |
backuppath = None |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
326 |
|
33438 | 327 |
finally: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
328 |
ui.status(_(b'removing temporary repository %s\n') % tmppath) |
33438 | 329 |
repo.vfs.rmtree(tmppath, forcibly=True) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
330 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
331 |
if backuppath and not ui.quiet: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
332 |
ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
333 |
_(b'copy of old repository backed up at %s\n') % backuppath |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
334 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
335 |
ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
336 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
337 |
b'the old repository will not be deleted; remove ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
338 |
b'it to free up disk space once the upgraded ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
339 |
b'repository is verified\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
340 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
341 |
) |
46002
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
342 |
|
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
|
343 |
if upgrade_actions.sharesafe.name in addedreqs: |
46002
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
344 |
ui.warn( |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
345 |
_( |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
346 |
b'repository upgraded to share safe mode, existing' |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
347 |
b' shares will still work in old non-safe mode. ' |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
348 |
b'Re-share existing shares to use them in safe mode' |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
349 |
b' New shares will be created in safe mode.\n' |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
350 |
) |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
351 |
) |
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
|
352 |
if upgrade_actions.sharesafe.name in removedreqs: |
46003
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46002
diff
changeset
|
353 |
ui.warn( |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46002
diff
changeset
|
354 |
_( |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46002
diff
changeset
|
355 |
b'repository downgraded to not use share safe mode, ' |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46002
diff
changeset
|
356 |
b'existing shares will not work and needs to' |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46002
diff
changeset
|
357 |
b' be reshared.\n' |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46002
diff
changeset
|
358 |
) |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46002
diff
changeset
|
359 |
) |