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