annotate mercurial/upgrade.py @ 43784:995066c41bb2

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