annotate mercurial/upgrade.py @ 46184:cb8b2ee89a5d

copies: stop attempt to avoid extra dict copies around branching In the python code, we attempt to avoid unnecessary dict copies when gathering copy information. However that logic is wobbly and I keep running into case where independent branches affects each others. With the current code we can't ensure we are the only "user" of dict when dealing with merge. This caused havoc in the next series on tests I am about to introduce. So for now I am disabling the faulty optimisation. I believe we will need a dedicated overlay to deal with the "copy on write logic" to have something correct. I am also hoping to find time to build dedicated test case for this category of problem instead of relying on side effect in other tests. However for now I am focussing on another issue. Differential Revision: https://phab.mercurial-scm.org/D9608
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 15 Dec 2020 00:29:29 +0100
parents c407513a44a3
children 945b33a7edfd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31894
9379689b6c10 upgrade: update the header comment
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31893
diff changeset
1 # upgrade.py - functions for in place upgrade of Mercurial repository
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
2 #
31895
783b4c9bd5f5 upgrade: update the copyright statement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31894
diff changeset
3 # Copyright (c) 2016-present, Gregory Szorc
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
4 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8073
diff changeset
5 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9150
diff changeset
6 # GNU General Public License version 2 or any later version.
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
7
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
8 from __future__ import absolute_import
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
9
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
10 from .i18n import _
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
11 from . import (
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26425
diff changeset
12 error,
35343
06987c6971be upgrade: more standard creation of the temporary repository
Boris Feld <boris.feld@octobus.net>
parents: 35342
diff changeset
13 hg,
31893
165428b05fca upgrade: import 'localrepo' globally
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31875
diff changeset
14 localrepo,
38165
2ce60954b1b7 py3: wrap tempfile.mkdtemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents: 37444
diff changeset
15 pycompat,
46046
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
16 )
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
17
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
18 from .upgrade_utils import (
46047
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
19 actions as upgrade_actions,
46046
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
20 engine as upgrade_engine,
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
21 )
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
22
46047
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
23 allformatvariant = upgrade_actions.allformatvariant
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
24
41088
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
25 # search without '-' to support older form on newer client.
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
26 #
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
27 # We don't enforce backward compatibility for debug command so this
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
28 # might eventually be dropped. However, having to use two different
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
29 # forms in script when comparing result is anoying enough to add
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
30 # backward compatibility for a while.
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
31 legacy_opts_map = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
32 b'redeltaparent': b're-delta-parent',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
33 b'redeltamultibase': b're-delta-multibase',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
34 b'redeltaall': b're-delta-all',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
35 b'redeltafulladd': b're-delta-fulladd',
41088
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
36 }
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
37
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
38
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
39 def upgraderepo(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
40 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
41 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
42 run=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
43 optimize=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
44 backup=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
45 manifest=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
46 changelog=None,
45997
7c539f0febbe upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45995
diff changeset
47 filelogs=None,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
48 ):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
49 """Upgrade a repository in place."""
41088
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
50 if optimize is None:
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
51 optimize = []
44452
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44382
diff changeset
52 optimize = {legacy_opts_map.get(o, o) for o in optimize}
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
53 repo = repo.unfiltered()
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
54
46046
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
55 revlogs = set(upgrade_engine.UPGRADE_ALL_REVLOGS)
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
56 specentries = (
46046
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
57 (upgrade_engine.UPGRADE_CHANGELOG, changelog),
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
58 (upgrade_engine.UPGRADE_MANIFEST, manifest),
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
59 (upgrade_engine.UPGRADE_FILELOGS, filelogs),
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
60 )
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
61 specified = [(y, x) for (y, x) in specentries if x is not None]
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
62 if specified:
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
63 # we have some limitation on revlogs to be recloned
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
64 if any(x for y, x in specified):
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
65 revlogs = set()
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
66 for upgrade, enabled in specified:
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
67 if enabled:
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
68 revlogs.add(upgrade)
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
69 else:
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
70 # none are enabled
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
71 for upgrade, __ in specified:
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
72 revlogs.discard(upgrade)
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
73
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
74 # Ensure the repository can be upgraded.
46048
f4f956342cf1 upgrade: move requirements checking in a dedicated function
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46047
diff changeset
75 upgrade_actions.check_source_requirements(repo)
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
76
46051
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46050
diff changeset
77 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
78 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
79 newreqs.update(upgrade_actions.preservedrequirements(repo))
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
80
46051
72b7b4bf3e65 upgrade: extract the checking of target requirements change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46050
diff changeset
81 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
82
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
83 # 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
84 alloptimizations = upgrade_actions.findoptimizations(repo)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
85
31899
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
86 # Apply and Validate arguments.
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
87 optimizations = []
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
88 for o in alloptimizations:
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
89 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
90 optimizations.append(o)
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
91 optimize.discard(o.name)
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
92
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
93 if optimize: # anything left is unknown
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
94 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
95 _(b'unknown optimization action requested: %s')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
96 % 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
97 hint=_(b'run without arguments to see valid optimizations'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
98 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
99
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
100 deficiencies = upgrade_actions.finddeficiencies(repo)
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
101 actions = upgrade_actions.determineactions(
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
102 repo, deficiencies, repo.requirements, newreqs
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
103 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
104 actions.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
105 o
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
106 for o in sorted(optimizations)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
107 # determineactions could have added optimisation
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
108 if o not in actions
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
109 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
110
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
111 removedreqs = repo.requirements - newreqs
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
112 addedreqs = newreqs - repo.requirements
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
113
46046
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
114 if revlogs != upgrade_engine.UPGRADE_ALL_REVLOGS:
46047
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
115 incompatible = upgrade_actions.RECLONES_REQUIREMENTS & (
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
116 removedreqs | addedreqs
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
117 )
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
118 if incompatible:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
119 msg = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
120 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
121 b'change: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
122 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
123 ui.warn(msg % b', '.join(sorted(incompatible)))
46046
f105c49e89cd upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46035
diff changeset
124 revlogs = upgrade_engine.UPGRADE_ALL_REVLOGS
42832
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
125
43805
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
126 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
127 first = True
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
128 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
129 if not first:
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
130 ui.write(b', ')
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
131 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
132 first = False
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
133
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
134 def printrequirements():
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
135 ui.write(_(b'requirements\n'))
43805
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
136 ui.write(_(b' preserved: '))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
137 write_labeled(
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
138 newreqs & repo.requirements, "upgrade-repo.requirement.preserved"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
139 )
43805
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
140 ui.write((b'\n'))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
141 removed = repo.requirements - newreqs
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
142 if repo.requirements - newreqs:
43805
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
143 ui.write(_(b' removed: '))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
144 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
145 ui.write((b'\n'))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
146 added = newreqs - repo.requirements
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
147 if added:
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
148 ui.write(_(b' added: '))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
149 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
150 ui.write((b'\n'))
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
151 ui.write(b'\n')
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
152
44797
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
153 def printoptimisations():
46047
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
154 optimisations = [
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
155 a for a in actions if a.type == upgrade_actions.OPTIMISATION
4b89cf08d8dc upgrade: split definition and management of the actions from the main code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46046
diff changeset
156 ]
44797
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
157 optimisations.sort(key=lambda a: a.name)
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
158 if optimisations:
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
159 ui.write(_(b'optimisations: '))
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
160 write_labeled(
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
161 [a.name for a in optimisations],
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
162 "upgrade-repo.optimisation.performed",
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
163 )
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
164 ui.write(b'\n\n')
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
165
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
166 def printupgradeactions():
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
167 for a in actions:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
168 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
169
46035
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
170 def print_affected_revlogs():
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
171 if not revlogs:
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
172 ui.write((b'no revlogs to process\n'))
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
173 else:
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
174 ui.write((b'processed revlogs:\n'))
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
175 for r in sorted(revlogs):
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
176 ui.write((b' - %s\n' % r))
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
177 ui.write((b'\n'))
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
178
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
179 upgrade_op = upgrade_actions.UpgradeOperation(
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
180 newreqs,
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
181 [a.name for a in actions],
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
182 revlogs,
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
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
189 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
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:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
219 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
220 _(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
221 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
222 b'repository)\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
223 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
224 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
225
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
226 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
227 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
228 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
229 b'changes:\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
230 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
231 )
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
232
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
233 printrequirements()
44797
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
234 printoptimisations()
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
235 printupgradeactions()
46035
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
236 print_affected_revlogs()
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
237
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
238 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
239
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
240 if unusedoptimize:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
241 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
242 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
243 b'additional optimizations are available by specifying '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
244 b'"--optimize <name>":\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
245 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
246 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
247 for i in unusedoptimize:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
248 ui.status(_(b'%s\n %s\n\n') % (i.name, i.description))
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
249 return
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
250
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
251 # 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
252 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
253 printrequirements()
44797
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
254 printoptimisations()
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
255 printupgradeactions()
46035
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
256 print_affected_revlogs()
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
257
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
258 ui.status(_(b'beginning upgrade...\n'))
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
259 with repo.wlock(), repo.lock():
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
260 ui.status(_(b'repository locked and read-only\n'))
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
261 # Our strategy for upgrading the repository is to create a new,
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
262 # temporary repository, write data to it, then do a swap of the
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
263 # data. There are less heavyweight ways to do this, but it is easier
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
264 # to create a new repo object than to instantiate all the components
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
265 # (like the store) separately.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
266 tmppath = pycompat.mkdtemp(prefix=b'upgrade.', dir=repo.path)
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
267 backuppath = None
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
268 try:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
269 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
270 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
271 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
272 b'data: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
273 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
274 % tmppath
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
275 )
35342
75520786ad2f upgrade: use the repository 'ui' as the base for the new repository
Boris Feld <boris.feld@octobus.net>
parents: 35340
diff changeset
276
35379
6c28956ba2d4 upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents: 35345
diff changeset
277 # 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
278 repoui = repo.ui.__class__(repo.ui)
6c28956ba2d4 upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents: 35345
diff changeset
279 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
280
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
281 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
282 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
283 ui, repo, dstrepo, upgrade_op
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
284 )
41089
a59a74721c76 debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents: 41088
diff changeset
285 if not (backup or backuppath is None):
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
286 ui.status(
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
287 _(b'removing old repository content%s\n') % backuppath
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
288 )
41089
a59a74721c76 debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents: 41088
diff changeset
289 repo.vfs.rmtree(backuppath, forcibly=True)
a59a74721c76 debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents: 41088
diff changeset
290 backuppath = None
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
291
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
292 finally:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
293 ui.status(_(b'removing temporary repository %s\n') % tmppath)
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
294 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
295
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
296 if backuppath and not ui.quiet:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
297 ui.warn(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
298 _(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
299 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
300 ui.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
301 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
302 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
303 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
304 b'repository is verified\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
305 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
306 )
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
307
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
308 if upgrade_actions.sharesafe.name in addedreqs:
46002
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
309 ui.warn(
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
310 _(
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
311 b'repository upgraded to share safe mode, existing'
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
312 b' shares will still work in old non-safe mode. '
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
313 b'Re-share existing shares to use them in safe mode'
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
314 b' New shares will be created in safe mode.\n'
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
315 )
705c37f22859 upgrade: add support for experimental safe share mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45997
diff changeset
316 )
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
317 if upgrade_actions.sharesafe.name in removedreqs:
46003
c6a1fa42e325 upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46002
diff changeset
318 ui.warn(
c6a1fa42e325 upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46002
diff changeset
319 _(
c6a1fa42e325 upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46002
diff changeset
320 b'repository downgraded to not use share safe mode, '
c6a1fa42e325 upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46002
diff changeset
321 b'existing shares will not work and needs to'
c6a1fa42e325 upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46002
diff changeset
322 b' be reshared.\n'
c6a1fa42e325 upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46002
diff changeset
323 )
c6a1fa42e325 upgrade: add support to downgrade share safe mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46002
diff changeset
324 )