author | Pulkit Goyal <7895pulkit@gmail.com> |
Wed, 16 Dec 2020 14:16:10 +0530 | |
changeset 46210 | 6b40aac4da8e |
parent 46194 | 4d1cec4e5e1f |
child 46214 | 5dfa837d933e |
permissions | -rw-r--r-- |
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 |
|
46046
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
12 |
from ..i18n import _ |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
13 |
from ..pycompat import getattr |
f105c49e89cd
upgrade: split actual upgrade code away from the main module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46035
diff
changeset
|
14 |
from .. import ( |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
15 |
changelog, |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26425
diff
changeset
|
16 |
error, |
35344
8f3f8b8dbab7
upgrade: use actual filelog to convert filelog
Boris Feld <boris.feld@octobus.net>
parents:
35343
diff
changeset
|
17 |
filelog, |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
18 |
manifest, |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44841
diff
changeset
|
19 |
metadata, |
38165
2ce60954b1b7
py3: wrap tempfile.mkdtemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents:
37444
diff
changeset
|
20 |
pycompat, |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45371
diff
changeset
|
21 |
requirements, |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
22 |
revlog, |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
23 |
scmutil, |
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
24 |
util, |
31232
254f98326eef
vfs: use 'vfs' module directly in 'mercurial.repair'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30975
diff
changeset
|
25 |
vfs as vfsmod, |
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
26 |
) |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
27 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
28 |
|
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
29 |
def _revlogfrompath(repo, path): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
30 |
"""Obtain a revlog from a repo path. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
31 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
32 |
An instance of the appropriate class is returned. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
33 |
""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
34 |
if path == b'00changelog.i': |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
35 |
return changelog.changelog(repo.svfs) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
36 |
elif path.endswith(b'00manifest.i'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
37 |
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
|
38 |
return manifest.manifestrevlog(repo.svfs, tree=mandir) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
39 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
40 |
# 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
|
41 |
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
|
42 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
43 |
|
42691
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
44 |
def _copyrevlog(tr, destrepo, oldrl, unencodedname): |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
45 |
"""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
|
46 |
|
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
""" |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
51 |
oldrl = getattr(oldrl, '_revlog', oldrl) |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
52 |
newrl = _revlogfrompath(destrepo, unencodedname) |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
53 |
newrl = getattr(newrl, '_revlog', newrl) |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
54 |
|
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
55 |
oldvfs = oldrl.opener |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
56 |
newvfs = newrl.opener |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
57 |
oldindex = oldvfs.join(oldrl.indexfile) |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
58 |
newindex = newvfs.join(newrl.indexfile) |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
59 |
olddata = oldvfs.join(oldrl.datafile) |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
60 |
newdata = newvfs.join(newrl.datafile) |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
61 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
62 |
with newvfs(newrl.indexfile, b'w'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
63 |
pass # create all the directories |
42691
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
64 |
|
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
65 |
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
|
66 |
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
|
67 |
if copydata: |
42691
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
68 |
util.copyfile(olddata, newdata) |
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
69 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
70 |
if not ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
71 |
unencodedname.endswith(b'00changelog.i') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
72 |
or unencodedname.endswith(b'00manifest.i') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
73 |
): |
42691
5535a2201ff1
upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42690
diff
changeset
|
74 |
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
|
75 |
if copydata: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
76 |
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
|
77 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
78 |
|
46035
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
79 |
UPGRADE_CHANGELOG = b"changelog" |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
80 |
UPGRADE_MANIFEST = b"manifest" |
6c960b708ac4
upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46003
diff
changeset
|
81 |
UPGRADE_FILELOGS = b"all-filelogs" |
42693
0812d9fb63fe
upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42691
diff
changeset
|
82 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
83 |
UPGRADE_ALL_REVLOGS = frozenset( |
45980
fe7d7917ceb5
upgrade: rename UPGRADE_FILELOG to UPGRADE_FILELOGS
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45735
diff
changeset
|
84 |
[UPGRADE_CHANGELOG, UPGRADE_MANIFEST, UPGRADE_FILELOGS] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
85 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
86 |
|
42693
0812d9fb63fe
upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42691
diff
changeset
|
87 |
|
43135
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
88 |
def getsidedatacompanion(srcrepo, dstrepo): |
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
89 |
sidedatacompanion = None |
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
90 |
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
|
91 |
addedreqs = dstrepo.requirements - srcrepo.requirements |
45373
d7dcc75a3eae
localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45372
diff
changeset
|
92 |
if requirements.SIDEDATA_REQUIREMENT in removedreqs: |
43135
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
93 |
|
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
94 |
def sidedatacompanion(rl, rev): |
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
95 |
rl = getattr(rl, '_revlog', rl) |
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
96 |
if rl.flags(rev) & revlog.REVIDX_SIDEDATA: |
45735
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45694
diff
changeset
|
97 |
return True, (), {}, 0, 0 |
edf4fa06df94
upgrade: allow sidedata upgrade to modify revision flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45694
diff
changeset
|
98 |
return False, (), {}, 0, 0 |
43135
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
99 |
|
45373
d7dcc75a3eae
localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45372
diff
changeset
|
100 |
elif requirements.COPIESSDC_REQUIREMENT in addedreqs: |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44841
diff
changeset
|
101 |
sidedatacompanion = metadata.getsidedataadder(srcrepo, dstrepo) |
45373
d7dcc75a3eae
localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45372
diff
changeset
|
102 |
elif requirements.COPIESSDC_REQUIREMENT in removedreqs: |
44940
4c1d39215034
metadata: move computation related to files touched in a dedicated module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44841
diff
changeset
|
103 |
sidedatacompanion = metadata.getsidedataremover(srcrepo, dstrepo) |
43135
6e3dc1eff5c7
upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43134
diff
changeset
|
104 |
return sidedatacompanion |
43134
75ad8af9c95e
upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
105 |
|
75ad8af9c95e
upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
106 |
|
42693
0812d9fb63fe
upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42691
diff
changeset
|
107 |
def matchrevlog(revlogfilter, entry): |
45694
d1c10d33a85c
upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45487
diff
changeset
|
108 |
"""check if a revlog is selected for cloning. |
d1c10d33a85c
upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45487
diff
changeset
|
109 |
|
d1c10d33a85c
upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45487
diff
changeset
|
110 |
In other words, are there any updates which need to be done on revlog |
d1c10d33a85c
upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45487
diff
changeset
|
111 |
or it can be blindly copied. |
42693
0812d9fb63fe
upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42691
diff
changeset
|
112 |
|
0812d9fb63fe
upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42691
diff
changeset
|
113 |
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
|
114 |
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
|
115 |
return UPGRADE_CHANGELOG in revlogfilter |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 |
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
|
117 |
return UPGRADE_MANIFEST in revlogfilter |
45980
fe7d7917ceb5
upgrade: rename UPGRADE_FILELOG to UPGRADE_FILELOGS
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45735
diff
changeset
|
118 |
return UPGRADE_FILELOGS in revlogfilter |
42693
0812d9fb63fe
upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42691
diff
changeset
|
119 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
120 |
|
46193
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
121 |
def _perform_clone( |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
122 |
ui, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
123 |
dstrepo, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
124 |
tr, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
125 |
old_revlog, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
126 |
unencoded, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
127 |
deltareuse, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
128 |
forcedeltabothparents, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
129 |
revlogs, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
130 |
sidedatacompanion, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
131 |
oncopiedrevision, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
132 |
): |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
133 |
""" returns the new revlog object created""" |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
134 |
newrl = None |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
135 |
if matchrevlog(revlogs, unencoded): |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
136 |
ui.note( |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
137 |
_(b'cloning %d revisions from %s\n') % (len(old_revlog), unencoded) |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
138 |
) |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
139 |
newrl = _revlogfrompath(dstrepo, unencoded) |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
140 |
old_revlog.clone( |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
141 |
tr, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
142 |
newrl, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
143 |
addrevisioncb=oncopiedrevision, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
144 |
deltareuse=deltareuse, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
145 |
forcedeltabothparents=forcedeltabothparents, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
146 |
sidedatacompanion=sidedatacompanion, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
147 |
) |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
148 |
else: |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
149 |
msg = _(b'blindly copying %s containing %i revisions\n') |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
150 |
ui.note(msg % (unencoded, len(old_revlog))) |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
151 |
_copyrevlog(tr, dstrepo, old_revlog, unencoded) |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
152 |
|
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
153 |
newrl = _revlogfrompath(dstrepo, unencoded) |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
154 |
return newrl |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
155 |
|
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
156 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
157 |
def _clonerevlogs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
158 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
159 |
srcrepo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
160 |
dstrepo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
161 |
tr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
162 |
deltareuse, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
163 |
forcedeltabothparents, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
164 |
revlogs=UPGRADE_ALL_REVLOGS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
165 |
): |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
166 |
"""Copy revlogs between 2 repos.""" |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
167 |
revcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
168 |
srcsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
169 |
srcrawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
170 |
dstsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
171 |
fcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
172 |
frevcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
173 |
fsrcsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
174 |
frawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
175 |
fdstsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
176 |
mcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
177 |
mrevcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
178 |
msrcsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
179 |
mrawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
180 |
mdstsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
181 |
crevcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
182 |
csrcsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
183 |
crawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
184 |
cdstsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
185 |
|
42689
896fb9deeaf8
upgrade: walk the source store file only once
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42137
diff
changeset
|
186 |
alldatafiles = list(srcrepo.store.walk()) |
46194
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
187 |
# mapping of data files which needs to be cloned |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
188 |
# key is unencoded filename |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
189 |
# value is revlog_object_from_srcrepo |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
190 |
manifests = {} |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
191 |
changelogs = {} |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
192 |
filelogs = {} |
42689
896fb9deeaf8
upgrade: walk the source store file only once
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42137
diff
changeset
|
193 |
|
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
194 |
# 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
|
195 |
# 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
|
196 |
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
|
197 |
if unencoded.endswith(b'.d'): |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
198 |
continue |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
199 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
200 |
rl = _revlogfrompath(srcrepo, unencoded) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
201 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
202 |
info = rl.storageinfo( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
203 |
exclusivefiles=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
204 |
revisionscount=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
205 |
trackedsize=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
206 |
storedsize=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
207 |
) |
39857
8dab7c8a93eb
upgrade: report size of backing files, not internal storage size
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39546
diff
changeset
|
208 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
209 |
revcount += info[b'revisionscount'] or 0 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
210 |
datasize = info[b'storedsize'] or 0 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
211 |
rawsize = info[b'trackedsize'] or 0 |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
212 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
213 |
srcsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
214 |
srcrawsize += rawsize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
215 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
216 |
# This is for the separate progress bars. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
217 |
if isinstance(rl, changelog.changelog): |
46194
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
218 |
changelogs[unencoded] = rl |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
219 |
crevcount += len(rl) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
220 |
csrcsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
221 |
crawsize += rawsize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
222 |
elif isinstance(rl, manifest.manifestrevlog): |
46194
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
223 |
manifests[unencoded] = rl |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
224 |
mcount += 1 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
225 |
mrevcount += len(rl) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
226 |
msrcsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
227 |
mrawsize += rawsize |
37444
c8666a9e9e11
upgrade: sniff for filelog type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36373
diff
changeset
|
228 |
elif isinstance(rl, filelog.filelog): |
46194
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
229 |
filelogs[unencoded] = rl |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
230 |
fcount += 1 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
231 |
frevcount += len(rl) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
232 |
fsrcsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
233 |
frawsize += rawsize |
37444
c8666a9e9e11
upgrade: sniff for filelog type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36373
diff
changeset
|
234 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
235 |
error.ProgrammingError(b'unknown revlog type') |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
236 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
237 |
if not revcount: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
238 |
return |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
239 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
240 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
241 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
242 |
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
|
243 |
b'%d in changelog)\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
244 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
245 |
% (revcount, frevcount, mrevcount, crevcount) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
246 |
) |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
247 |
ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
248 |
_(b'migrating %s in store; %s tracked data\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
249 |
% ((util.bytecount(srcsize), util.bytecount(srcrawsize))) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
250 |
) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
251 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
252 |
# Used to keep track of progress. |
38399
185588cb0c4b
upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38398
diff
changeset
|
253 |
progress = None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
254 |
|
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
255 |
def oncopiedrevision(rl, rev, node): |
38399
185588cb0c4b
upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38398
diff
changeset
|
256 |
progress.increment() |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
257 |
|
43134
75ad8af9c95e
upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
258 |
sidedatacompanion = getsidedatacompanion(srcrepo, dstrepo) |
75ad8af9c95e
upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
259 |
|
46194
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
260 |
# Migrating filelogs |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
261 |
ui.status( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
262 |
_( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
263 |
b'migrating %d filelogs containing %d revisions ' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
264 |
b'(%s in store; %s tracked data)\n' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
265 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
266 |
% ( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
267 |
fcount, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
268 |
frevcount, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
269 |
util.bytecount(fsrcsize), |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
270 |
util.bytecount(frawsize), |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
271 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
272 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
273 |
progress = srcrepo.ui.makeprogress(_(b'file revisions'), total=frevcount) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
274 |
for unencoded, oldrl in sorted(filelogs.items()): |
46193
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
275 |
newrl = _perform_clone( |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
276 |
ui, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
277 |
dstrepo, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
278 |
tr, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
279 |
oldrl, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
280 |
unencoded, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
281 |
deltareuse, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
282 |
forcedeltabothparents, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
283 |
revlogs, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
284 |
sidedatacompanion, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
285 |
oncopiedrevision, |
85f7cf314b39
engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46191
diff
changeset
|
286 |
) |
39870
b399ff55ee6d
upgrade: use storageinfo() for obtaining storage metadata
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39859
diff
changeset
|
287 |
info = newrl.storageinfo(storedsize=True) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
288 |
datasize = info[b'storedsize'] or 0 |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
289 |
dstsize += datasize |
46194
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
290 |
fdstsize += datasize |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
291 |
ui.status( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
292 |
_( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
293 |
b'finished migrating %d filelog revisions across %d ' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
294 |
b'filelogs; change in size: %s\n' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
295 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
296 |
% (frevcount, fcount, util.bytecount(fdstsize - fsrcsize)) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
297 |
) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
298 |
|
46194
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
299 |
# Migrating manifests |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
300 |
ui.status( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
301 |
_( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
302 |
b'migrating %d manifests containing %d revisions ' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
303 |
b'(%s in store; %s tracked data)\n' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
304 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
305 |
% ( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
306 |
mcount, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
307 |
mrevcount, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
308 |
util.bytecount(msrcsize), |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
309 |
util.bytecount(mrawsize), |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
310 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
311 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
312 |
if progress: |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
313 |
progress.complete() |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
314 |
progress = srcrepo.ui.makeprogress( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
315 |
_(b'manifest revisions'), total=mrevcount |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
316 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
317 |
for unencoded, oldrl in sorted(manifests.items()): |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
318 |
newrl = _perform_clone( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
319 |
ui, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
320 |
dstrepo, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
321 |
tr, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
322 |
oldrl, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
323 |
unencoded, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
324 |
deltareuse, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
325 |
forcedeltabothparents, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
326 |
revlogs, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
327 |
sidedatacompanion, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
328 |
oncopiedrevision, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
329 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
330 |
info = newrl.storageinfo(storedsize=True) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
331 |
datasize = info[b'storedsize'] or 0 |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
332 |
dstsize += datasize |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
333 |
mdstsize += datasize |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
334 |
ui.status( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
335 |
_( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
336 |
b'finished migrating %d manifest revisions across %d ' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
337 |
b'manifests; change in size: %s\n' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
338 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
339 |
% (mrevcount, mcount, util.bytecount(mdstsize - msrcsize)) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
340 |
) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
341 |
|
46194
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
342 |
# Migrating changelog |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
343 |
ui.status( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
344 |
_( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
345 |
b'migrating changelog containing %d revisions ' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
346 |
b'(%s in store; %s tracked data)\n' |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
347 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
348 |
% ( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
349 |
crevcount, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
350 |
util.bytecount(csrcsize), |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
351 |
util.bytecount(crawsize), |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
352 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
353 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
354 |
if progress: |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
355 |
progress.complete() |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
356 |
progress = srcrepo.ui.makeprogress( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
357 |
_(b'changelog revisions'), total=crevcount |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
358 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
359 |
for unencoded, oldrl in sorted(changelogs.items()): |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
360 |
newrl = _perform_clone( |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
361 |
ui, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
362 |
dstrepo, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
363 |
tr, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
364 |
oldrl, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
365 |
unencoded, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
366 |
deltareuse, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
367 |
forcedeltabothparents, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
368 |
revlogs, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
369 |
sidedatacompanion, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
370 |
oncopiedrevision, |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
371 |
) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
372 |
info = newrl.storageinfo(storedsize=True) |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
373 |
datasize = info[b'storedsize'] or 0 |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
374 |
dstsize += datasize |
4d1cec4e5e1f
engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46193
diff
changeset
|
375 |
cdstsize += datasize |
38399
185588cb0c4b
upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
38398
diff
changeset
|
376 |
progress.complete() |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
377 |
ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
378 |
_( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
379 |
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
|
380 |
b'%s\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
381 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
382 |
% (crevcount, util.bytecount(cdstsize - csrcsize)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
383 |
) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
384 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
385 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
386 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
387 |
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
|
388 |
b'size: %s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
389 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
390 |
% (revcount, util.bytecount(dstsize - srcsize)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
391 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
392 |
|
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
393 |
|
31873
d6c2005484b6
upgrade: drop the prefix to the '_filterstorefile' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31872
diff
changeset
|
394 |
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
|
395 |
"""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
|
396 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
397 |
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
|
398 |
``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
|
399 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
400 |
Args: |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
401 |
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
|
402 |
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
|
403 |
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
|
404 |
path: store file being examined |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
405 |
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
|
406 |
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
|
407 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
408 |
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
|
409 |
""" |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
410 |
# Skip revlogs. |
44841
526d69eeea31
upgrade: support upgrade and downgrade from persistent nodemap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44799
diff
changeset
|
411 |
if path.endswith((b'.i', b'.d', b'.n', b'.nd')): |
30780
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
412 |
return False |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
413 |
# Skip transaction related files. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
414 |
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
|
415 |
return False |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
416 |
# Only copy regular files. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
417 |
if mode != stat.S_IFREG: |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
418 |
return False |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
419 |
# Skip other skipped files. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
420 |
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
|
421 |
return False |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
422 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
423 |
return True |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
424 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
425 |
|
31874
27ec6517e40e
upgrade: drop the prefix to the '_finishdatamigration' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31873
diff
changeset
|
426 |
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
|
427 |
"""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
|
428 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
429 |
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
|
430 |
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
|
431 |
""" |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
432 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
433 |
|
46056
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46046
diff
changeset
|
434 |
def upgrade(ui, srcrepo, dstrepo, upgrade_op): |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
435 |
"""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
|
436 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
437 |
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
|
438 |
repository and a temporary destination repository. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
439 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
""" |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
444 |
assert srcrepo.currentwlock() |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
445 |
assert dstrepo.currentwlock() |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
446 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
447 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
448 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
449 |
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
|
450 |
b'data migration completes)\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
451 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
452 |
) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
453 |
|
46210
6b40aac4da8e
upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46194
diff
changeset
|
454 |
if upgrade_op.has_upgrade_action(b're-delta-all'): |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
455 |
deltareuse = revlog.revlog.DELTAREUSENEVER |
46210
6b40aac4da8e
upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46194
diff
changeset
|
456 |
elif upgrade_op.has_upgrade_action(b're-delta-parent'): |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
457 |
deltareuse = revlog.revlog.DELTAREUSESAMEREVS |
46210
6b40aac4da8e
upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46194
diff
changeset
|
458 |
elif upgrade_op.has_upgrade_action(b're-delta-multibase'): |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
459 |
deltareuse = revlog.revlog.DELTAREUSESAMEREVS |
46210
6b40aac4da8e
upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46194
diff
changeset
|
460 |
elif upgrade_op.has_upgrade_action(b're-delta-fulladd'): |
35345
6226668a7169
upgrade: add a 'redeltafullall' mode
Boris Feld <boris.feld@octobus.net>
parents:
35344
diff
changeset
|
461 |
deltareuse = revlog.revlog.DELTAREUSEFULLADD |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
462 |
else: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
463 |
deltareuse = revlog.revlog.DELTAREUSEALWAYS |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
464 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
465 |
with dstrepo.transaction(b'upgrade') as tr: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
466 |
_clonerevlogs( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
467 |
ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
468 |
srcrepo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
469 |
dstrepo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
470 |
tr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
471 |
deltareuse, |
46210
6b40aac4da8e
upgrade: rename actions to upgrade_actions
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46194
diff
changeset
|
472 |
upgrade_op.has_upgrade_action(b're-delta-multibase'), |
46056
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46046
diff
changeset
|
473 |
revlogs=upgrade_op.revlogs_to_process, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
474 |
) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
475 |
|
30780
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
476 |
# 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
|
477 |
# The sorted() makes execution deterministic. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
478 |
for p, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)): |
46056
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46046
diff
changeset
|
479 |
if not _filterstorefile( |
46191
aba979b1b90b
upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46189
diff
changeset
|
480 |
srcrepo, dstrepo, upgrade_op.new_requirements, p, kind, st |
46056
c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46046
diff
changeset
|
481 |
): |
30780
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
482 |
continue |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
483 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
484 |
srcrepo.ui.status(_(b'copying %s\n') % p) |
31799
8110d49e0558
repair: use rawvfs when copying extra store files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31797
diff
changeset
|
485 |
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
|
486 |
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
|
487 |
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
|
488 |
|
31874
27ec6517e40e
upgrade: drop the prefix to the '_finishdatamigration' function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31873
diff
changeset
|
489 |
_finishdatamigration(ui, srcrepo, dstrepo, requirements) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
490 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
491 |
ui.status(_(b'data fully migrated to temporary repository\n')) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
492 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
493 |
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
|
494 |
backupvfs = vfsmod.vfs(backuppath) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
495 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
496 |
# 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
|
497 |
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
|
498 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
499 |
# 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
|
500 |
# 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
|
501 |
# 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
|
502 |
# an inconsistent state. |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
503 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
504 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
505 |
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
|
506 |
b'unable to read from repository\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
507 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
508 |
) |
45106
a03c177a4679
scmutil: add writereporequirements() and route requires writing through it
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44940
diff
changeset
|
509 |
scmutil.writereporequirements( |
a03c177a4679
scmutil: add writereporequirements() and route requires writing through it
Pulkit Goyal <7895pulkit@gmail.com>
parents:
44940
diff
changeset
|
510 |
srcrepo, srcrepo.requirements | {b'upgradeinprogress'} |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
511 |
) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
512 |
|
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
513 |
ui.status(_(b'starting in-place swap of repository data\n')) |
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
514 |
ui.status(_(b'replaced files will be backed up at %s\n') % backuppath) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
515 |
|
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
516 |
# 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
|
517 |
# 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
|
518 |
# environments). |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
519 |
ui.status(_(b'replacing store...\n')) |
30975
22fbca1d11ed
mercurial: switch to util.timer for all interval timings
Simon Farnsworth <simonfar@fb.com>
parents:
30781
diff
changeset
|
520 |
tstart = util.timer() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
521 |
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
|
522 |
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
|
523 |
elapsed = util.timer() - tstart |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
524 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
525 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
526 |
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
|
527 |
b'%0.1fs\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
528 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
529 |
% elapsed |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
530 |
) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
531 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
532 |
# 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
|
533 |
# out legacy clients. |
44798
e295ba238bd8
upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44797
diff
changeset
|
534 |
ui.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
535 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
536 |
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
|
537 |
b'again\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
538 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43031
diff
changeset
|
539 |
) |
46191
aba979b1b90b
upgrade: move `printrequirements()` to UpgradeOperation class
Pulkit Goyal <7895pulkit@gmail.com>
parents:
46189
diff
changeset
|
540 |
scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
541 |
|
30781
f2c069bf78ee
repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30780
diff
changeset
|
542 |
# 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
|
543 |
# 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
|
544 |
# 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
|
545 |
# location. This is simpler. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
546 |
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
|
547 |
|
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
548 |
return backuppath |