annotate mercurial/upgrade.py @ 31872:3c001db97c71

upgrade: drop the prefix to the 'determineactions' function Now that we are in the 'upgrade' module we can simplify the name.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 10 Apr 2017 18:05:57 +0200
parents 5881f76323c2
children d6c2005484b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
1 # repair.py - functions for repository repair for mercurial
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
2 #
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
3 # Copyright 2005, 2006 Chris Mason <mason@suse.com>
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
4 # Copyright 2007 Matt Mackall
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
5 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8073
diff changeset
6 # 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
7 # 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
8
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
9 from __future__ import absolute_import
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
10
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
11 import stat
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
12 import tempfile
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
13
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
14 from .i18n import _
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
15 from . import (
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
16 changelog,
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26425
diff changeset
17 error,
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
18 manifest,
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
19 revlog,
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
20 scmutil,
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
21 util,
31242
254f98326eef vfs: use 'vfs' module directly in 'mercurial.repair'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30995
diff changeset
22 vfs as vfsmod,
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
23 )
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
24
31865
5dcaa0f4455b upgrade: drop the prefix to the 'requiredsourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31864
diff changeset
25 def requiredsourcerequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
26 """Obtain requirements required to be present to upgrade a repo.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
27
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
28 An upgrade will not be allowed if the repository doesn't have the
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
29 requirements returned by this function.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
30 """
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
31 return set([
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
32 # Introduced in Mercurial 0.9.2.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
33 'revlogv1',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
34 # Introduced in Mercurial 0.9.2.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
35 'store',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
36 ])
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
37
31866
1454726b6d7c upgrade: drop the prefix to the 'blocksourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31865
diff changeset
38 def blocksourcerequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
39 """Obtain requirements that will prevent an upgrade from occurring.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
40
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
41 An upgrade cannot be performed if the source repository contains a
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
42 requirements in the returned set.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
43 """
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
44 return set([
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
45 # The upgrade code does not yet support these experimental features.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
46 # This is an artificial limitation.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
47 'manifestv2',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
48 'treemanifest',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
49 # This was a precursor to generaldelta and was never enabled by default.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
50 # It should (hopefully) not exist in the wild.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
51 'parentdelta',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
52 # Upgrade should operate on the actual store, not the shared link.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
53 'shared',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
54 ])
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
55
31867
cc60b6c36637 upgrade: drop the prefix to the 'supportremovedrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31866
diff changeset
56 def supportremovedrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
57 """Obtain requirements that can be removed during an upgrade.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
58
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
59 If an upgrade were to create a repository that dropped a requirement,
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
60 the dropped requirement must appear in the returned set for the upgrade
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
61 to be allowed.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
62 """
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
63 return set()
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
64
31870
49011f1cedd4 upgrade: drop the prefix to the 'supporteddestrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31869
diff changeset
65 def supporteddestrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
66 """Obtain requirements that upgrade supports in the destination.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
67
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
68 If the result of the upgrade would create requirements not in this set,
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
69 the upgrade is disallowed.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
70
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
71 Extensions should monkeypatch this to add their custom requirements.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
72 """
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
73 return set([
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
74 'dotencode',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
75 'fncache',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
76 'generaldelta',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
77 'revlogv1',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
78 'store',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
79 ])
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
80
31869
fe5e30b58934 upgrade: drop the prefix to the 'allowednewrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31868
diff changeset
81 def allowednewrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
82 """Obtain requirements that can be added to a repository during upgrade.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
83
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
84 This is used to disallow proposed requirements from being added when
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
85 they weren't present before.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
86
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
87 We use a list of allowed requirement additions instead of a list of known
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
88 bad additions because the whitelist approach is safer and will prevent
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
89 future, unknown requirements from accidentally being added.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
90 """
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
91 return set([
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
92 'dotencode',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
93 'fncache',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
94 'generaldelta',
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
95 ])
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
96
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
97 deficiency = 'deficiency'
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
98 optimisation = 'optimization'
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
99
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
100 class improvement(object):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
101 """Represents an improvement that can be made as part of an upgrade.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
102
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
103 The following attributes are defined on each instance:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
104
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
105 name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
106 Machine-readable string uniquely identifying this improvement. It
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
107 will be mapped to an action later in the upgrade process.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
108
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
109 type
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
110 Either ``deficiency`` or ``optimisation``. A deficiency is an obvious
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
111 problem. An optimization is an action (sometimes optional) that
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
112 can be taken to further improve the state of the repository.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
113
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
114 description
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
115 Message intended for humans explaining the improvement in more detail,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
116 including the implications of it. For ``deficiency`` types, should be
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
117 worded in the present tense. For ``optimisation`` types, should be
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
118 worded in the future tense.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
119
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
120 upgrademessage
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
121 Message intended for humans explaining what an upgrade addressing this
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
122 issue will do. Should be worded in the future tense.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
123
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
124 fromdefault (``deficiency`` types only)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
125 Boolean indicating whether the current (deficient) state deviates
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
126 from Mercurial's default configuration.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
127
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
128 fromconfig (``deficiency`` types only)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
129 Boolean indicating whether the current (deficient) state deviates
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
130 from the current Mercurial configuration.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
131 """
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
132 def __init__(self, name, type, description, upgrademessage, **kwargs):
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
133 self.name = name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
134 self.type = type
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
135 self.description = description
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
136 self.upgrademessage = upgrademessage
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
137
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
138 for k, v in kwargs.items():
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
139 setattr(self, k, v)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
140
31871
5881f76323c2 upgrade: drop the prefix to the 'findimprovements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31870
diff changeset
141 def findimprovements(repo):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
142 """Determine improvements that can be made to the repo during upgrade.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
143
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
144 Returns a list of ``upgradeimprovement`` describing repository deficiencies
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
145 and optimizations.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
146 """
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
147 # Avoid cycle: cmdutil -> repair -> localrepo -> cmdutil
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
148 from . import localrepo
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
149
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
150 newreporeqs = localrepo.newreporequirements(repo)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
151
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
152 improvements = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
153
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
154 # We could detect lack of revlogv1 and store here, but they were added
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
155 # in 0.9.2 and we don't support upgrading repos without these
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
156 # requirements, so let's not bother.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
157
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
158 if 'fncache' not in repo.requirements:
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
159 improvements.append(improvement(
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
160 name='fncache',
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
161 type=deficiency,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
162 description=_('long and reserved filenames may not work correctly; '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
163 'repository performance is sub-optimal'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
164 upgrademessage=_('repository will be more resilient to storing '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
165 'certain paths and performance of certain '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
166 'operations should be improved'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
167 fromdefault=True,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
168 fromconfig='fncache' in newreporeqs))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
169
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
170 if 'dotencode' not in repo.requirements:
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
171 improvements.append(improvement(
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
172 name='dotencode',
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
173 type=deficiency,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
174 description=_('storage of filenames beginning with a period or '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
175 'space may not work correctly'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
176 upgrademessage=_('repository will be better able to store files '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
177 'beginning with a space or period'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
178 fromdefault=True,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
179 fromconfig='dotencode' in newreporeqs))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
180
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
181 if 'generaldelta' not in repo.requirements:
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
182 improvements.append(improvement(
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
183 name='generaldelta',
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
184 type=deficiency,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
185 description=_('deltas within internal storage are unable to '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
186 'choose optimal revisions; repository is larger and '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
187 'slower than it could be; interaction with other '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
188 'repositories may require extra network and CPU '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
189 'resources, making "hg push" and "hg pull" slower'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
190 upgrademessage=_('repository storage will be able to create '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
191 'optimal deltas; new repository data will be '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
192 'smaller and read times should decrease; '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
193 'interacting with other repositories using this '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
194 'storage model should require less network and '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
195 'CPU resources, making "hg push" and "hg pull" '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
196 'faster'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
197 fromdefault=True,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
198 fromconfig='generaldelta' in newreporeqs))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
199
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
200 # Mercurial 4.0 changed changelogs to not use delta chains. Search for
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
201 # changelogs with deltas.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
202 cl = repo.changelog
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
203 for rev in cl:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
204 chainbase = cl.chainbase(rev)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
205 if chainbase != rev:
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
206 improvements.append(improvement(
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
207 name='removecldeltachain',
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
208 type=deficiency,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
209 description=_('changelog storage is using deltas instead of '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
210 'raw entries; changelog reading and any '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
211 'operation relying on changelog data are slower '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
212 'than they could be'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
213 upgrademessage=_('changelog storage will be reformated to '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
214 'store raw entries; changelog reading will be '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
215 'faster; changelog size may be reduced'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
216 fromdefault=True,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
217 fromconfig=True))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
218 break
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
219
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
220 # Now for the optimizations.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
221
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
222 # These are unconditionally added. There is logic later that figures out
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
223 # which ones to apply.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
224
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
225 improvements.append(improvement(
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
226 name='redeltaparent',
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
227 type=optimisation,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
228 description=_('deltas within internal storage will be recalculated to '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
229 'choose an optimal base revision where this was not '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
230 'already done; the size of the repository may shrink and '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
231 'various operations may become faster; the first time '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
232 'this optimization is performed could slow down upgrade '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
233 'execution considerably; subsequent invocations should '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
234 'not run noticeably slower'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
235 upgrademessage=_('deltas within internal storage will choose a new '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
236 'base revision if needed')))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
237
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
238 improvements.append(improvement(
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
239 name='redeltamultibase',
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
240 type=optimisation,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
241 description=_('deltas within internal storage will be recalculated '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
242 'against multiple base revision and the smallest '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
243 'difference will be used; the size of the repository may '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
244 'shrink significantly when there are many merges; this '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
245 'optimization will slow down execution in proportion to '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
246 'the number of merges in the repository and the amount '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
247 'of files in the repository; this slow down should not '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
248 'be significant unless there are tens of thousands of '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
249 'files and thousands of merges'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
250 upgrademessage=_('deltas within internal storage will choose an '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
251 'optimal delta by computing deltas against multiple '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
252 'parents; may slow down execution time '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
253 'significantly')))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
254
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
255 improvements.append(improvement(
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
256 name='redeltaall',
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
257 type=optimisation,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
258 description=_('deltas within internal storage will always be '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
259 'recalculated without reusing prior deltas; this will '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
260 'likely make execution run several times slower; this '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
261 'optimization is typically not needed'),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
262 upgrademessage=_('deltas within internal storage will be fully '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
263 'recomputed; this will likely drastically slow down '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
264 'execution time')))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
265
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
266 return improvements
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
267
31872
3c001db97c71 upgrade: drop the prefix to the 'determineactions' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31871
diff changeset
268 def determineactions(repo, improvements, sourcereqs, destreqs,
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
269 optimize):
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
270 """Determine upgrade actions that will be performed.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
271
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
272 Given a list of improvements as returned by ``upgradefindimprovements``,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
273 determine the list of upgrade actions that will be performed.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
274
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
275 The role of this function is to filter improvements if needed, apply
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
276 recommended optimizations from the improvements list that make sense,
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
277 etc.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
278
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
279 Returns a list of action names.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
280 """
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
281 newactions = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
282
31870
49011f1cedd4 upgrade: drop the prefix to the 'supporteddestrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31869
diff changeset
283 knownreqs = supporteddestrequirements(repo)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
284
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
285 for i in improvements:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
286 name = i.name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
287
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
288 # If the action is a requirement that doesn't show up in the
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
289 # destination requirements, prune the action.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
290 if name in knownreqs and name not in destreqs:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
291 continue
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
292
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
293 if i.type == deficiency:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
294 newactions.append(name)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
295
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
296 newactions.extend(o for o in sorted(optimize) if o not in newactions)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
297
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
298 # FUTURE consider adding some optimizations here for certain transitions.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
299 # e.g. adding generaldelta could schedule parent redeltas.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
300
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
301 return newactions
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
302
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
303 def _revlogfrompath(repo, path):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
304 """Obtain a revlog from a repo path.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
305
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
306 An instance of the appropriate class is returned.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
307 """
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
308 if path == '00changelog.i':
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
309 return changelog.changelog(repo.svfs)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
310 elif path.endswith('00manifest.i'):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
311 mandir = path[:-len('00manifest.i')]
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
312 return manifest.manifestrevlog(repo.svfs, dir=mandir)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
313 else:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
314 # Filelogs don't do anything special with settings. So we can use a
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
315 # vanilla revlog.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
316 return revlog.revlog(repo.svfs, path)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
317
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
318 def _copyrevlogs(ui, srcrepo, dstrepo, tr, deltareuse, aggressivemergedeltas):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
319 """Copy revlogs between 2 repos."""
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
320 revcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
321 srcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
322 srcrawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
323 dstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
324 fcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
325 frevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
326 fsrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
327 frawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
328 fdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
329 mcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
330 mrevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
331 msrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
332 mrawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
333 mdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
334 crevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
335 csrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
336 crawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
337 cdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
338
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
339 # Perform a pass to collect metadata. This validates we can open all
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
340 # source files and allows a unified progress bar to be displayed.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
341 for unencoded, encoded, size in srcrepo.store.walk():
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
342 if unencoded.endswith('.d'):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
343 continue
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
344
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
345 rl = _revlogfrompath(srcrepo, unencoded)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
346 revcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
347
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
348 datasize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
349 rawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
350 idx = rl.index
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
351 for rev in rl:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
352 e = idx[rev]
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
353 datasize += e[1]
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
354 rawsize += e[2]
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
355
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
356 srcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
357 srcrawsize += rawsize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
358
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
359 # This is for the separate progress bars.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
360 if isinstance(rl, changelog.changelog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
361 crevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
362 csrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
363 crawsize += rawsize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
364 elif isinstance(rl, manifest.manifestrevlog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
365 mcount += 1
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
366 mrevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
367 msrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
368 mrawsize += rawsize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
369 elif isinstance(rl, revlog.revlog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
370 fcount += 1
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
371 frevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
372 fsrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
373 frawsize += rawsize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
374
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
375 if not revcount:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
376 return
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
377
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
378 ui.write(_('migrating %d total revisions (%d in filelogs, %d in manifests, '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
379 '%d in changelog)\n') %
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
380 (revcount, frevcount, mrevcount, crevcount))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
381 ui.write(_('migrating %s in store; %s tracked data\n') % (
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
382 (util.bytecount(srcsize), util.bytecount(srcrawsize))))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
383
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
384 # Used to keep track of progress.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
385 progress = []
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
386 def oncopiedrevision(rl, rev, node):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
387 progress[1] += 1
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
388 srcrepo.ui.progress(progress[0], progress[1], total=progress[2])
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
389
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
390 # Do the actual copying.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
391 # FUTURE this operation can be farmed off to worker processes.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
392 seen = set()
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
393 for unencoded, encoded, size in srcrepo.store.walk():
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
394 if unencoded.endswith('.d'):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
395 continue
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
396
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
397 oldrl = _revlogfrompath(srcrepo, unencoded)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
398 newrl = _revlogfrompath(dstrepo, unencoded)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
399
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
400 if isinstance(oldrl, changelog.changelog) and 'c' not in seen:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
401 ui.write(_('finished migrating %d manifest revisions across %d '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
402 'manifests; change in size: %s\n') %
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
403 (mrevcount, mcount, util.bytecount(mdstsize - msrcsize)))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
404
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
405 ui.write(_('migrating changelog containing %d revisions '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
406 '(%s in store; %s tracked data)\n') %
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
407 (crevcount, util.bytecount(csrcsize),
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
408 util.bytecount(crawsize)))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
409 seen.add('c')
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
410 progress[:] = [_('changelog revisions'), 0, crevcount]
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
411 elif isinstance(oldrl, manifest.manifestrevlog) and 'm' not in seen:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
412 ui.write(_('finished migrating %d filelog revisions across %d '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
413 'filelogs; change in size: %s\n') %
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
414 (frevcount, fcount, util.bytecount(fdstsize - fsrcsize)))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
415
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
416 ui.write(_('migrating %d manifests containing %d revisions '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
417 '(%s in store; %s tracked data)\n') %
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
418 (mcount, mrevcount, util.bytecount(msrcsize),
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
419 util.bytecount(mrawsize)))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
420 seen.add('m')
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
421 progress[:] = [_('manifest revisions'), 0, mrevcount]
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
422 elif 'f' not in seen:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
423 ui.write(_('migrating %d filelogs containing %d revisions '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
424 '(%s in store; %s tracked data)\n') %
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
425 (fcount, frevcount, util.bytecount(fsrcsize),
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
426 util.bytecount(frawsize)))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
427 seen.add('f')
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
428 progress[:] = [_('file revisions'), 0, frevcount]
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
429
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
430 ui.progress(progress[0], progress[1], total=progress[2])
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
431
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
432 ui.note(_('cloning %d revisions from %s\n') % (len(oldrl), unencoded))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
433 oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision,
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
434 deltareuse=deltareuse,
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
435 aggressivemergedeltas=aggressivemergedeltas)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
436
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
437 datasize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
438 idx = newrl.index
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
439 for rev in newrl:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
440 datasize += idx[rev][1]
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
441
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
442 dstsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
443
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
444 if isinstance(newrl, changelog.changelog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
445 cdstsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
446 elif isinstance(newrl, manifest.manifestrevlog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
447 mdstsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
448 else:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
449 fdstsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
450
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
451 ui.progress(progress[0], None)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
452
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
453 ui.write(_('finished migrating %d changelog revisions; change in size: '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
454 '%s\n') % (crevcount, util.bytecount(cdstsize - csrcsize)))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
455
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
456 ui.write(_('finished migrating %d total revisions; total change in store '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
457 'size: %s\n') % (revcount, util.bytecount(dstsize - srcsize)))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
458
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
459 def _upgradefilterstorefile(srcrepo, dstrepo, requirements, path, mode, st):
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
460 """Determine whether to copy a store file during upgrade.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
461
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
462 This function is called when migrating store files from ``srcrepo`` to
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
463 ``dstrepo`` as part of upgrading a repository.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
464
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
465 Args:
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
466 srcrepo: repo we are copying from
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
467 dstrepo: repo we are copying to
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
468 requirements: set of requirements for ``dstrepo``
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
469 path: store file being examined
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
470 mode: the ``ST_MODE`` file type of ``path``
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
471 st: ``stat`` data structure for ``path``
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
472
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
473 Function should return ``True`` if the file is to be copied.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
474 """
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
475 # Skip revlogs.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
476 if path.endswith(('.i', '.d')):
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
477 return False
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
478 # Skip transaction related files.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
479 if path.startswith('undo'):
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
480 return False
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
481 # Only copy regular files.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
482 if mode != stat.S_IFREG:
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
483 return False
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
484 # Skip other skipped files.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
485 if path in ('lock', 'fncache'):
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
486 return False
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
487
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
488 return True
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
489
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
490 def _upgradefinishdatamigration(ui, srcrepo, dstrepo, requirements):
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
491 """Hook point for extensions to perform additional actions during upgrade.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
492
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
493 This function is called after revlogs and store files have been copied but
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
494 before the new store is swapped into the original location.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
495 """
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
496
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
497 def _upgraderepo(ui, srcrepo, dstrepo, requirements, actions):
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
498 """Do the low-level work of upgrading a repository.
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
499
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
500 The upgrade is effectively performed as a copy between a source
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
501 repository and a temporary destination repository.
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
502
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
503 The source repository is unmodified for as long as possible so the
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
504 upgrade can abort at any time without causing loss of service for
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
505 readers and without corrupting the source repository.
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
506 """
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
507 assert srcrepo.currentwlock()
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
508 assert dstrepo.currentwlock()
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
509
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
510 ui.write(_('(it is safe to interrupt this process any time before '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
511 'data migration completes)\n'))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
512
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
513 if 'redeltaall' in actions:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
514 deltareuse = revlog.revlog.DELTAREUSENEVER
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
515 elif 'redeltaparent' in actions:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
516 deltareuse = revlog.revlog.DELTAREUSESAMEREVS
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
517 elif 'redeltamultibase' in actions:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
518 deltareuse = revlog.revlog.DELTAREUSESAMEREVS
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
519 else:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
520 deltareuse = revlog.revlog.DELTAREUSEALWAYS
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
521
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
522 with dstrepo.transaction('upgrade') as tr:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
523 _copyrevlogs(ui, srcrepo, dstrepo, tr, deltareuse,
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
524 'redeltamultibase' in actions)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
525
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
526 # Now copy other files in the store directory.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
527 for p, kind, st in srcrepo.store.vfs.readdir('', stat=True):
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
528 if not _upgradefilterstorefile(srcrepo, dstrepo, requirements,
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
529 p, kind, st):
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
530 continue
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
531
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
532 srcrepo.ui.write(_('copying %s\n') % p)
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
533 src = srcrepo.store.vfs.join(p)
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
534 dst = dstrepo.store.vfs.join(p)
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
535 util.copyfile(src, dst, copystat=True)
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
536
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
537 _upgradefinishdatamigration(ui, srcrepo, dstrepo, requirements)
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
538
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
539 ui.write(_('data fully migrated to temporary repository\n'))
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
540
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
541 backuppath = tempfile.mkdtemp(prefix='upgradebackup.', dir=srcrepo.path)
31242
254f98326eef vfs: use 'vfs' module directly in 'mercurial.repair'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30995
diff changeset
542 backupvfs = vfsmod.vfs(backuppath)
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
543
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
544 # Make a backup of requires file first, as it is the first to be modified.
31333
e712a9c35fd8 repair: directly use repo.vfs.join
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31242
diff changeset
545 util.copyfile(srcrepo.vfs.join('requires'), backupvfs.join('requires'))
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
546
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
547 # We install an arbitrary requirement that clients must not support
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
548 # as a mechanism to lock out new clients during the data swap. This is
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
549 # better than allowing a client to continue while the repository is in
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
550 # an inconsistent state.
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
551 ui.write(_('marking source repository as being upgraded; clients will be '
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
552 'unable to read from repository\n'))
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
553 scmutil.writerequires(srcrepo.vfs,
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
554 srcrepo.requirements | set(['upgradeinprogress']))
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
555
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
556 ui.write(_('starting in-place swap of repository data\n'))
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
557 ui.write(_('replaced files will be backed up at %s\n') %
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
558 backuppath)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
559
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
560 # Now swap in the new store directory. Doing it as a rename should make
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
561 # the operation nearly instantaneous and atomic (at least in well-behaved
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
562 # environments).
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
563 ui.write(_('replacing store...\n'))
30995
22fbca1d11ed mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents: 30781
diff changeset
564 tstart = util.timer()
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
565 util.rename(srcrepo.spath, backupvfs.join('store'))
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
566 util.rename(dstrepo.spath, srcrepo.spath)
30995
22fbca1d11ed mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents: 30781
diff changeset
567 elapsed = util.timer() - tstart
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
568 ui.write(_('store replacement complete; repository was inconsistent for '
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
569 '%0.1fs\n') % elapsed)
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
570
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
571 # We first write the requirements file. Any new requirements will lock
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
572 # out legacy clients.
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
573 ui.write(_('finalizing requirements file and making repository readable '
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
574 'again\n'))
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
575 scmutil.writerequires(srcrepo.vfs, requirements)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
576
30781
f2c069bf78ee repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30780
diff changeset
577 # The lock file from the old store won't be removed because nothing has a
f2c069bf78ee repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30780
diff changeset
578 # reference to its new location. So clean it up manually. Alternatively, we
f2c069bf78ee repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30780
diff changeset
579 # could update srcrepo.svfs and other variables to point to the new
f2c069bf78ee repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30780
diff changeset
580 # location. This is simpler.
f2c069bf78ee repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30780
diff changeset
581 backupvfs.unlink('store/lock')
f2c069bf78ee repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30780
diff changeset
582
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
583 return backuppath
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
584
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
585 def upgraderepo(ui, repo, run=False, optimize=None):
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
586 """Upgrade a repository in place."""
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
587 # Avoid cycle: cmdutil -> repair -> localrepo -> cmdutil
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
588 from . import localrepo
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
589
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
590 optimize = set(optimize or [])
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
591 repo = repo.unfiltered()
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
592
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
593 # Ensure the repository can be upgraded.
31865
5dcaa0f4455b upgrade: drop the prefix to the 'requiredsourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31864
diff changeset
594 missingreqs = requiredsourcerequirements(repo) - repo.requirements
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
595 if missingreqs:
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
596 raise error.Abort(_('cannot upgrade repository; requirement '
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
597 'missing: %s') % _(', ').join(sorted(missingreqs)))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
598
31866
1454726b6d7c upgrade: drop the prefix to the 'blocksourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31865
diff changeset
599 blockedreqs = blocksourcerequirements(repo) & repo.requirements
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
600 if blockedreqs:
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
601 raise error.Abort(_('cannot upgrade repository; unsupported source '
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
602 'requirement: %s') %
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
603 _(', ').join(sorted(blockedreqs)))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
604
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
605 # FUTURE there is potentially a need to control the wanted requirements via
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
606 # command arguments or via an extension hook point.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
607 newreqs = localrepo.newreporequirements(repo)
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
608
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
609 noremovereqs = (repo.requirements - newreqs -
31867
cc60b6c36637 upgrade: drop the prefix to the 'supportremovedrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31866
diff changeset
610 supportremovedrequirements(repo))
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
611 if noremovereqs:
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
612 raise error.Abort(_('cannot upgrade repository; requirement would be '
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
613 'removed: %s') % _(', ').join(sorted(noremovereqs)))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
614
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
615 noaddreqs = (newreqs - repo.requirements -
31869
fe5e30b58934 upgrade: drop the prefix to the 'allowednewrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31868
diff changeset
616 allowednewrequirements(repo))
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
617 if noaddreqs:
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
618 raise error.Abort(_('cannot upgrade repository; do not support adding '
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
619 'requirement: %s') %
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
620 _(', ').join(sorted(noaddreqs)))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
621
31870
49011f1cedd4 upgrade: drop the prefix to the 'supporteddestrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31869
diff changeset
622 unsupportedreqs = newreqs - supporteddestrequirements(repo)
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
623 if unsupportedreqs:
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
624 raise error.Abort(_('cannot upgrade repository; do not support '
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
625 'destination requirement: %s') %
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
626 _(', ').join(sorted(unsupportedreqs)))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
627
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
628 # Find and validate all improvements that can be made.
31871
5881f76323c2 upgrade: drop the prefix to the 'findimprovements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31870
diff changeset
629 improvements = findimprovements(repo)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
630 for i in improvements:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
631 if i.type not in (deficiency, optimisation):
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
632 raise error.Abort(_('unexpected improvement type %s for %s') % (
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
633 i.type, i.name))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
634
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
635 # Validate arguments.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
636 unknownoptimize = optimize - set(i.name for i in improvements
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
637 if i.type == optimisation)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
638 if unknownoptimize:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
639 raise error.Abort(_('unknown optimization action requested: %s') %
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
640 ', '.join(sorted(unknownoptimize)),
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
641 hint=_('run without arguments to see valid '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
642 'optimizations'))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
643
31872
3c001db97c71 upgrade: drop the prefix to the 'determineactions' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31871
diff changeset
644 actions = determineactions(repo, improvements, repo.requirements,
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
645 newreqs, optimize)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
646
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
647 def printrequirements():
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
648 ui.write(_('requirements\n'))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
649 ui.write(_(' preserved: %s\n') %
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
650 _(', ').join(sorted(newreqs & repo.requirements)))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
651
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
652 if repo.requirements - newreqs:
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
653 ui.write(_(' removed: %s\n') %
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
654 _(', ').join(sorted(repo.requirements - newreqs)))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
655
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
656 if newreqs - repo.requirements:
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
657 ui.write(_(' added: %s\n') %
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
658 _(', ').join(sorted(newreqs - repo.requirements)))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
659
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
660 ui.write('\n')
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
661
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
662 def printupgradeactions():
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
663 for action in actions:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
664 for i in improvements:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
665 if i.name == action:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
666 ui.write('%s\n %s\n\n' %
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
667 (i.name, i.upgrademessage))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
668
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
669 if not run:
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
670 fromdefault = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
671 fromconfig = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
672 optimizations = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
673
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
674 for i in improvements:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
675 assert i.type in (deficiency, optimisation)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
676 if i.type == deficiency:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
677 if i.fromdefault:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
678 fromdefault.append(i)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
679 if i.fromconfig:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
680 fromconfig.append(i)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
681 else:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
682 optimizations.append(i)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
683
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
684 if fromdefault or fromconfig:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
685 fromconfignames = set(x.name for x in fromconfig)
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
686 onlydefault = [i for i in fromdefault
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
687 if i.name not in fromconfignames]
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
688
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
689 if fromconfig:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
690 ui.write(_('repository lacks features recommended by '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
691 'current config options:\n\n'))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
692 for i in fromconfig:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
693 ui.write('%s\n %s\n\n' % (i.name, i.description))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
694
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
695 if onlydefault:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
696 ui.write(_('repository lacks features used by the default '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
697 'config options:\n\n'))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
698 for i in onlydefault:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
699 ui.write('%s\n %s\n\n' % (i.name, i.description))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
700
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
701 ui.write('\n')
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
702 else:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
703 ui.write(_('(no feature deficiencies found in existing '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
704 'repository)\n'))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
705
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
706 ui.write(_('performing an upgrade with "--run" will make the following '
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
707 'changes:\n\n'))
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
708
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
709 printrequirements()
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
710 printupgradeactions()
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
711
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
712 unusedoptimize = [i for i in improvements
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
713 if i.name not in actions and i.type == optimisation]
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
714 if unusedoptimize:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
715 ui.write(_('additional optimizations are available by specifying '
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
716 '"--optimize <name>":\n\n'))
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
717 for i in unusedoptimize:
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
718 ui.write(_('%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
719 return
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
720
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
721 # Else we're in the run=true case.
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
722 ui.write(_('upgrade will perform the following actions:\n\n'))
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
723 printrequirements()
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
724 printupgradeactions()
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
725
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
726 ui.write(_('beginning upgrade...\n'))
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
727 with repo.wlock():
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
728 with repo.lock():
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
729 ui.write(_('repository locked and read-only\n'))
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
730 # Our strategy for upgrading the repository is to create a new,
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
731 # temporary repository, write data to it, then do a swap of the
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
732 # data. There are less heavyweight ways to do this, but it is easier
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
733 # to create a new repo object than to instantiate all the components
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
734 # (like the store) separately.
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
735 tmppath = tempfile.mkdtemp(prefix='upgrade.', dir=repo.path)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
736 backuppath = None
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
737 try:
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
738 ui.write(_('creating temporary repository to stage migrated '
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
739 'data: %s\n') % tmppath)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
740 dstrepo = localrepo.localrepository(repo.baseui,
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
741 path=tmppath,
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
742 create=True)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
743
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
744 with dstrepo.wlock():
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
745 with dstrepo.lock():
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
746 backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
747 actions)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
748
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
749 finally:
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
750 ui.write(_('removing temporary repository %s\n') % tmppath)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
751 repo.vfs.rmtree(tmppath, forcibly=True)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
752
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
753 if backuppath:
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
754 ui.warn(_('copy of old repository backed up at %s\n') %
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
755 backuppath)
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
756 ui.warn(_('the old repository will not be deleted; remove '
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
757 'it to free up disk space once the upgraded '
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
758 'repository is verified\n'))