Mercurial > hg
annotate mercurial/upgrade.py @ 48826:3ce8001fd768
setup: remove more Python 2 support code
I'll inline print() etc in future patches.
Differential Revision: https://phab.mercurial-scm.org/D12270
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 02 Mar 2022 10:07:21 -0500 |
parents | 17eaeb06562c |
children | 6000f5b25c9b |
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, |
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, |
46235
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
15 lock as lockmod, |
38165
2ce60954b1b7
py3: wrap tempfile.mkdtemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents:
37444
diff
changeset
|
16 pycompat, |
46235
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
17 requirements as requirementsmod, |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
18 scmutil, |
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
19 ) |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
20 |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
21 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
|
22 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
|
23 engine as upgrade_engine, |
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
24 ) |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
25 |
46235
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
26 from .utils import ( |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
27 stringutil, |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
28 ) |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
29 |
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
|
30 allformatvariant = upgrade_actions.allformatvariant |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
31 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
32 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
33 def upgraderepo( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
34 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
35 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
36 run=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
37 optimize=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
38 backup=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
39 manifest=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
40 changelog=None, |
45997
7c539f0febbe
upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45995
diff
changeset
|
41 filelogs=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
42 ): |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
43 """Upgrade a repository in place.""" |
41088
5608b5a6c323
upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents:
40997
diff
changeset
|
44 if optimize is None: |
48472
a4d8de93023c
pytype: stop excluding upgrade.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
48468
diff
changeset
|
45 optimize = set() |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
46 repo = repo.unfiltered() |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
47 |
48445
e7420f75d90d
upgrade: make the list of explicitly specified revlog a dict
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48444
diff
changeset
|
48 specified_revlogs = {} |
e7420f75d90d
upgrade: make the list of explicitly specified revlog a dict
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48444
diff
changeset
|
49 if changelog is not None: |
e7420f75d90d
upgrade: make the list of explicitly specified revlog a dict
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48444
diff
changeset
|
50 specified_revlogs[upgrade_engine.UPGRADE_CHANGELOG] = changelog |
e7420f75d90d
upgrade: make the list of explicitly specified revlog a dict
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48444
diff
changeset
|
51 if manifest is not None: |
e7420f75d90d
upgrade: make the list of explicitly specified revlog a dict
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48444
diff
changeset
|
52 specified_revlogs[upgrade_engine.UPGRADE_MANIFEST] = manifest |
e7420f75d90d
upgrade: make the list of explicitly specified revlog a dict
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48444
diff
changeset
|
53 if filelogs is not None: |
e7420f75d90d
upgrade: make the list of explicitly specified revlog a dict
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48444
diff
changeset
|
54 specified_revlogs[upgrade_engine.UPGRADE_FILELOGS] = filelogs |
42830
cf2b765cecd7
upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42693
diff
changeset
|
55 |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
56 # 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
|
57 upgrade_actions.check_source_requirements(repo) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
58 |
46051
72b7b4bf3e65
upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
59 default_options = localrepo.defaultcreateopts(repo.ui) |
72b7b4bf3e65
upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
60 newreqs = localrepo.newreporequirements(repo.ui, default_options) |
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
|
61 newreqs.update(upgrade_actions.preservedrequirements(repo)) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
62 |
46051
72b7b4bf3e65
upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46050
diff
changeset
|
63 upgrade_actions.check_requirements_changes(repo, newreqs) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
64 |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
65 # 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
|
66 alloptimizations = upgrade_actions.findoptimizations(repo) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
67 |
31899
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
68 # Apply and Validate arguments. |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
69 optimizations = [] |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
70 for o in alloptimizations: |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
71 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
|
72 optimizations.append(o) |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
73 optimize.discard(o.name) |
cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31898
diff
changeset
|
74 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
75 if optimize: # anything left is unknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
76 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
77 _(b'unknown optimization action requested: %s') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
78 % 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
|
79 hint=_(b'run without arguments to see valid optimizations'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
80 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
81 |
46205
53d083fa1f83
upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46192
diff
changeset
|
82 format_upgrades = upgrade_actions.find_format_upgrades(repo) |
46210
6b40aac4da8e
upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46209
diff
changeset
|
83 up_actions = upgrade_actions.determine_upgrade_actions( |
46209
a51d345f1404
upgrade: move optimization addition to determineactions()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46208
diff
changeset
|
84 repo, format_upgrades, optimizations, repo.requirements, newreqs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
85 ) |
46213
30310886d423
upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46210
diff
changeset
|
86 removed_actions = upgrade_actions.find_format_downgrades(repo) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
87 |
48444
6e045497b20b
upgrade: move the revlog selection code lower down the chain
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46414
diff
changeset
|
88 # check if we need to touch revlog and if so, which ones |
6e045497b20b
upgrade: move the revlog selection code lower down the chain
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46414
diff
changeset
|
89 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
90 touched_revlogs = set() |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
91 overwrite_msg = _(b'warning: ignoring %14s, as upgrade is changing: %s\n') |
48447
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
92 select_msg = _(b'note: selecting %s for processing to change: %s\n') |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
93 msg_issued = 0 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
94 |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
95 FL = upgrade_engine.UPGRADE_FILELOGS |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
96 MN = upgrade_engine.UPGRADE_MANIFEST |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
97 CL = upgrade_engine.UPGRADE_CHANGELOG |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
98 |
48448
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
99 if optimizations: |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
100 if any(specified_revlogs.values()): |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
101 # we have some limitation on revlogs to be recloned |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
102 for rl, enabled in specified_revlogs.items(): |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
103 if enabled: |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
104 touched_revlogs.add(rl) |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
105 else: |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
106 touched_revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS) |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
107 for rl, enabled in specified_revlogs.items(): |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
108 if not enabled: |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
109 touched_revlogs.discard(rl) |
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
110 |
48779
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
111 if repo.shared(): |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
112 unsafe_actions = set() |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
113 unsafe_actions.update(up_actions) |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
114 unsafe_actions.update(removed_actions) |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
115 unsafe_actions.update(optimizations) |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
116 unsafe_actions = [ |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
117 a for a in unsafe_actions if not a.compatible_with_share |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
118 ] |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
119 unsafe_actions.sort(key=lambda a: a.name) |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
120 if unsafe_actions: |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
121 m = _(b'cannot use these actions on a share repository: %s') |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
122 h = _(b'upgrade the main repository directly') |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
123 actions = b', '.join(a.name for a in unsafe_actions) |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
124 m %= actions |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
125 raise error.Abort(m, hint=h) |
17eaeb06562c
upgrade: prepare code (and output) for the idea of upgrading share
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48472
diff
changeset
|
126 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
127 for action in sorted(up_actions + removed_actions, key=lambda a: a.name): |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
128 # optimisation does not "requires anything, they just needs it. |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
129 if action.type != upgrade_actions.FORMAT_VARIANT: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
130 continue |
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
|
131 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
132 if action.touches_filelogs and FL not in touched_revlogs: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
133 if FL in specified_revlogs: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
134 if not specified_revlogs[FL]: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
135 msg = overwrite_msg % (b'--no-filelogs', action.name) |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
136 ui.warn(msg) |
48447
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
137 msg_issued = 2 |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
138 else: |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
139 msg = select_msg % (b'all-filelogs', action.name) |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
140 ui.status(msg) |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
141 if not ui.quiet: |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
142 msg_issued = 1 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
143 touched_revlogs.add(FL) |
48447
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
144 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
145 if action.touches_manifests and MN not in touched_revlogs: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
146 if MN in specified_revlogs: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
147 if not specified_revlogs[MN]: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
148 msg = overwrite_msg % (b'--no-manifest', action.name) |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
149 ui.warn(msg) |
48447
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
150 msg_issued = 2 |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
151 else: |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
152 msg = select_msg % (b'all-manifestlogs', action.name) |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
153 ui.status(msg) |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
154 if not ui.quiet: |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
155 msg_issued = 1 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
156 touched_revlogs.add(MN) |
48447
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
157 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
158 if action.touches_changelog and CL not in touched_revlogs: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
159 if CL in specified_revlogs: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
160 if not specified_revlogs[CL]: |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
161 msg = overwrite_msg % (b'--no-changelog', action.name) |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
162 ui.warn(msg) |
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
163 msg_issued = True |
48447
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
164 else: |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
165 msg = select_msg % (b'changelog', action.name) |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
166 ui.status(msg) |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
167 if not ui.quiet: |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
168 msg_issued = 1 |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
169 touched_revlogs.add(CL) |
48447
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
170 if msg_issued >= 2: |
48446
1d0978cfe968
upgrade: explicitly warn when a `--no-xxx` flag is overwritten
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48445
diff
changeset
|
171 ui.warn((b"\n")) |
48447
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
172 elif msg_issued >= 1: |
8405c1bffacf
upgrade: issue a message when a revlog type has to be upgraded
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48446
diff
changeset
|
173 ui.status((b"\n")) |
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
|
174 |
46056
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46051
diff
changeset
|
175 upgrade_op = upgrade_actions.UpgradeOperation( |
46188
945b33a7edfd
upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46056
diff
changeset
|
176 ui, |
46056
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46051
diff
changeset
|
177 newreqs, |
46191
aba979b1b90b
upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46190
diff
changeset
|
178 repo.requirements, |
46210
6b40aac4da8e
upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46209
diff
changeset
|
179 up_actions, |
46213
30310886d423
upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46210
diff
changeset
|
180 removed_actions, |
48448
62e6222cc5b6
upgrade: only process revlogs that needs it by default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48447
diff
changeset
|
181 touched_revlogs, |
46375
2e8a844d0ae0
upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46333
diff
changeset
|
182 backup, |
46056
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46051
diff
changeset
|
183 ) |
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46051
diff
changeset
|
184 |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
185 if not run: |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
186 fromconfig = [] |
31904
3c77f03f16b3
upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31903
diff
changeset
|
187 onlydefault = [] |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
188 |
46205
53d083fa1f83
upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46192
diff
changeset
|
189 for d in format_upgrades: |
32031
11a2461fc9b1
upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
32030
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 onlydefault.append(d) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
194 |
31904
3c77f03f16b3
upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31903
diff
changeset
|
195 if fromconfig or onlydefault: |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
196 |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
197 if fromconfig: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
198 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
199 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
200 b'repository lacks features recommended by ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
201 b'current config options:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
202 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
203 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
204 for i in fromconfig: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
205 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
|
206 |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
207 if onlydefault: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
208 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
209 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
210 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
|
211 b'config options:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
212 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
213 ) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
214 for i in onlydefault: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
215 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
|
216 |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
217 ui.status(b'\n') |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
218 else: |
46205
53d083fa1f83
upgrade: rename finddeficiences() to find_format_upgrades()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46192
diff
changeset
|
219 ui.status(_(b'(no format upgrades found in existing repository)\n')) |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
220 |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
221 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
222 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
223 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
|
224 b'changes:\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
225 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
226 ) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
227 |
46191
aba979b1b90b
upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46190
diff
changeset
|
228 upgrade_op.print_requirements() |
46190
9ab2ab5bf9af
upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46189
diff
changeset
|
229 upgrade_op.print_optimisations() |
46189
dfddcbb0c244
upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46188
diff
changeset
|
230 upgrade_op.print_upgrade_actions() |
46188
945b33a7edfd
upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46056
diff
changeset
|
231 upgrade_op.print_affected_revlogs() |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
232 |
46192
25d11b24dedf
upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
233 if upgrade_op.unused_optimizations: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
234 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
235 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
236 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
|
237 b'"--optimize <name>":\n\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
238 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
239 ) |
46192
25d11b24dedf
upgrade: move printing of unused optimizations to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
240 upgrade_op.print_unused_optimizations() |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
241 return |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
242 |
46231
d3113c4cf52c
upgrade: don't perform anything if nothing to do
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46222
diff
changeset
|
243 if not (upgrade_op.upgrade_actions or upgrade_op.removed_actions): |
d3113c4cf52c
upgrade: don't perform anything if nothing to do
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46222
diff
changeset
|
244 ui.status(_(b'nothing to do\n')) |
d3113c4cf52c
upgrade: don't perform anything if nothing to do
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46222
diff
changeset
|
245 return |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
246 # 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
|
247 ui.write(_(b'upgrade will perform the following actions:\n\n')) |
46191
aba979b1b90b
upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46190
diff
changeset
|
248 upgrade_op.print_requirements() |
46190
9ab2ab5bf9af
upgrade: move `printoptimisations() to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46189
diff
changeset
|
249 upgrade_op.print_optimisations() |
46189
dfddcbb0c244
upgrade: move `printupgradeactions()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46188
diff
changeset
|
250 upgrade_op.print_upgrade_actions() |
46188
945b33a7edfd
upgrade: move `print_affected_revlogs()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46056
diff
changeset
|
251 upgrade_op.print_affected_revlogs() |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
252 |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
253 ui.status(_(b'beginning upgrade...\n')) |
33438 | 254 with repo.wlock(), repo.lock(): |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
255 ui.status(_(b'repository locked and read-only\n')) |
33438 | 256 # Our strategy for upgrading the repository is to create a new, |
257 # temporary repository, write data to it, then do a swap of the | |
258 # data. There are less heavyweight ways to do this, but it is easier | |
259 # to create a new repo object than to instantiate all the components | |
260 # (like the store) separately. | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
261 tmppath = pycompat.mkdtemp(prefix=b'upgrade.', dir=repo.path) |
33438 | 262 backuppath = None |
263 try: | |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
264 ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
265 _( |
46222
e22aed089567
upgrade: migrated -> upgraded in ui messages
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46221
diff
changeset
|
266 b'creating temporary repository to stage upgraded ' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
267 b'data: %s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
268 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
269 % tmppath |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
270 ) |
35342
75520786ad2f
upgrade: use the repository 'ui' as the base for the new repository
Boris Feld <boris.feld@octobus.net>
parents:
35340
diff
changeset
|
271 |
35379
6c28956ba2d4
upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents:
35345
diff
changeset
|
272 # 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
|
273 repoui = repo.ui.__class__(repo.ui) |
6c28956ba2d4
upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents:
35345
diff
changeset
|
274 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
|
275 |
33438 | 276 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
|
277 backuppath = upgrade_engine.upgrade( |
46056
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46051
diff
changeset
|
278 ui, repo, dstrepo, upgrade_op |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
279 ) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
280 |
33438 | 281 finally: |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
282 ui.status(_(b'removing temporary repository %s\n') % tmppath) |
33438 | 283 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
|
284 |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
285 if backuppath and not ui.quiet: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
286 ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
287 _(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
|
288 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
289 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
290 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
291 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
|
292 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
|
293 b'repository is verified\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
294 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
295 ) |
46002
705c37f22859
upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45997
diff
changeset
|
296 |
46213
30310886d423
upgrade: introduce post upgrade and downgrade message for improvements
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46210
diff
changeset
|
297 upgrade_op.print_post_op_messages() |
46235
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
298 |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
299 |
46332
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
300 def upgrade_share_to_safe( |
46333
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
301 ui, |
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
302 hgvfs, |
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
303 storevfs, |
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
304 current_requirements, |
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
305 mismatch_config, |
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
306 mismatch_warn, |
46332
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
307 ): |
46235
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
308 """Upgrades a share to use share-safe mechanism""" |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
309 wlock = None |
46329
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
310 store_requirements = localrepo._readrequires(storevfs, False) |
46330
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
311 original_crequirements = current_requirements.copy() |
46329
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
312 # after upgrade, store requires will be shared, so lets find |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
313 # the requirements which are not present in store and |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
314 # write them to share's .hg/requires |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
315 diffrequires = current_requirements - store_requirements |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
316 # add share-safe requirement as it will mark the share as share-safe |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
317 diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT) |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
318 current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) |
46332
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
319 # in `allow` case, we don't try to upgrade, we just respect the source |
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
320 # state, update requirements and continue |
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
321 if mismatch_config == b'allow': |
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
322 return |
46235
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
323 try: |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
324 wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) |
46330
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
325 # some process might change the requirement in between, re-read |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
326 # and update current_requirements |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
327 locked_requirements = localrepo._readrequires(hgvfs, True) |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
328 if locked_requirements != original_crequirements: |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
329 removed = current_requirements - locked_requirements |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
330 # update current_requirements in place because it's passed |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
331 # as reference |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
332 current_requirements -= removed |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
333 current_requirements |= locked_requirements |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
334 diffrequires = current_requirements - store_requirements |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
335 # add share-safe requirement as it will mark the share as share-safe |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
336 diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT) |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
337 current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) |
46235
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
338 scmutil.writerequires(hgvfs, diffrequires) |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
339 ui.warn(_(b'repository upgraded to use share-safe mode\n')) |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
340 except error.LockError as e: |
46348
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
341 hint = _( |
48440
cb477edeca79
upgrade: byteify a few error messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
46414
diff
changeset
|
342 b"see `hg help config.format.use-share-safe` for more information" |
46348
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
343 ) |
46332
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
344 if mismatch_config == b'upgrade-abort': |
46239
d159d0fafa78
sharesafe: introduce config to disallow outdated shares if upgrade fails
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46238
diff
changeset
|
345 raise error.Abort( |
d159d0fafa78
sharesafe: introduce config to disallow outdated shares if upgrade fails
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46238
diff
changeset
|
346 _(b'failed to upgrade share, got error: %s') |
46348
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
347 % stringutil.forcebytestr(e.strerror), |
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
348 hint=hint, |
46239
d159d0fafa78
sharesafe: introduce config to disallow outdated shares if upgrade fails
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46238
diff
changeset
|
349 ) |
46333
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
350 elif mismatch_warn: |
46238
9796cf108e4e
sharesafe: make warning about outdated share configurable
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46236
diff
changeset
|
351 ui.warn( |
9796cf108e4e
sharesafe: make warning about outdated share configurable
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46236
diff
changeset
|
352 _(b'failed to upgrade share, got error: %s\n') |
46348
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
353 % stringutil.forcebytestr(e.strerror), |
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
354 hint=hint, |
46238
9796cf108e4e
sharesafe: make warning about outdated share configurable
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46236
diff
changeset
|
355 ) |
46235
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
356 finally: |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
357 if wlock: |
0babe12ef35d
sharesafe: introduce functionality to automatically upgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46231
diff
changeset
|
358 wlock.release() |
46236
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
359 |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
360 |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
361 def downgrade_share_to_non_safe( |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
362 ui, |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
363 hgvfs, |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
364 sharedvfs, |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
365 current_requirements, |
46332
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
366 mismatch_config, |
46333
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
367 mismatch_warn, |
46236
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
368 ): |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
369 """Downgrades a share which use share-safe to not use it""" |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
370 wlock = None |
46329
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
371 source_requirements = localrepo._readrequires(sharedvfs, True) |
46330
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
372 original_crequirements = current_requirements.copy() |
46329
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
373 # we cannot be 100% sure on which requirements were present in store when |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
374 # the source supported share-safe. However, we do know that working |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
375 # directory requirements were not there. Hence we remove them |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
376 source_requirements -= requirementsmod.WORKING_DIR_REQUIREMENTS |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
377 current_requirements |= source_requirements |
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
378 current_requirements.remove(requirementsmod.SHARESAFE_REQUIREMENT) |
46332
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
379 if mismatch_config == b'allow': |
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
380 return |
46329
17176f64a03d
upgrade: take lock only for part where it's required
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46239
diff
changeset
|
381 |
46236
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
382 try: |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
383 wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) |
46330
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
384 # some process might change the requirement in between, re-read |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
385 # and update current_requirements |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
386 locked_requirements = localrepo._readrequires(hgvfs, True) |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
387 if locked_requirements != original_crequirements: |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
388 removed = current_requirements - locked_requirements |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
389 # update current_requirements in place because it's passed |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
390 # as reference |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
391 current_requirements -= removed |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
392 current_requirements |= locked_requirements |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
393 current_requirements |= source_requirements |
02f3badf9011
upgrade: re-read current requirements after taking lock
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46329
diff
changeset
|
394 current_requirements -= set(requirementsmod.SHARESAFE_REQUIREMENT) |
46236
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
395 scmutil.writerequires(hgvfs, current_requirements) |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
396 ui.warn(_(b'repository downgraded to not use share-safe mode\n')) |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
397 except error.LockError as e: |
46348
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
398 hint = _( |
48440
cb477edeca79
upgrade: byteify a few error messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
46414
diff
changeset
|
399 b"see `hg help config.format.use-share-safe` for more information" |
46348
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
400 ) |
46332
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
401 # If upgrade-abort is set, abort when upgrade fails, else let the |
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
402 # process continue as `upgrade-allow` is set |
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
403 if mismatch_config == b'downgrade-abort': |
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
404 raise error.Abort( |
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
405 _(b'failed to downgrade share, got error: %s') |
46348
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
406 % stringutil.forcebytestr(e.strerror), |
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
407 hint=hint, |
46332
cc3452d2dfa4
share: rework config options to be much clearer and easier
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46330
diff
changeset
|
408 ) |
46333
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
409 elif mismatch_warn: |
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
410 ui.warn( |
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
411 _(b'failed to downgrade share, got error: %s\n') |
46348
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
412 % stringutil.forcebytestr(e.strerror), |
4a58561ace0f
share-share: have the hint issue more consistently and point to the right doc
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46333
diff
changeset
|
413 hint=hint, |
46333
2eb5fe13461b
share: rename share-safe warning config
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46332
diff
changeset
|
414 ) |
46236
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
415 finally: |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
416 if wlock: |
eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46235
diff
changeset
|
417 wlock.release() |