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