Mercurial > hg-stable
annotate mercurial/upgrade.py @ 46054:ad9dd4d333be
upgrade: drop an outdated comment
We can control the added/removed requirement through config for multiple years.
Differential Revision: https://phab.mercurial-scm.org/D9484
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 01 Dec 2020 15:50:12 +0100 |
parents | f4f956342cf1 |
children | 72b7b4bf3e65 |
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 | 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, |
35352
06987c6971be
upgrade: more standard creation of the temporary repository
Boris Feld <boris.feld@octobus.net>
parents:
35351
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, |
38198
2ce60954b1b7
py3: wrap tempfile.mkdtemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents:
37444
diff
changeset
|
15 pycompat, |
46050
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
diff
changeset
|
16 ) |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
diff
changeset
|
17 |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
diff
changeset
|
18 from .upgrade_utils import ( |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
19 actions as upgrade_actions, |
46050
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
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 |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
23 allformatvariant = upgrade_actions.allformatvariant |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
24 |
41091
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
41007
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:
41007
diff
changeset
|
26 # |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
41007
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:
41007
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:
41007
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:
41007
diff
changeset
|
30 # backward compatibility for a while. |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
41007
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', |
41091
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
41007
diff
changeset
|
36 } |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
41007
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, |
46012
7c539f0febbe
upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46010
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.""" |
41091
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
41007
diff
changeset
|
50 if optimize is None: |
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
41007
diff
changeset
|
51 optimize = [] |
44470
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44413
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 |
46050
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
diff
changeset
|
55 revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS) |
45996
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45995
diff
changeset
|
56 specentries = ( |
46050
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
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:
46039
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:
46039
diff
changeset
|
59 (upgrade_engine.UPGRADE_FILELOGS, filelogs), |
45996
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45995
diff
changeset
|
60 ) |
42840
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42715
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:
42715
diff
changeset
|
62 if specified: |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42715
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:
42715
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:
42715
diff
changeset
|
65 revlogs = set() |
45996
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45995
diff
changeset
|
66 for upgrade, enabled in specified: |
42840
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42715
diff
changeset
|
67 if enabled: |
45996
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45995
diff
changeset
|
68 revlogs.add(upgrade) |
42840
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42715
diff
changeset
|
69 else: |
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42715
diff
changeset
|
70 # none are enabled |
45996
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45995
diff
changeset
|
71 for upgrade, __ in specified: |
53bde3ad0270
upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45995
diff
changeset
|
72 revlogs.discard(upgrade) |
42840
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42715
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. |
46052
f4f956342cf1
upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46051
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 |
39997
dbcb466d0065
localrepo: define storage backend in creation options (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39875
diff
changeset
|
77 newreqs = localrepo.newreporequirements( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
78 repo.ui, localrepo.defaultcreateopts(repo.ui) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
79 ) |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
80 newreqs.update(upgrade_actions.preservedrequirements(repo)) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
81 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
82 noremovereqs = ( |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
83 repo.requirements |
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
84 - newreqs |
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
85 - upgrade_actions.supportremovedrequirements(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
86 ) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
87 if noremovereqs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
88 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
89 _( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
90 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
|
91 b'removed: %s' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
92 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
93 % _(b', ').join(sorted(noremovereqs)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
94 ) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
95 |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
96 noaddreqs = ( |
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
97 newreqs |
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
98 - repo.requirements |
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
99 - 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:
46050
diff
changeset
|
100 ) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
101 if noaddreqs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
102 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
103 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
104 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
|
105 b'requirement: %s' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
106 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
107 % _(b', ').join(sorted(noaddreqs)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
108 ) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
109 |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
110 unsupportedreqs = newreqs - upgrade_actions.supporteddestrequirements(repo) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
111 if unsupportedreqs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
112 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
113 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
114 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
|
115 b'destination requirement: %s' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
116 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
117 % _(b', ').join(sorted(unsupportedreqs)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
118 ) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
119 |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
120 # Find and validate all improvements that can be made. |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
121 alloptimizations = upgrade_actions.findoptimizations(repo) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
122 |
31899
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
123 # Apply and Validate arguments. |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
124 optimizations = [] |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
125 for o in alloptimizations: |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
126 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
|
127 optimizations.append(o) |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
128 optimize.discard(o.name) |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
129 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
130 if optimize: # anything left is unknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
131 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
132 _(b'unknown optimization action requested: %s') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
133 % 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
|
134 hint=_(b'run without arguments to see valid optimizations'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
135 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
136 |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
137 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:
46050
diff
changeset
|
138 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:
46050
diff
changeset
|
139 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:
46050
diff
changeset
|
140 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
141 actions.extend( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
142 o |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
143 for o in sorted(optimizations) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
144 # determineactions could have added optimisation |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
145 if o not in actions |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
146 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
147 |
42842
a3c2ffcd266f
upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42841
diff
changeset
|
148 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:
42841
diff
changeset
|
149 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:
42841
diff
changeset
|
150 |
46050
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
diff
changeset
|
151 if revlogs != upgrade_engine.UPGRADE_ALL_REVLOGS: |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
152 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:
46050
diff
changeset
|
153 removedreqs | addedreqs |
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
154 ) |
42842
a3c2ffcd266f
upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42841
diff
changeset
|
155 if incompatible: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
156 msg = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
157 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
|
158 b'change: %s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
159 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
160 ui.warn(msg % b', '.join(sorted(incompatible))) |
46050
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
diff
changeset
|
161 revlogs = upgrade_engine.UPGRADE_ALL_REVLOGS |
42842
a3c2ffcd266f
upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42841
diff
changeset
|
162 |
43823
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
163 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
|
164 first = True |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
165 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
|
166 if not first: |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
167 ui.write(b', ') |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
168 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
|
169 first = False |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
170 |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
171 def printrequirements(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
172 ui.write(_(b'requirements\n')) |
43823
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
173 ui.write(_(b' preserved: ')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
174 write_labeled( |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
175 newreqs & repo.requirements, "upgrade-repo.requirement.preserved" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
176 ) |
43823
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
177 ui.write((b'\n')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
178 removed = repo.requirements - newreqs |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
179 if repo.requirements - newreqs: |
43823
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
180 ui.write(_(b' removed: ')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
181 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
|
182 ui.write((b'\n')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
183 added = newreqs - repo.requirements |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
184 if added: |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
185 ui.write(_(b' added: ')) |
ad84fc97d120
upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43148
diff
changeset
|
186 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
|
187 ui.write((b'\n')) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
188 ui.write(b'\n') |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
189 |
44874
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
190 def printoptimisations(): |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
191 optimisations = [ |
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
192 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:
46050
diff
changeset
|
193 ] |
44874
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
194 optimisations.sort(key=lambda a: a.name) |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
195 if optimisations: |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
196 ui.write(_(b'optimisations: ')) |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
197 write_labeled( |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
198 [a.name for a in optimisations], |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
199 "upgrade-repo.optimisation.performed", |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
200 ) |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
201 ui.write(b'\n\n') |
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
202 |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
203 def printupgradeactions(): |
31903
fa1088de2119
upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31902
diff
changeset
|
204 for a in actions: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
205 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
|
206 |
46039
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46018
diff
changeset
|
207 def print_affected_revlogs(): |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46018
diff
changeset
|
208 if not revlogs: |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46018
diff
changeset
|
209 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:
46018
diff
changeset
|
210 else: |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46018
diff
changeset
|
211 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:
46018
diff
changeset
|
212 for r in sorted(revlogs): |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46018
diff
changeset
|
213 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:
46018
diff
changeset
|
214 ui.write((b'\n')) |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46018
diff
changeset
|
215 |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
216 if not run: |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
217 fromconfig = [] |
31904
3c77f03f16b3
upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31903
diff
changeset
|
218 onlydefault = [] |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
219 |
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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 onlydefault.append(d) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
225 |
31904
3c77f03f16b3
upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31903
diff
changeset
|
226 if fromconfig or onlydefault: |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
227 |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
228 if fromconfig: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
229 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
230 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
231 b'repository lacks features recommended by ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
232 b'current config options:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
233 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
234 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
235 for i in fromconfig: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
236 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
|
237 |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
238 if onlydefault: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
239 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
240 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
241 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
|
242 b'config options:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
243 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
244 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
245 for i in onlydefault: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
246 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
|
247 |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
248 ui.status(b'\n') |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
249 else: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
250 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
251 _( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 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
|
253 b'repository)\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
254 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
255 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
256 |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
257 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
258 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
259 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
|
260 b'changes:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
261 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
262 ) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
263 |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
264 printrequirements() |
44874
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
265 printoptimisations() |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
266 printupgradeactions() |
46039
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46018
diff
changeset
|
267 print_affected_revlogs() |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
268 |
31903
fa1088de2119
upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31902
diff
changeset
|
269 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
|
270 |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
271 if unusedoptimize: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
272 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
273 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
274 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
|
275 b'"--optimize <name>":\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
276 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
277 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
278 for i in unusedoptimize: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
279 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
|
280 return |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
281 |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
282 # 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
|
283 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
|
284 printrequirements() |
44874
5ee4b2119af9
upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44741
diff
changeset
|
285 printoptimisations() |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
286 printupgradeactions() |
46039
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46018
diff
changeset
|
287 print_affected_revlogs() |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
288 |
31903
fa1088de2119
upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31902
diff
changeset
|
289 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
|
290 |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
291 ui.status(_(b'beginning upgrade...\n')) |
33438 | 292 with repo.wlock(), repo.lock(): |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
293 ui.status(_(b'repository locked and read-only\n')) |
33438 | 294 # Our strategy for upgrading the repository is to create a new, |
295 # temporary repository, write data to it, then do a swap of the | |
296 # data. There are less heavyweight ways to do this, but it is easier | |
297 # to create a new repo object than to instantiate all the components | |
298 # (like the store) separately. | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
299 tmppath = pycompat.mkdtemp(prefix=b'upgrade.', dir=repo.path) |
33438 | 300 backuppath = None |
301 try: | |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
302 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
303 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
304 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
|
305 b'data: %s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
306 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
307 % tmppath |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
308 ) |
35351
75520786ad2f
upgrade: use the repository 'ui' as the base for the new repository
Boris Feld <boris.feld@octobus.net>
parents:
35349
diff
changeset
|
309 |
35388
6c28956ba2d4
upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents:
35354
diff
changeset
|
310 # 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:
35354
diff
changeset
|
311 repoui = repo.ui.__class__(repo.ui) |
6c28956ba2d4
upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents:
35354
diff
changeset
|
312 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
|
313 |
33438 | 314 with dstrepo.wlock(), dstrepo.lock(): |
46050
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46039
diff
changeset
|
315 backuppath = upgrade_engine.upgrade( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
316 ui, repo, dstrepo, newreqs, upgradeactions, revlogs=revlogs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
317 ) |
41092
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
41091
diff
changeset
|
318 if not (backup or backuppath is None): |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
319 ui.status( |
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
320 _(b'removing old repository content%s\n') % backuppath |
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
321 ) |
41092
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
41091
diff
changeset
|
322 repo.vfs.rmtree(backuppath, forcibly=True) |
a59a74721c76
debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents:
41091
diff
changeset
|
323 backuppath = None |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
324 |
33438 | 325 finally: |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
326 ui.status(_(b'removing temporary repository %s\n') % tmppath) |
33438 | 327 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
|
328 |
44875
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44874
diff
changeset
|
329 if backuppath and not ui.quiet: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
330 ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
331 _(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
|
332 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
333 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
334 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
335 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
|
336 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
|
337 b'repository is verified\n' |
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 ) |
46017
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46012
diff
changeset
|
340 |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
341 if upgrade_actions.sharesafe.name in addedreqs: |
46017
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46012
diff
changeset
|
342 ui.warn( |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46012
diff
changeset
|
343 _( |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46012
diff
changeset
|
344 b'repository upgraded to share safe mode, existing' |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46012
diff
changeset
|
345 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:
46012
diff
changeset
|
346 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:
46012
diff
changeset
|
347 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:
46012
diff
changeset
|
348 ) |
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46012
diff
changeset
|
349 ) |
46051
4b89cf08d8dc
upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
350 if upgrade_actions.sharesafe.name in removedreqs: |
46018
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46017
diff
changeset
|
351 ui.warn( |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46017
diff
changeset
|
352 _( |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46017
diff
changeset
|
353 b'repository downgraded to not use share safe mode, ' |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46017
diff
changeset
|
354 b'existing shares will not work and needs to' |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46017
diff
changeset
|
355 b' be reshared.\n' |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46017
diff
changeset
|
356 ) |
c6a1fa42e325
upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46017
diff
changeset
|
357 ) |