annotate mercurial/upgrade.py @ 45997:7c539f0febbe

upgrade: add an explicite --filelogs arguments This make it possible to select no revlog for upgrade, which is useful for some upgrade target or in some specific cases (eg: persistent-nodemap or share-safe update). Differential Revision: https://phab.mercurial-scm.org/D9468
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 30 Nov 2020 14:06:45 +0100
parents 32dcd783a985
children 705c37f22859
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31894
9379689b6c10 upgrade: update the header comment
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31893
diff changeset
1 # upgrade.py - functions for in place upgrade of Mercurial repository
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
2 #
31895
783b4c9bd5f5 upgrade: update the copyright statement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31894
diff changeset
3 # Copyright (c) 2016-present, Gregory Szorc
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
4 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8073
diff changeset
5 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9150
diff changeset
6 # GNU General Public License version 2 or any later version.
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
7
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
8 from __future__ import absolute_import
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
9
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
10 import stat
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
11
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
12 from .i18n import _
43089
c59eb1560c44 py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43077
diff changeset
13 from .pycompat import getattr
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
14 from . import (
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
15 changelog,
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26425
diff changeset
16 error,
35344
8f3f8b8dbab7 upgrade: use actual filelog to convert filelog
Boris Feld <boris.feld@octobus.net>
parents: 35343
diff changeset
17 filelog,
35343
06987c6971be upgrade: more standard creation of the temporary repository
Boris Feld <boris.feld@octobus.net>
parents: 35342
diff changeset
18 hg,
31893
165428b05fca upgrade: import 'localrepo' globally
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31875
diff changeset
19 localrepo,
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
20 manifest,
44940
4c1d39215034 metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44841
diff changeset
21 metadata,
38165
2ce60954b1b7 py3: wrap tempfile.mkdtemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents: 37444
diff changeset
22 pycompat,
45372
77b8588dd84e requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45371
diff changeset
23 requirements,
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
24 revlog,
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
25 scmutil,
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
26 util,
31232
254f98326eef vfs: use 'vfs' module directly in 'mercurial.repair'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
27 vfs as vfsmod,
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
28 )
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
29
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
30 from .utils import compression
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
31
42832
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
32 # list of requirements that request a clone of all revlog if added/removed
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
33 RECLONES_REQUIREMENTS = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
34 b'generaldelta',
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
35 requirements.SPARSEREVLOG_REQUIREMENT,
42832
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
36 }
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
37
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
38
31865
5dcaa0f4455b upgrade: drop the prefix to the 'requiredsourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31864
diff changeset
39 def requiredsourcerequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
40 """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
41
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
42 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
43 requirements returned by this function.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
44 """
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
45 return {
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
46 # Introduced in Mercurial 0.9.2.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
47 b'revlogv1',
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
48 # Introduced in Mercurial 0.9.2.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
49 b'store',
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
50 }
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
51
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
52
31866
1454726b6d7c upgrade: drop the prefix to the 'blocksourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31865
diff changeset
53 def blocksourcerequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
54 """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
55
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
56 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
57 requirements in the returned set.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
58 """
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
59 return {
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
60 # 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
61 # This is an artificial limitation.
45372
77b8588dd84e requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45371
diff changeset
62 requirements.TREEMANIFEST_REQUIREMENT,
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
63 # 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
64 # It should (hopefully) not exist in the wild.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
65 b'parentdelta',
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
66 # Upgrade should operate on the actual store, not the shared link.
45386
034d94f8761b requirements: introduce constants for `shared` and `relshared` requirements
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45373
diff changeset
67 requirements.SHARED_REQUIREMENT,
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
68 }
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
69
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
70
31867
cc60b6c36637 upgrade: drop the prefix to the 'supportremovedrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31866
diff changeset
71 def supportremovedrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
72 """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
73
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
74 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
75 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
76 to be allowed.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
77 """
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
78 supported = {
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
79 requirements.SPARSEREVLOG_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
80 requirements.SIDEDATA_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
81 requirements.COPIESSDC_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
82 requirements.NODEMAP_REQUIREMENT,
38720
d12415b8f833 upgrade: enable adding or removing sparse-revlog requirement
Paul Morelle <paul.morelle@octobus.net>
parents: 38719
diff changeset
83 }
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
84 for name in compression.compengines:
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
85 engine = compression.compengines[name]
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
86 if engine.available() and engine.revlogheader():
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
87 supported.add(b'exp-compression-%s' % name)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
88 if engine.name() == b'zstd':
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
89 supported.add(b'revlog-compression-zstd')
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
90 return supported
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
91
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
92
31870
49011f1cedd4 upgrade: drop the prefix to the 'supporteddestrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31869
diff changeset
93 def supporteddestrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
94 """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
95
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
96 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
97 the upgrade is disallowed.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
98
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
99 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
100 """
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
101 supported = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
102 b'dotencode',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
103 b'fncache',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
104 b'generaldelta',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
105 b'revlogv1',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
106 b'store',
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
107 requirements.SPARSEREVLOG_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
108 requirements.SIDEDATA_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
109 requirements.COPIESSDC_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
110 requirements.NODEMAP_REQUIREMENT,
45487
78f0bb37f52d upgrade: support running upgrade if repository has share-safe requirement
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45386
diff changeset
111 requirements.SHARESAFE_REQUIREMENT,
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
112 }
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
113 for name in compression.compengines:
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
114 engine = compression.compengines[name]
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
115 if engine.available() and engine.revlogheader():
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
116 supported.add(b'exp-compression-%s' % name)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
117 if engine.name() == b'zstd':
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
118 supported.add(b'revlog-compression-zstd')
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
119 return supported
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
120
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
121
31869
fe5e30b58934 upgrade: drop the prefix to the 'allowednewrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31868
diff changeset
122 def allowednewrequirements(repo):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
123 """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
124
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
125 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
126 they weren't present before.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
127
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
128 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
129 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
130 future, unknown requirements from accidentally being added.
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
131 """
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
132 supported = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
133 b'dotencode',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
134 b'fncache',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
135 b'generaldelta',
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
136 requirements.SPARSEREVLOG_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
137 requirements.SIDEDATA_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
138 requirements.COPIESSDC_REQUIREMENT,
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
139 requirements.NODEMAP_REQUIREMENT,
32291
bd872f64a8ba cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents: 32032
diff changeset
140 }
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
141 for name in compression.compengines:
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
142 engine = compression.compengines[name]
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
143 if engine.available() and engine.revlogheader():
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
144 supported.add(b'exp-compression-%s' % name)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
145 if engine.name() == b'zstd':
42137
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
146 supported.add(b'revlog-compression-zstd')
d086ba387ae8 upgrade: support upgrade to/from zstd storage (issue6088)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42136
diff changeset
147 return supported
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
148
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
149
35302
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
150 def preservedrequirements(repo):
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
151 return set()
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
152
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
153
45993
8037d0641146 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45981
diff changeset
154 DEFICIENCY = b'deficiency'
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
155 OPTIMISATION = b'optimization'
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
156
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
157
31868
9f84ccb1b282 upgrade: drop the prefix to the 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31867
diff changeset
158 class improvement(object):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
159 """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
160
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
161 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
162
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
163 name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
164 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
165 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
166
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
167 type
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
168 Either ``DEFICIENCY`` or ``OPTIMISATION``. A deficiency is an obvious
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
169 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
170 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
171
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
172 description
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
173 Message intended for humans explaining the improvement in more detail,
45993
8037d0641146 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45981
diff changeset
174 including the implications of it. For ``DEFICIENCY`` types, should be
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
175 worded in the present tense. For ``OPTIMISATION`` types, should be
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
176 worded in the future tense.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
177
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
178 upgrademessage
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
179 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
180 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
181 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
182
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
183 def __init__(self, name, type, description, upgrademessage):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
184 self.name = name
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
185 self.type = type
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
186 self.description = description
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
187 self.upgrademessage = upgrademessage
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
188
31902
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
189 def __eq__(self, other):
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
190 if not isinstance(other, improvement):
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
191 # This is what python tell use to do
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
192 return NotImplemented
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
193 return self.name == other.name
6557f0d4ab8e upgrade: implement equality for 'improvement' object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31901
diff changeset
194
32028
99f63f476a72 upgrade: implement '__ne__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31904
diff changeset
195 def __ne__(self, other):
40997
038108a9811c upgrade: correct implementation of improvement.__ne__
Benjamin Peterson <benjamin@python.org>
parents: 40918
diff changeset
196 return not (self == other)
32028
99f63f476a72 upgrade: implement '__ne__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31904
diff changeset
197
32029
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
198 def __hash__(self):
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
199 return hash(self.name)
9e35848fa007 upgrade: implement '__hash__' on 'improvement' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32028
diff changeset
200
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
201
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
202 allformatvariant = []
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
203
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
204
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
205 def registerformatvariant(cls):
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
206 allformatvariant.append(cls)
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
207 return cls
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
208
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
209
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
210 class formatvariant(improvement):
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
211 """an improvement subclass dedicated to repository format"""
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
212
45993
8037d0641146 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45981
diff changeset
213 type = DEFICIENCY
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
214 ### The following attributes should be defined for each class:
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
215
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
216 # machine-readable string uniquely identifying this improvement. it will be
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
217 # mapped to an action later in the upgrade process.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
218 name = None
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
219
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
220 # message intended for humans explaining the improvement in more detail,
45993
8037d0641146 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45981
diff changeset
221 # including the implications of it ``DEFICIENCY`` types, should be worded
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
222 # in the present tense.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
223 description = None
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
224
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
225 # message intended for humans explaining what an upgrade addressing this
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
226 # issue will do. should be worded in the future tense.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
227 upgrademessage = None
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
228
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
229 # value of current Mercurial default for new repository
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
230 default = None
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
231
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
232 def __init__(self):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
233 raise NotImplementedError()
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
234
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
235 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
236 def fromrepo(repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
237 """current value of the variant in the repository"""
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
238 raise NotImplementedError()
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
239
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
240 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
241 def fromconfig(repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
242 """current value of the variant in the configuration"""
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
243 raise NotImplementedError()
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
244
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
245
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
246 class requirementformatvariant(formatvariant):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
247 """formatvariant based on a 'requirement' name.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
248
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
249 Many format variant are controlled by a 'requirement'. We define a small
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
250 subclass to factor the code.
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
251 """
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
252
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
253 # the requirement that control this format variant
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
254 _requirement = None
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
255
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
256 @staticmethod
39546
41aa5dced975 localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39243
diff changeset
257 def _newreporequirements(ui):
39996
dbcb466d0065 localrepo: define storage backend in creation options (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39870
diff changeset
258 return localrepo.newreporequirements(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
259 ui, localrepo.defaultcreateopts(ui)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
260 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
261
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
262 @classmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
263 def fromrepo(cls, repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
264 assert cls._requirement is not None
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
265 return cls._requirement in repo.requirements
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
266
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
267 @classmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
268 def fromconfig(cls, repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
269 assert cls._requirement is not None
39546
41aa5dced975 localrepo: pass ui to newreporequirements() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39243
diff changeset
270 return cls._requirement in cls._newreporequirements(repo.ui)
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
271
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
272
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
273 @registerformatvariant
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
274 class fncache(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
275 name = b'fncache'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
276
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
277 _requirement = b'fncache'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
278
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
279 default = True
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
280
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
281 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
282 b'long and reserved filenames may not work correctly; '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
283 b'repository performance is sub-optimal'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
284 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
285
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
286 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
287 b'repository will be more resilient to storing '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
288 b'certain paths and performance of certain '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
289 b'operations should be improved'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
290 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
291
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
292
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
293 @registerformatvariant
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
294 class dotencode(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
295 name = b'dotencode'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
296
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
297 _requirement = b'dotencode'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
298
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
299 default = True
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
300
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
301 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
302 b'storage of filenames beginning with a period or '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
303 b'space may not work correctly'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
304 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
305
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
306 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
307 b'repository will be better able to store files '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
308 b'beginning with a space or period'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
309 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
310
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
311
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
312 @registerformatvariant
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
313 class generaldelta(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
314 name = b'generaldelta'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
315
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
316 _requirement = b'generaldelta'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
317
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
318 default = True
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
319
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
320 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
321 b'deltas within internal storage are unable to '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
322 b'choose optimal revisions; repository is larger and '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
323 b'slower than it could be; interaction with other '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
324 b'repositories may require extra network and CPU '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
325 b'resources, making "hg push" and "hg pull" slower'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
326 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
327
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
328 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
329 b'repository storage will be able to create '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
330 b'optimal deltas; new repository data will be '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
331 b'smaller and read times should decrease; '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
332 b'interacting with other repositories using this '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
333 b'storage model should require less network and '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
334 b'CPU resources, making "hg push" and "hg pull" '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
335 b'faster'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
336 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
337
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
338
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
339 @registerformatvariant
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
340 class sparserevlog(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
341 name = b'sparserevlog'
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
342
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
343 _requirement = requirements.SPARSEREVLOG_REQUIREMENT
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
344
40918
3764330f76a6 sparse-revlog: enabled by default
Boris Feld <boris.feld@octobus.net>
parents: 40837
diff changeset
345 default = True
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
346
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
347 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
348 b'in order to limit disk reading and memory usage on older '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
349 b'version, the span of a delta chain from its root to its '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
350 b'end is limited, whatever the relevant data in this span. '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
351 b'This can severly limit Mercurial ability to build good '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
352 b'chain of delta resulting is much more storage space being '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
353 b'taken and limit reusability of on disk delta during '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
354 b'exchange.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
355 )
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
356
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
357 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
358 b'Revlog supports delta chain with more unused data '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
359 b'between payload. These gaps will be skipped at read '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
360 b'time. This allows for better delta chains, making a '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
361 b'better compression and faster exchange with server.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
362 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
363
38719
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
364
4ad2a1ff0404 upgrade: add information about sparse-revlog
Paul Morelle <paul.morelle@octobus.net>
parents: 38399
diff changeset
365 @registerformatvariant
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
366 class sidedata(requirementformatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
367 name = b'sidedata'
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
368
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
369 _requirement = requirements.SIDEDATA_REQUIREMENT
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
370
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
371 default = False
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
372
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
373 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
374 b'Allows storage of extra data alongside a revision, '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
375 b'unlocking various caching options.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
376 )
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
377
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
378 upgrademessage = _(b'Allows storage of extra data alongside a revision.')
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
379
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
380
43031
e16ca9fde7aa upgrade: detect the side-data format variants
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43002
diff changeset
381 @registerformatvariant
44799
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
382 class persistentnodemap(requirementformatvariant):
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
383 name = b'persistent-nodemap'
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
384
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
385 _requirement = requirements.NODEMAP_REQUIREMENT
44799
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
386
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
387 default = False
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
388
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
389 description = _(
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
390 b'persist the node -> rev mapping on disk to speedup lookup'
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
391 )
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
392
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
393 upgrademessage = _(b'Speedup revision lookup by node id.')
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
394
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
395
ea9563e9e65a nodemap: teach `hg debugformat` about the persistent nodemap option
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44798
diff changeset
396 @registerformatvariant
43138
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
397 class copiessdc(requirementformatvariant):
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
398 name = b'copies-sdc'
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
399
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
400 _requirement = requirements.COPIESSDC_REQUIREMENT
43138
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
401
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
402 default = False
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
403
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
404 description = _(b'Stores copies information alongside changesets.')
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
405
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
406 upgrademessage = _(
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
407 b'Allows to use more efficient algorithm to deal with ' b'copy tracing.'
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
408 )
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
409
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
410
f9dc98a97cdb sidedatacopies: teach upgrade about the new requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43135
diff changeset
411 @registerformatvariant
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
412 class removecldeltachain(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
413 name = b'plain-cl-delta'
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
414
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
415 default = True
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
416
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
417 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
418 b'changelog storage is using deltas instead of '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
419 b'raw entries; changelog reading and any '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
420 b'operation relying on changelog data are slower '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
421 b'than they could be'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
422 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
423
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
424 upgrademessage = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
425 b'changelog storage will be reformated to '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
426 b'store raw entries; changelog reading will be '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
427 b'faster; changelog size may be reduced'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
428 )
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
429
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
430 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
431 def fromrepo(repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
432 # Mercurial 4.0 changed changelogs to not use delta chains. Search for
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
433 # changelogs with deltas.
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
434 cl = repo.changelog
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
435 chainbase = cl.chainbase
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
436 return all(rev == chainbase(rev) for rev in cl)
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
437
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
438 @staticmethod
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
439 def fromconfig(repo):
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
440 return True
32030
e47223576b8d upgrade: introduce a 'formatvariant' class
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32029
diff changeset
441
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
442
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
443 @registerformatvariant
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
444 class compressionengine(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
445 name = b'compression'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
446 default = b'zlib'
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
447
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
448 description = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
449 b'Compresion algorithm used to compress data. '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
450 b'Some engine are faster than other'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
451 )
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
452
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
453 upgrademessage = _(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43089
diff changeset
454 b'revlog content will be recompressed with the new algorithm.'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
455 )
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
456
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
457 @classmethod
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
458 def fromrepo(cls, repo):
42136
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
459 # we allow multiple compression engine requirement to co-exist because
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
460 # strickly speaking, revlog seems to support mixed compression style.
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
461 #
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
462 # The compression used for new entries will be "the last one"
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
463 compression = b'zlib'
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
464 for req in repo.requirements:
42136
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
465 prefix = req.startswith
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
466 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
467 compression = req.split(b'-', 2)[2]
42136
10a6725dca6e compression: introduce an official `zstd-revlog` requirement
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42046
diff changeset
468 return compression
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
469
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
470 @classmethod
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
471 def fromconfig(cls, repo):
44382
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
472 compengines = repo.ui.configlist(b'format', b'revlog-compression')
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
473 # return the first valid value as the selection code would do
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
474 for comp in compengines:
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
475 if comp in util.compengines:
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
476 return comp
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
477
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
478 # no valide compression found lets display it all for clarity
f0027a3dd7cb revlog-compression: update the config to be a list
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43805
diff changeset
479 return b','.join(compengines)
35340
ead01b74be04 upgrade: register compression as a format variants
Boris Feld <boris.feld@octobus.net>
parents: 35335
diff changeset
480
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
481
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
482 @registerformatvariant
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
483 class compressionlevel(formatvariant):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
484 name = b'compression-level'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
485 default = b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
486
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
487 description = _(b'compression level')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
488
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
489 upgrademessage = _(b'revlog content will be recompressed')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
490
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
491 @classmethod
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
492 def fromrepo(cls, repo):
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
493 comp = compressionengine.fromrepo(repo)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
494 level = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
495 if comp == b'zlib':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
496 level = repo.ui.configint(b'storage', b'revlog.zlib.level')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
497 elif comp == b'zstd':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
498 level = repo.ui.configint(b'storage', b'revlog.zstd.level')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
499 if level is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
500 return b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
501 return bytes(level)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
502
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
503 @classmethod
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
504 def fromconfig(cls, repo):
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
505 comp = compressionengine.fromconfig(repo)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
506 level = None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
507 if comp == b'zlib':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
508 level = repo.ui.configint(b'storage', b'revlog.zlib.level')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
509 elif comp == b'zstd':
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
510 level = repo.ui.configint(b'storage', b'revlog.zstd.level')
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
511 if level is None:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
512 return b'default'
42045
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
513 return bytes(level)
d7e751ec679e compression: display compression level in debugformat
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41089
diff changeset
514
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
515
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
516 def finddeficiencies(repo):
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
517 """returns a list of deficiencies that the repo suffer from"""
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
518 deficiencies = []
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
519
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
520 # 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
521 # 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
522 # requirements, so let's not bother.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
523
32032
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
524 for fv in allformatvariant:
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
525 if not fv.fromrepo(repo):
189778a06743 upgrade: register all format variants in a list
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32031
diff changeset
526 deficiencies.append(fv)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
527
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
528 return deficiencies
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
529
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
530
41088
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
531 # search without '-' to support older form on newer client.
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
532 #
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
533 # We don't enforce backward compatibility for debug command so this
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
534 # might eventually be dropped. However, having to use two different
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
535 # forms in script when comparing result is anoying enough to add
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
536 # backward compatibility for a while.
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
537 legacy_opts_map = {
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
538 b'redeltaparent': b're-delta-parent',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
539 b'redeltamultibase': b're-delta-multibase',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
540 b'redeltaall': b're-delta-all',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
541 b'redeltafulladd': b're-delta-fulladd',
41088
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
542 }
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
543
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
544 ALL_OPTIMISATIONS = []
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
545
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
546
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
547 def register_optimization(obj):
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
548 ALL_OPTIMISATIONS.append(obj)
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
549 return obj
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
550
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
551
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
552 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
553 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
554 name=b're-delta-parent',
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
555 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
556 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
557 b'deltas within internal storage will be recalculated to '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
558 b'choose an optimal base revision where this was not '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
559 b'already done; the size of the repository may shrink and '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
560 b'various operations may become faster; the first time '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
561 b'this optimization is performed could slow down upgrade '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
562 b'execution considerably; subsequent invocations should '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
563 b'not run noticeably slower'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
564 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
565 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
566 b'deltas within internal storage will choose a new '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
567 b'base revision if needed'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
568 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
569 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
570 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
571
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
572 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
573 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
574 name=b're-delta-multibase',
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
575 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
576 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
577 b'deltas within internal storage will be recalculated '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
578 b'against multiple base revision and the smallest '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
579 b'difference will be used; the size of the repository may '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
580 b'shrink significantly when there are many merges; this '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
581 b'optimization will slow down execution in proportion to '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
582 b'the number of merges in the repository and the amount '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
583 b'of files in the repository; this slow down should not '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
584 b'be significant unless there are tens of thousands of '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
585 b'files and thousands of merges'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
586 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
587 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
588 b'deltas within internal storage will choose an '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
589 b'optimal delta by computing deltas against multiple '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
590 b'parents; may slow down execution time '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
591 b'significantly'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
592 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
593 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
594 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
595
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
596 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
597 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
598 name=b're-delta-all',
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
599 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
600 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
601 b'deltas within internal storage will always be '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
602 b'recalculated without reusing prior deltas; this will '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
603 b'likely make execution run several times slower; this '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
604 b'optimization is typically not needed'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
605 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
606 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
607 b'deltas within internal storage will be fully '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
608 b'recomputed; this will likely drastically slow down '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
609 b'execution time'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
610 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
611 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
612 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
613
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
614 register_optimization(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
615 improvement(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
616 name=b're-delta-fulladd',
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
617 type=OPTIMISATION,
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
618 description=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
619 b'every revision will be re-added as if it was new '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
620 b'content. It will go through the full storage '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
621 b'mechanism giving extensions a chance to process it '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
622 b'(eg. lfs). This is similar to "re-delta-all" but even '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
623 b'slower since more logic is involved.'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
624 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
625 upgrademessage=_(
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
626 b'each revision will be added as new content to the '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
627 b'internal storage; this will likely drastically slow '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
628 b'down execution time, but some extensions might need '
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
629 b'it'
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
630 ),
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
631 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
632 )
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
633
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
634
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
635 def findoptimizations(repo):
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
636 """Determine optimisation that could be used during upgrade"""
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
637 # 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
638 # which ones to apply.
45995
32dcd783a985 upgrade: move optimisation to something more declarative
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45994
diff changeset
639 return list(ALL_OPTIMISATIONS)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
640
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
641
31900
0f0d7005b9ad upgrade: simplify 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31899
diff changeset
642 def determineactions(repo, deficiencies, sourcereqs, destreqs):
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
643 """Determine upgrade actions that will be performed.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
644
31896
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
645 Given a list of improvements as returned by ``finddeficiencies`` and
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
646 ``findoptimizations``, determine the list of upgrade actions that
127b41e975fd upgrade: split finding deficiencies from finding optimisations
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31895
diff changeset
647 will be performed.
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
648
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
649 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
650 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
651 etc.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
652
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
653 Returns a list of action names.
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
654 """
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
655 newactions = []
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
656
31900
0f0d7005b9ad upgrade: simplify 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31899
diff changeset
657 for d in deficiencies:
44746
c36a3fcfc36b upgrade: properly filter action depending on planned work
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44452
diff changeset
658 name = d._requirement
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
659
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
660 # 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
661 # destination requirements, prune the action.
44746
c36a3fcfc36b upgrade: properly filter action depending on planned work
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44452
diff changeset
662 if name is not None and name not in destreqs:
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
663 continue
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
664
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
665 newactions.append(d)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
666
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
667 # 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
668 # 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
669
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
670 return newactions
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
671
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
672
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
673 def _revlogfrompath(repo, path):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
674 """Obtain a revlog from a repo path.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
675
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
676 An instance of the appropriate class is returned.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
677 """
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
678 if path == b'00changelog.i':
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
679 return changelog.changelog(repo.svfs)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
680 elif path.endswith(b'00manifest.i'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
681 mandir = path[: -len(b'00manifest.i')]
39243
0d97530eb535 manifest: rename dir argument and attribute to tree
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38736
diff changeset
682 return manifest.manifestrevlog(repo.svfs, tree=mandir)
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
683 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
684 # reverse of "/".join(("data", path + ".i"))
35344
8f3f8b8dbab7 upgrade: use actual filelog to convert filelog
Boris Feld <boris.feld@octobus.net>
parents: 35343
diff changeset
685 return filelog.filelog(repo.svfs, path[5:-2])
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
686
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
687
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
688 def _copyrevlog(tr, destrepo, oldrl, unencodedname):
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
689 """copy all relevant files for `oldrl` into `destrepo` store
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
690
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
691 Files are copied "as is" without any transformation. The copy is performed
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
692 without extra checks. Callers are responsible for making sure the copied
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
693 content is compatible with format of the destination repository.
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
694 """
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
695 oldrl = getattr(oldrl, '_revlog', oldrl)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
696 newrl = _revlogfrompath(destrepo, unencodedname)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
697 newrl = getattr(newrl, '_revlog', newrl)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
698
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
699 oldvfs = oldrl.opener
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
700 newvfs = newrl.opener
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
701 oldindex = oldvfs.join(oldrl.indexfile)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
702 newindex = newvfs.join(newrl.indexfile)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
703 olddata = oldvfs.join(oldrl.datafile)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
704 newdata = newvfs.join(newrl.datafile)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
705
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
706 with newvfs(newrl.indexfile, b'w'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
707 pass # create all the directories
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
708
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
709 util.copyfile(oldindex, newindex)
43002
373749982924 upgrade: also register copied `.d` files to fncache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43000
diff changeset
710 copydata = oldrl.opener.exists(oldrl.datafile)
373749982924 upgrade: also register copied `.d` files to fncache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43000
diff changeset
711 if copydata:
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
712 util.copyfile(olddata, newdata)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
713
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
714 if not (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
715 unencodedname.endswith(b'00changelog.i')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
716 or unencodedname.endswith(b'00manifest.i')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
717 ):
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
718 destrepo.svfs.fncache.add(unencodedname)
43002
373749982924 upgrade: also register copied `.d` files to fncache
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43000
diff changeset
719 if copydata:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
720 destrepo.svfs.fncache.add(unencodedname[:-2] + b'.d')
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
721
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
722
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
723 UPGRADE_CHANGELOG = object()
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
724 UPGRADE_MANIFEST = object()
45980
fe7d7917ceb5 upgrade: rename UPGRADE_FILELOG to UPGRADE_FILELOGS
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45735
diff changeset
725 UPGRADE_FILELOGS = object()
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
726
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
727 UPGRADE_ALL_REVLOGS = frozenset(
45980
fe7d7917ceb5 upgrade: rename UPGRADE_FILELOG to UPGRADE_FILELOGS
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45735
diff changeset
728 [UPGRADE_CHANGELOG, UPGRADE_MANIFEST, UPGRADE_FILELOGS]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
729 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
730
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
731
43135
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
732 def getsidedatacompanion(srcrepo, dstrepo):
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
733 sidedatacompanion = None
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
734 removedreqs = srcrepo.requirements - dstrepo.requirements
43148
843da18386d5 sidedatacopies: deal with upgrading and downgrading to that format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43138
diff changeset
735 addedreqs = dstrepo.requirements - srcrepo.requirements
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
736 if requirements.SIDEDATA_REQUIREMENT in removedreqs:
43135
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
737
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
738 def sidedatacompanion(rl, rev):
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
739 rl = getattr(rl, '_revlog', rl)
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
740 if rl.flags(rev) & revlog.REVIDX_SIDEDATA:
45735
edf4fa06df94 upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45694
diff changeset
741 return True, (), {}, 0, 0
edf4fa06df94 upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45694
diff changeset
742 return False, (), {}, 0, 0
43135
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
743
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
744 elif requirements.COPIESSDC_REQUIREMENT in addedreqs:
44940
4c1d39215034 metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44841
diff changeset
745 sidedatacompanion = metadata.getsidedataadder(srcrepo, dstrepo)
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
746 elif requirements.COPIESSDC_REQUIREMENT in removedreqs:
44940
4c1d39215034 metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44841
diff changeset
747 sidedatacompanion = metadata.getsidedataremover(srcrepo, dstrepo)
43135
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
748 return sidedatacompanion
43134
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
749
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
750
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
751 def matchrevlog(revlogfilter, entry):
45694
d1c10d33a85c upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45487
diff changeset
752 """check if a revlog is selected for cloning.
d1c10d33a85c upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45487
diff changeset
753
d1c10d33a85c upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45487
diff changeset
754 In other words, are there any updates which need to be done on revlog
d1c10d33a85c upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45487
diff changeset
755 or it can be blindly copied.
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
756
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
757 The store entry is checked against the passed filter"""
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
758 if entry.endswith(b'00changelog.i'):
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
759 return UPGRADE_CHANGELOG in revlogfilter
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
760 elif entry.endswith(b'00manifest.i'):
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
761 return UPGRADE_MANIFEST in revlogfilter
45980
fe7d7917ceb5 upgrade: rename UPGRADE_FILELOG to UPGRADE_FILELOGS
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45735
diff changeset
762 return UPGRADE_FILELOGS in revlogfilter
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
763
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
764
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
765 def _clonerevlogs(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
766 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
767 srcrepo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
768 dstrepo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
769 tr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
770 deltareuse,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
771 forcedeltabothparents,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
772 revlogs=UPGRADE_ALL_REVLOGS,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
773 ):
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
774 """Copy revlogs between 2 repos."""
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
775 revcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
776 srcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
777 srcrawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
778 dstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
779 fcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
780 frevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
781 fsrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
782 frawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
783 fdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
784 mcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
785 mrevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
786 msrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
787 mrawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
788 mdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
789 crevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
790 csrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
791 crawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
792 cdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
793
42689
896fb9deeaf8 upgrade: walk the source store file only once
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42137
diff changeset
794 alldatafiles = list(srcrepo.store.walk())
896fb9deeaf8 upgrade: walk the source store file only once
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42137
diff changeset
795
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
796 # 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
797 # source files and allows a unified progress bar to be displayed.
42689
896fb9deeaf8 upgrade: walk the source store file only once
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42137
diff changeset
798 for unencoded, encoded, size in alldatafiles:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
799 if unencoded.endswith(b'.d'):
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
800 continue
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
801
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
802 rl = _revlogfrompath(srcrepo, unencoded)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
803
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
804 info = rl.storageinfo(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
805 exclusivefiles=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
806 revisionscount=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
807 trackedsize=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
808 storedsize=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
809 )
39857
8dab7c8a93eb upgrade: report size of backing files, not internal storage size
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39546
diff changeset
810
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
811 revcount += info[b'revisionscount'] or 0
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
812 datasize = info[b'storedsize'] or 0
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
813 rawsize = info[b'trackedsize'] or 0
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
814
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
815 srcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
816 srcrawsize += rawsize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
817
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
818 # This is for the separate progress bars.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
819 if isinstance(rl, changelog.changelog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
820 crevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
821 csrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
822 crawsize += rawsize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
823 elif isinstance(rl, manifest.manifestrevlog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
824 mcount += 1
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
825 mrevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
826 msrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
827 mrawsize += rawsize
37444
c8666a9e9e11 upgrade: sniff for filelog type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36373
diff changeset
828 elif isinstance(rl, filelog.filelog):
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
829 fcount += 1
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
830 frevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
831 fsrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
832 frawsize += rawsize
37444
c8666a9e9e11 upgrade: sniff for filelog type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36373
diff changeset
833 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
834 error.ProgrammingError(b'unknown revlog type')
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
835
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
836 if not revcount:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
837 return
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
838
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
839 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
840 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
841 b'migrating %d total revisions (%d in filelogs, %d in manifests, '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
842 b'%d in changelog)\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
843 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
844 % (revcount, frevcount, mrevcount, crevcount)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
845 )
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
846 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
847 _(b'migrating %s in store; %s tracked data\n')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
848 % ((util.bytecount(srcsize), util.bytecount(srcrawsize)))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
849 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
850
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
851 # Used to keep track of progress.
38399
185588cb0c4b upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38398
diff changeset
852 progress = None
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
853
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
854 def oncopiedrevision(rl, rev, node):
38399
185588cb0c4b upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38398
diff changeset
855 progress.increment()
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
856
43134
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
857 sidedatacompanion = getsidedatacompanion(srcrepo, dstrepo)
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
858
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
859 # Do the actual copying.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
860 # 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
861 seen = set()
42689
896fb9deeaf8 upgrade: walk the source store file only once
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42137
diff changeset
862 for unencoded, encoded, size in alldatafiles:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
863 if unencoded.endswith(b'.d'):
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
864 continue
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
865
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
866 oldrl = _revlogfrompath(srcrepo, unencoded)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
867
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
868 if isinstance(oldrl, changelog.changelog) and b'c' not in seen:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
869 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
870 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
871 b'finished migrating %d manifest revisions across %d '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
872 b'manifests; change in size: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
873 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
874 % (mrevcount, mcount, util.bytecount(mdstsize - msrcsize))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
875 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
876
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
877 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
878 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
879 b'migrating changelog containing %d revisions '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
880 b'(%s in store; %s tracked data)\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
881 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
882 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
883 crevcount,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
884 util.bytecount(csrcsize),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
885 util.bytecount(crawsize),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
886 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
887 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
888 seen.add(b'c')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
889 progress = srcrepo.ui.makeprogress(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
890 _(b'changelog revisions'), total=crevcount
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
891 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
892 elif isinstance(oldrl, manifest.manifestrevlog) and b'm' not in seen:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
893 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
894 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
895 b'finished migrating %d filelog revisions across %d '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
896 b'filelogs; change in size: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
897 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
898 % (frevcount, fcount, util.bytecount(fdstsize - fsrcsize))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
899 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
900
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
901 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
902 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
903 b'migrating %d manifests containing %d revisions '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
904 b'(%s in store; %s tracked data)\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
905 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
906 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
907 mcount,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
908 mrevcount,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
909 util.bytecount(msrcsize),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
910 util.bytecount(mrawsize),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
911 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
912 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
913 seen.add(b'm')
38398
f273b768b60f upgrade: close progress after each revlog
Martin von Zweigbergk <martinvonz@google.com>
parents: 38165
diff changeset
914 if progress:
38399
185588cb0c4b upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38398
diff changeset
915 progress.complete()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
916 progress = srcrepo.ui.makeprogress(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
917 _(b'manifest revisions'), total=mrevcount
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
918 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
919 elif b'f' not in seen:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
920 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
921 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
922 b'migrating %d filelogs containing %d revisions '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
923 b'(%s in store; %s tracked data)\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
924 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
925 % (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
926 fcount,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
927 frevcount,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
928 util.bytecount(fsrcsize),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
929 util.bytecount(frawsize),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
930 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
931 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
932 seen.add(b'f')
38398
f273b768b60f upgrade: close progress after each revlog
Martin von Zweigbergk <martinvonz@google.com>
parents: 38165
diff changeset
933 if progress:
38399
185588cb0c4b upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38398
diff changeset
934 progress.complete()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
935 progress = srcrepo.ui.makeprogress(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
936 _(b'file revisions'), total=frevcount
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
937 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
938
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
939 if matchrevlog(revlogs, unencoded):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
940 ui.note(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
941 _(b'cloning %d revisions from %s\n') % (len(oldrl), unencoded)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
942 )
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
943 newrl = _revlogfrompath(dstrepo, unencoded)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
944 oldrl.clone(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
945 tr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
946 newrl,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
947 addrevisioncb=oncopiedrevision,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
948 deltareuse=deltareuse,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
949 forcedeltabothparents=forcedeltabothparents,
43134
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
950 sidedatacompanion=sidedatacompanion,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
951 )
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
952 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
953 msg = _(b'blindly copying %s containing %i revisions\n')
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
954 ui.note(msg % (unencoded, len(oldrl)))
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
955 _copyrevlog(tr, dstrepo, oldrl, unencoded)
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
956
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
957 newrl = _revlogfrompath(dstrepo, unencoded)
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
958
39870
b399ff55ee6d upgrade: use storageinfo() for obtaining storage metadata
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39859
diff changeset
959 info = newrl.storageinfo(storedsize=True)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
960 datasize = info[b'storedsize'] or 0
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
961
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
962 dstsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
963
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
964 if isinstance(newrl, changelog.changelog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
965 cdstsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
966 elif isinstance(newrl, manifest.manifestrevlog):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
967 mdstsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
968 else:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
969 fdstsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
970
38399
185588cb0c4b upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38398
diff changeset
971 progress.complete()
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
972
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
973 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
974 _(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
975 b'finished migrating %d changelog revisions; change in size: '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
976 b'%s\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
977 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
978 % (crevcount, util.bytecount(cdstsize - csrcsize))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
979 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
980
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
981 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
982 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
983 b'finished migrating %d total revisions; total change in store '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
984 b'size: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
985 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
986 % (revcount, util.bytecount(dstsize - srcsize))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
987 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
988
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
989
31873
d6c2005484b6 upgrade: drop the prefix to the '_filterstorefile' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31872
diff changeset
990 def _filterstorefile(srcrepo, dstrepo, requirements, path, mode, st):
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
991 """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
992
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
993 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
994 ``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
995
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
996 Args:
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
997 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
998 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
999 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
1000 path: store file being examined
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1001 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
1002 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
1003
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1004 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
1005 """
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1006 # Skip revlogs.
44841
526d69eeea31 upgrade: support upgrade and downgrade from persistent nodemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44799
diff changeset
1007 if path.endswith((b'.i', b'.d', b'.n', b'.nd')):
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1008 return False
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1009 # Skip transaction related files.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1010 if path.startswith(b'undo'):
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1011 return False
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1012 # Only copy regular files.
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1013 if mode != stat.S_IFREG:
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1014 return False
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1015 # Skip other skipped files.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1016 if path in (b'lock', b'fncache'):
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1017 return False
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1018
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1019 return True
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1020
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1021
31874
27ec6517e40e upgrade: drop the prefix to the '_finishdatamigration' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31873
diff changeset
1022 def _finishdatamigration(ui, srcrepo, dstrepo, requirements):
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1023 """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
1024
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1025 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
1026 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
1027 """
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1028
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1029
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1030 def _upgraderepo(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1031 ui, srcrepo, dstrepo, requirements, actions, revlogs=UPGRADE_ALL_REVLOGS
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1032 ):
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1033 """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
1034
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1035 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
1036 repository and a temporary destination repository.
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1037
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1038 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
1039 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
1040 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
1041 """
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1042 assert srcrepo.currentwlock()
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1043 assert dstrepo.currentwlock()
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1044
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1045 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1046 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1047 b'(it is safe to interrupt this process any time before '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1048 b'data migration completes)\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1049 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1050 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1051
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1052 if b're-delta-all' in actions:
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1053 deltareuse = revlog.revlog.DELTAREUSENEVER
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1054 elif b're-delta-parent' in actions:
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1055 deltareuse = revlog.revlog.DELTAREUSESAMEREVS
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1056 elif b're-delta-multibase' in actions:
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1057 deltareuse = revlog.revlog.DELTAREUSESAMEREVS
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1058 elif b're-delta-fulladd' in actions:
35345
6226668a7169 upgrade: add a 'redeltafullall' mode
Boris Feld <boris.feld@octobus.net>
parents: 35344
diff changeset
1059 deltareuse = revlog.revlog.DELTAREUSEFULLADD
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1060 else:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1061 deltareuse = revlog.revlog.DELTAREUSEALWAYS
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1062
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1063 with dstrepo.transaction(b'upgrade') as tr:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1064 _clonerevlogs(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1065 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1066 srcrepo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1067 dstrepo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1068 tr,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1069 deltareuse,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1070 b're-delta-multibase' in actions,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1071 revlogs=revlogs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1072 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1073
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1074 # Now copy other files in the store directory.
31797
0b913e1e725b repair: iterate store files deterministically
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30781
diff changeset
1075 # The sorted() makes execution deterministic.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1076 for p, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1077 if not _filterstorefile(srcrepo, dstrepo, requirements, p, kind, st):
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1078 continue
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1079
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1080 srcrepo.ui.status(_(b'copying %s\n') % p)
31799
8110d49e0558 repair: use rawvfs when copying extra store files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 31797
diff changeset
1081 src = srcrepo.store.rawvfs.join(p)
8110d49e0558 repair: use rawvfs when copying extra store files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 31797
diff changeset
1082 dst = dstrepo.store.rawvfs.join(p)
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
1083 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
1084
31874
27ec6517e40e upgrade: drop the prefix to the '_finishdatamigration' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31873
diff changeset
1085 _finishdatamigration(ui, srcrepo, dstrepo, requirements)
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1086
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1087 ui.status(_(b'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
1088
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1089 backuppath = pycompat.mkdtemp(prefix=b'upgradebackup.', dir=srcrepo.path)
31232
254f98326eef vfs: use 'vfs' module directly in 'mercurial.repair'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30975
diff changeset
1090 backupvfs = vfsmod.vfs(backuppath)
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1091
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1092 # Make a backup of requires file first, as it is the first to be modified.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1093 util.copyfile(srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires'))
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1094
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1095 # 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
1096 # 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
1097 # 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
1098 # an inconsistent state.
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1099 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1100 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1101 b'marking source repository as being upgraded; clients will be '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1102 b'unable to read from repository\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1103 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1104 )
45106
a03c177a4679 scmutil: add writereporequirements() and route requires writing through it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
1105 scmutil.writereporequirements(
a03c177a4679 scmutil: add writereporequirements() and route requires writing through it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
1106 srcrepo, srcrepo.requirements | {b'upgradeinprogress'}
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1107 )
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1108
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1109 ui.status(_(b'starting in-place swap of repository data\n'))
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1110 ui.status(_(b'replaced files will be backed up at %s\n') % backuppath)
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1111
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1112 # 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
1113 # 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
1114 # environments).
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1115 ui.status(_(b'replacing store...\n'))
30975
22fbca1d11ed mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents: 30781
diff changeset
1116 tstart = util.timer()
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1117 util.rename(srcrepo.spath, backupvfs.join(b'store'))
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
1118 util.rename(dstrepo.spath, srcrepo.spath)
30975
22fbca1d11ed mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents: 30781
diff changeset
1119 elapsed = util.timer() - tstart
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1120 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1121 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1122 b'store replacement complete; repository was inconsistent for '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1123 b'%0.1fs\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1124 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1125 % elapsed
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1126 )
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1127
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1128 # 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
1129 # out legacy clients.
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1130 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1131 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1132 b'finalizing requirements file and making repository readable '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1133 b'again\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1134 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1135 )
45106
a03c177a4679 scmutil: add writereporequirements() and route requires writing through it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
1136 scmutil.writereporequirements(srcrepo, requirements)
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1137
30781
f2c069bf78ee repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30780
diff changeset
1138 # 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
1139 # 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
1140 # 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
1141 # location. This is simpler.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1142 backupvfs.unlink(b'store/lock')
30781
f2c069bf78ee repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30780
diff changeset
1143
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1144 return backuppath
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1145
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1146
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1147 def upgraderepo(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1148 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1149 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1150 run=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1151 optimize=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1152 backup=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1153 manifest=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1154 changelog=None,
45997
7c539f0febbe upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45995
diff changeset
1155 filelogs=None,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1156 ):
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1157 """Upgrade a repository in place."""
41088
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
1158 if optimize is None:
5608b5a6c323 upgrade: add '-' in optimization name
Boris Feld <boris.feld@octobus.net>
parents: 40997
diff changeset
1159 optimize = []
44452
9d2b2df2c2ba cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents: 44382
diff changeset
1160 optimize = {legacy_opts_map.get(o, o) for o in optimize}
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1161 repo = repo.unfiltered()
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1162
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1163 revlogs = set(UPGRADE_ALL_REVLOGS)
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
1164 specentries = (
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
1165 (UPGRADE_CHANGELOG, changelog),
45997
7c539f0febbe upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45995
diff changeset
1166 (UPGRADE_MANIFEST, manifest),
7c539f0febbe upgrade: add an explicite --filelogs arguments
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45995
diff changeset
1167 (UPGRADE_FILELOGS, filelogs),
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
1168 )
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1169 specified = [(y, x) for (y, x) in specentries if x is not None]
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1170 if specified:
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1171 # we have some limitation on revlogs to be recloned
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1172 if any(x for y, x in specified):
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1173 revlogs = set()
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
1174 for upgrade, enabled in specified:
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1175 if enabled:
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
1176 revlogs.add(upgrade)
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1177 else:
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1178 # none are enabled
45981
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
1179 for upgrade, __ in specified:
53bde3ad0270 upgrade: directly use the upgrade action constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45980
diff changeset
1180 revlogs.discard(upgrade)
42830
cf2b765cecd7 upgrade: add an argument to control manifest upgrade
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42693
diff changeset
1181
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1182 # 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
1183 missingreqs = requiredsourcerequirements(repo) - repo.requirements
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1184 if missingreqs:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1185 raise error.Abort(
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43089
diff changeset
1186 _(b'cannot upgrade repository; requirement missing: %s')
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1187 % _(b', ').join(sorted(missingreqs))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1188 )
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1189
31866
1454726b6d7c upgrade: drop the prefix to the 'blocksourcerequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31865
diff changeset
1190 blockedreqs = blocksourcerequirements(repo) & repo.requirements
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1191 if blockedreqs:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1192 raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1193 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1194 b'cannot upgrade repository; unsupported source '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1195 b'requirement: %s'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1196 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1197 % _(b', ').join(sorted(blockedreqs))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1198 )
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1199
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1200 # 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
1201 # command arguments or via an extension hook point.
39996
dbcb466d0065 localrepo: define storage backend in creation options (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39870
diff changeset
1202 newreqs = localrepo.newreporequirements(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1203 repo.ui, localrepo.defaultcreateopts(repo.ui)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1204 )
35302
ad2b35ebf670 upgraderepo: allow extension to register preserved requirements
Boris Feld <boris.feld@octobus.net>
parents: 33438
diff changeset
1205 newreqs.update(preservedrequirements(repo))
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1206
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1207 noremovereqs = (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1208 repo.requirements - newreqs - supportremovedrequirements(repo)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1209 )
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1210 if noremovereqs:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1211 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1212 _(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1213 b'cannot upgrade repository; requirement would be '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1214 b'removed: %s'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1215 )
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1216 % _(b', ').join(sorted(noremovereqs))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1217 )
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1218
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1219 noaddreqs = newreqs - repo.requirements - allowednewrequirements(repo)
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1220 if noaddreqs:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1221 raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1222 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1223 b'cannot upgrade repository; do not support adding '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1224 b'requirement: %s'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1225 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1226 % _(b', ').join(sorted(noaddreqs))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1227 )
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1228
31870
49011f1cedd4 upgrade: drop the prefix to the 'supporteddestrequirements' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31869
diff changeset
1229 unsupportedreqs = newreqs - supporteddestrequirements(repo)
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1230 if unsupportedreqs:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1231 raise error.Abort(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1232 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1233 b'cannot upgrade repository; do not support '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1234 b'destination requirement: %s'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1235 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1236 % _(b', ').join(sorted(unsupportedreqs))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1237 )
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1238
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1239 # Find and validate all improvements that can be made.
31899
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1240 alloptimizations = findoptimizations(repo)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1241
31899
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1242 # Apply and Validate arguments.
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1243 optimizations = []
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1244 for o in alloptimizations:
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1245 if o.name in optimize:
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1246 optimizations.append(o)
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1247 optimize.discard(o.name)
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1248
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1249 if optimize: # anything left is unknown
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1250 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1251 _(b'unknown optimization action requested: %s')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1252 % b', '.join(sorted(optimize)),
43117
8ff1ecfadcd1 cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents: 43089
diff changeset
1253 hint=_(b'run without arguments to see valid optimizations'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1254 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1255
31897
d0067250542d upgrade: simplify optimisations validation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31896
diff changeset
1256 deficiencies = finddeficiencies(repo)
31899
cccd8e1538b0 upgrade: filter optimizations outside of 'determineactions'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31898
diff changeset
1257 actions = determineactions(repo, deficiencies, repo.requirements, newreqs)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1258 actions.extend(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1259 o
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1260 for o in sorted(optimizations)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1261 # determineactions could have added optimisation
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1262 if o not in actions
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1263 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1264
42832
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
1265 removedreqs = repo.requirements - newreqs
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
1266 addedreqs = newreqs - repo.requirements
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
1267
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
1268 if revlogs != UPGRADE_ALL_REVLOGS:
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
1269 incompatible = RECLONES_REQUIREMENTS & (removedreqs | addedreqs)
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
1270 if incompatible:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1271 msg = _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1272 b'ignoring revlogs selection flags, format requirements '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1273 b'change: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1274 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1275 ui.warn(msg % b', '.join(sorted(incompatible)))
42832
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
1276 revlogs = UPGRADE_ALL_REVLOGS
a3c2ffcd266f upgrade: make sure we reclone all revlogs when updating to some format
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42831
diff changeset
1277
43805
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1278 def write_labeled(l, label):
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1279 first = True
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1280 for r in sorted(l):
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1281 if not first:
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1282 ui.write(b', ')
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1283 ui.write(r, label=label)
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1284 first = False
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1285
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1286 def printrequirements():
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1287 ui.write(_(b'requirements\n'))
43805
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1288 ui.write(_(b' preserved: '))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1289 write_labeled(
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1290 newreqs & repo.requirements, "upgrade-repo.requirement.preserved"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1291 )
43805
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1292 ui.write((b'\n'))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1293 removed = repo.requirements - newreqs
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1294 if repo.requirements - newreqs:
43805
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1295 ui.write(_(b' removed: '))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1296 write_labeled(removed, "upgrade-repo.requirement.removed")
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1297 ui.write((b'\n'))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1298 added = newreqs - repo.requirements
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1299 if added:
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1300 ui.write(_(b' added: '))
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1301 write_labeled(added, "upgrade-repo.requirement.added")
ad84fc97d120 upgrade-repo: colorize some of the output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43148
diff changeset
1302 ui.write((b'\n'))
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1303 ui.write(b'\n')
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1304
44797
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1305 def printoptimisations():
45994
cfae98c4e1f1 upgrade: capitalize the `deficiency` constant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45993
diff changeset
1306 optimisations = [a for a in actions if a.type == OPTIMISATION]
44797
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1307 optimisations.sort(key=lambda a: a.name)
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1308 if optimisations:
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1309 ui.write(_(b'optimisations: '))
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1310 write_labeled(
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1311 [a.name for a in optimisations],
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1312 "upgrade-repo.optimisation.performed",
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1313 )
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1314 ui.write(b'\n\n')
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1315
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1316 def printupgradeactions():
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
1317 for a in actions:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1318 ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage))
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1319
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1320 if not run:
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1321 fromconfig = []
31904
3c77f03f16b3 upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31903
diff changeset
1322 onlydefault = []
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1323
31901
9bdedb050d8d upgrade: simplify some of the initial dispatch for dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31900
diff changeset
1324 for d in deficiencies:
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
1325 if d.fromconfig(repo):
31901
9bdedb050d8d upgrade: simplify some of the initial dispatch for dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31900
diff changeset
1326 fromconfig.append(d)
32031
11a2461fc9b1 upgrade: move descriptions and selection logic in individual classes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 32030
diff changeset
1327 elif d.default:
31904
3c77f03f16b3 upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31903
diff changeset
1328 onlydefault.append(d)
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1329
31904
3c77f03f16b3 upgrade: simplify the "origin" dispatch in dry run
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31903
diff changeset
1330 if fromconfig or onlydefault:
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1331
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1332 if fromconfig:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1333 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1334 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1335 b'repository lacks features recommended by '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1336 b'current config options:\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1337 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1338 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1339 for i in fromconfig:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1340 ui.status(b'%s\n %s\n\n' % (i.name, i.description))
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1341
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1342 if onlydefault:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1343 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1344 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1345 b'repository lacks features used by the default '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1346 b'config options:\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1347 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1348 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1349 for i in onlydefault:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1350 ui.status(b'%s\n %s\n\n' % (i.name, i.description))
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1351
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1352 ui.status(b'\n')
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1353 else:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1354 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1355 _(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1356 b'(no feature deficiencies found in existing '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1357 b'repository)\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1358 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1359 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1360
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1361 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1362 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1363 b'performing an upgrade with "--run" will make the following '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1364 b'changes:\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1365 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1366 )
30775
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1367
513d68a90398 repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30707
diff changeset
1368 printrequirements()
44797
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1369 printoptimisations()
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1370 printupgradeactions()
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1371
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
1372 unusedoptimize = [i for i in alloptimizations if i not in actions]
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
1373
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1374 if unusedoptimize:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1375 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1376 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1377 b'additional optimizations are available by specifying '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1378 b'"--optimize <name>":\n\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1379 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1380 )
30776
3997edc4a86d repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30775
diff changeset
1381 for i in unusedoptimize:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1382 ui.status(_(b'%s\n %s\n\n') % (i.name, i.description))
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1383 return
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1384
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1385 # Else we're in the run=true case.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1386 ui.write(_(b'upgrade will perform the following actions:\n\n'))
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1387 printrequirements()
44797
5ee4b2119af9 upgrade: clearly list optimisations
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44746
diff changeset
1388 printoptimisations()
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1389 printupgradeactions()
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1390
31903
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
1391 upgradeactions = [a.name for a in actions]
fa1088de2119 upgrade: use 'improvement' object for action too
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31902
diff changeset
1392
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1393 ui.status(_(b'beginning upgrade...\n'))
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1394 with repo.wlock(), repo.lock():
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1395 ui.status(_(b'repository locked and read-only\n'))
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1396 # Our strategy for upgrading the repository is to create a new,
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1397 # temporary repository, write data to it, then do a swap of the
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1398 # data. There are less heavyweight ways to do this, but it is easier
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1399 # to create a new repo object than to instantiate all the components
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1400 # (like the store) separately.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1401 tmppath = pycompat.mkdtemp(prefix=b'upgrade.', dir=repo.path)
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1402 backuppath = None
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1403 try:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1404 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1405 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1406 b'creating temporary repository to stage migrated '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1407 b'data: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1408 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1409 % tmppath
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1410 )
35342
75520786ad2f upgrade: use the repository 'ui' as the base for the new repository
Boris Feld <boris.feld@octobus.net>
parents: 35340
diff changeset
1411
35379
6c28956ba2d4 upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents: 35345
diff changeset
1412 # clone ui without using ui.copy because repo.ui is protected
6c28956ba2d4 upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents: 35345
diff changeset
1413 repoui = repo.ui.__class__(repo.ui)
6c28956ba2d4 upgrade: simplify workaround for repo.ui.copy()
Yuya Nishihara <yuya@tcha.org>
parents: 35345
diff changeset
1414 dstrepo = hg.repository(repoui, path=tmppath, create=True)
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1415
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1416 with dstrepo.wlock(), dstrepo.lock():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1417 backuppath = _upgraderepo(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1418 ui, repo, dstrepo, newreqs, upgradeactions, revlogs=revlogs
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1419 )
41089
a59a74721c76 debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents: 41088
diff changeset
1420 if not (backup or backuppath is None):
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1421 ui.status(
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1422 _(b'removing old repository content%s\n') % backuppath
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1423 )
41089
a59a74721c76 debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents: 41088
diff changeset
1424 repo.vfs.rmtree(backuppath, forcibly=True)
a59a74721c76 debugupgraderepo: add a --no-backup mode
Boris Feld <boris.feld@octobus.net>
parents: 41088
diff changeset
1425 backuppath = None
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1426
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1427 finally:
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1428 ui.status(_(b'removing temporary repository %s\n') % tmppath)
33438
8056481caa81 codemod: simplify nested withs
Jun Wu <quark@fb.com>
parents: 32291
diff changeset
1429 repo.vfs.rmtree(tmppath, forcibly=True)
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
1430
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
1431 if backuppath and not ui.quiet:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1432 ui.warn(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1433 _(b'copy of old repository backed up at %s\n') % backuppath
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1434 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1435 ui.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1436 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1437 b'the old repository will not be deleted; remove '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1438 b'it to free up disk space once the upgraded '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1439 b'repository is verified\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1440 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
1441 )