annotate mercurial/upgrade_utils/engine.py @ 46652:75832107ec07

hgtagsfnodes: refactor code to compute fnode into separate fn I plan to use this code at one more place while fixing a bug caused by an invalid fnode present in cache. Differential Revision: https://phab.mercurial-scm.org/D10013
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 16 Feb 2021 18:43:42 +0530
parents 67b5fafd3a46
children 6266d19556ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31894
9379689b6c10 upgrade: update the header comment
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31893
diff changeset
1 # upgrade.py - functions for in place upgrade of Mercurial repository
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
2 #
31895
783b4c9bd5f5 upgrade: update the copyright statement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31894
diff changeset
3 # Copyright (c) 2016-present, Gregory Szorc
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
4 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8073
diff changeset
5 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 9150
diff changeset
6 # GNU General Public License version 2 or any later version.
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
7
25970
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
8 from __future__ import absolute_import
d1419cfbd4f4 repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25874
diff changeset
9
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
10 import stat
4702
18e91c9def0c strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
11
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 )
46472
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
27 from ..revlogutils import nodemap
25970
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
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
30 def _revlogfrompath(repo, path):
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
31 """Obtain a revlog from a repo path.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
32
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
33 An instance of the appropriate class is returned.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
34 """
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
35 if path == b'00changelog.i':
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
36 return changelog.changelog(repo.svfs)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
37 elif path.endswith(b'00manifest.i'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
38 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
39 return manifest.manifestrevlog(repo.svfs, tree=mandir)
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
40 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
41 # 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
42 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
43
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
44
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
45 def _copyrevlog(tr, destrepo, oldrl, unencodedname):
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
46 """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
47
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
48 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
49 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
50 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
51 """
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
52 oldrl = getattr(oldrl, '_revlog', oldrl)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
53 newrl = _revlogfrompath(destrepo, unencodedname)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
54 newrl = getattr(newrl, '_revlog', newrl)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
55
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
56 oldvfs = oldrl.opener
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
57 newvfs = newrl.opener
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
58 oldindex = oldvfs.join(oldrl.indexfile)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
59 newindex = newvfs.join(newrl.indexfile)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
60 olddata = oldvfs.join(oldrl.datafile)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
61 newdata = newvfs.join(newrl.datafile)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
62
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
63 with newvfs(newrl.indexfile, b'w'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
64 pass # create all the directories
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
65
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
66 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
67 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
68 if copydata:
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
69 util.copyfile(olddata, newdata)
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
70
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
71 if not (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
72 unencodedname.endswith(b'00changelog.i')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
73 or unencodedname.endswith(b'00manifest.i')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
74 ):
42691
5535a2201ff1 upgrade: introduce a _copyrevlog method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42690
diff changeset
75 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
76 if copydata:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
77 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
78
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
79
46035
6c960b708ac4 upgrade: display the list of processed revlog before proceeding
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46003
diff changeset
80 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
81 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
82 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
83
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
84 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
85 [UPGRADE_CHANGELOG, UPGRADE_MANIFEST, UPGRADE_FILELOGS]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
86 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
87
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
88
43135
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
89 def getsidedatacompanion(srcrepo, dstrepo):
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
90 sidedatacompanion = None
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
91 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
92 addedreqs = dstrepo.requirements - srcrepo.requirements
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
93 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
94
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
95 def sidedatacompanion(rl, rev):
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
96 rl = getattr(rl, '_revlog', rl)
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
97 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
98 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
99 return False, (), {}, 0, 0
43135
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
100
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
101 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
102 sidedatacompanion = metadata.getsidedataadder(srcrepo, dstrepo)
45373
d7dcc75a3eae localrepo: move requirements constant to requirements module
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45372
diff changeset
103 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
104 sidedatacompanion = metadata.getsidedataremover(srcrepo, dstrepo)
43135
6e3dc1eff5c7 upgrade: allow for `sidedata` removal
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43134
diff changeset
105 return sidedatacompanion
43134
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
106
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
107
42693
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
108 def matchrevlog(revlogfilter, entry):
45694
d1c10d33a85c upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45487
diff changeset
109 """check if a revlog is selected for cloning.
d1c10d33a85c upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45487
diff changeset
110
d1c10d33a85c upgrade: improve documentation of matchrevlog()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 45487
diff changeset
111 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
112 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
113
0812d9fb63fe upgrade: introduce the internal code for revlog cloning selection
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42691
diff changeset
114 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
115 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
116 return UPGRADE_CHANGELOG in revlogfilter
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
117 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
118 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
119 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
120
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
121
46193
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
122 def _perform_clone(
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
123 ui,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
124 dstrepo,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
125 tr,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
126 old_revlog,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
127 unencoded,
46217
02df91e895bd engine: pass upgrade operation inside `_perform_clone()`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46216
diff changeset
128 upgrade_op,
46193
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
129 sidedatacompanion,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
130 oncopiedrevision,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
131 ):
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
132 """ returns the new revlog object created"""
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
133 newrl = None
46217
02df91e895bd engine: pass upgrade operation inside `_perform_clone()`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46216
diff changeset
134 if matchrevlog(upgrade_op.revlogs_to_process, unencoded):
46193
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
135 ui.note(
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
136 _(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
137 )
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
138 newrl = _revlogfrompath(dstrepo, unencoded)
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
139 old_revlog.clone(
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
140 tr,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
141 newrl,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
142 addrevisioncb=oncopiedrevision,
46217
02df91e895bd engine: pass upgrade operation inside `_perform_clone()`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46216
diff changeset
143 deltareuse=upgrade_op.delta_reuse_mode,
46218
3f92a9bb80f0 engine: prevent multiple checking of re-delta-multibase
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46217
diff changeset
144 forcedeltabothparents=upgrade_op.force_re_delta_both_parents,
46193
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
145 sidedatacompanion=sidedatacompanion,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
146 )
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
147 else:
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
148 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
149 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
150 _copyrevlog(tr, dstrepo, old_revlog, unencoded)
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
151
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
152 newrl = _revlogfrompath(dstrepo, unencoded)
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
153 return newrl
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
154
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
155
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
156 def _clonerevlogs(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
157 ui,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
158 srcrepo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
159 dstrepo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
160 tr,
46216
34efa84a43a1 engine: pass upgrade operation inside _clonerevlogs()
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46215
diff changeset
161 upgrade_op,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
162 ):
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
163 """Copy revlogs between 2 repos."""
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
164 revcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
165 srcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
166 srcrawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
167 dstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
168 fcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
169 frevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
170 fsrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
171 frawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
172 fdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
173 mcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
174 mrevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
175 msrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
176 mrawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
177 mdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
178 crevcount = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
179 csrcsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
180 crawsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
181 cdstsize = 0
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
182
42689
896fb9deeaf8 upgrade: walk the source store file only once
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42137
diff changeset
183 alldatafiles = list(srcrepo.store.walk())
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
184 # 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
185 # key is unencoded filename
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
186 # value is revlog_object_from_srcrepo
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
187 manifests = {}
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
188 changelogs = {}
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
189 filelogs = {}
42689
896fb9deeaf8 upgrade: walk the source store file only once
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42137
diff changeset
190
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
191 # 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
192 # 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
193 for unencoded, encoded, size in alldatafiles:
46252
8023991dc811 upgrade: explicitly test for revlog index
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46229
diff changeset
194 if not unencoded.endswith(b'.i'):
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
195 continue
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
196
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
197 rl = _revlogfrompath(srcrepo, unencoded)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
198
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
199 info = rl.storageinfo(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
200 exclusivefiles=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
201 revisionscount=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
202 trackedsize=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
203 storedsize=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
204 )
39857
8dab7c8a93eb upgrade: report size of backing files, not internal storage size
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39546
diff changeset
205
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
206 revcount += info[b'revisionscount'] or 0
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
207 datasize = info[b'storedsize'] or 0
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
208 rawsize = info[b'trackedsize'] or 0
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
209
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
210 srcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
211 srcrawsize += rawsize
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 # This is for the separate progress bars.
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
214 if isinstance(rl, changelog.changelog):
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
215 changelogs[unencoded] = rl
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
216 crevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
217 csrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
218 crawsize += rawsize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
219 elif isinstance(rl, manifest.manifestrevlog):
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
220 manifests[unencoded] = rl
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
221 mcount += 1
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
222 mrevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
223 msrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
224 mrawsize += rawsize
37444
c8666a9e9e11 upgrade: sniff for filelog type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36373
diff changeset
225 elif isinstance(rl, filelog.filelog):
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
226 filelogs[unencoded] = rl
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
227 fcount += 1
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
228 frevcount += len(rl)
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
229 fsrcsize += datasize
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
230 frawsize += rawsize
37444
c8666a9e9e11 upgrade: sniff for filelog type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36373
diff changeset
231 else:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
232 error.ProgrammingError(b'unknown revlog type')
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
233
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
234 if not revcount:
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
235 return
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
236
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
237 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
238 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
239 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
240 b'%d in changelog)\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
241 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
242 % (revcount, frevcount, mrevcount, crevcount)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
243 )
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
244 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
245 _(b'migrating %s in store; %s tracked data\n')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
246 % ((util.bytecount(srcsize), util.bytecount(srcrawsize)))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
247 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
248
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
249 # Used to keep track of progress.
38399
185588cb0c4b upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38398
diff changeset
250 progress = None
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
251
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
252 def oncopiedrevision(rl, rev, node):
38399
185588cb0c4b upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38398
diff changeset
253 progress.increment()
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
254
43134
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
255 sidedatacompanion = getsidedatacompanion(srcrepo, dstrepo)
75ad8af9c95e upgrade: allow upgrade to repository using sidedata
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43117
diff changeset
256
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
257 # Migrating filelogs
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
258 ui.status(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
259 _(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
260 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
261 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
262 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
263 % (
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
264 fcount,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
265 frevcount,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
266 util.bytecount(fsrcsize),
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
267 util.bytecount(frawsize),
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
268 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
269 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
270 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
271 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
272 newrl = _perform_clone(
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
273 ui,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
274 dstrepo,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
275 tr,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
276 oldrl,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
277 unencoded,
46217
02df91e895bd engine: pass upgrade operation inside `_perform_clone()`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46216
diff changeset
278 upgrade_op,
46193
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
279 sidedatacompanion,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
280 oncopiedrevision,
85f7cf314b39 engine: refactor actual cloning code into separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46191
diff changeset
281 )
39870
b399ff55ee6d upgrade: use storageinfo() for obtaining storage metadata
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39859
diff changeset
282 info = newrl.storageinfo(storedsize=True)
46214
5dfa837d933e engine: refactor how total dstsize is calculated
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
283 fdstsize += info[b'storedsize'] or 0
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
284 ui.status(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
285 _(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
286 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
287 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
288 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
289 % (frevcount, fcount, util.bytecount(fdstsize - fsrcsize))
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
290 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
291
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
292 # Migrating manifests
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
293 ui.status(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
294 _(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
295 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
296 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
297 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
298 % (
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
299 mcount,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
300 mrevcount,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
301 util.bytecount(msrcsize),
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
302 util.bytecount(mrawsize),
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
303 )
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 if progress:
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
306 progress.complete()
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
307 progress = srcrepo.ui.makeprogress(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
308 _(b'manifest revisions'), total=mrevcount
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
309 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
310 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
311 newrl = _perform_clone(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
312 ui,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
313 dstrepo,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
314 tr,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
315 oldrl,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
316 unencoded,
46217
02df91e895bd engine: pass upgrade operation inside `_perform_clone()`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46216
diff changeset
317 upgrade_op,
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
318 sidedatacompanion,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
319 oncopiedrevision,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
320 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
321 info = newrl.storageinfo(storedsize=True)
46214
5dfa837d933e engine: refactor how total dstsize is calculated
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
322 mdstsize += info[b'storedsize'] or 0
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
323 ui.status(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
324 _(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
325 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
326 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
327 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
328 % (mrevcount, mcount, util.bytecount(mdstsize - msrcsize))
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
329 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
330
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
331 # Migrating changelog
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
332 ui.status(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
333 _(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
334 b'migrating changelog containing %d revisions '
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
335 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
336 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
337 % (
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
338 crevcount,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
339 util.bytecount(csrcsize),
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
340 util.bytecount(crawsize),
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
341 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
342 )
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
343 if progress:
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
344 progress.complete()
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
345 progress = srcrepo.ui.makeprogress(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
346 _(b'changelog revisions'), total=crevcount
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 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
349 newrl = _perform_clone(
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
350 ui,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
351 dstrepo,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
352 tr,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
353 oldrl,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
354 unencoded,
46217
02df91e895bd engine: pass upgrade operation inside `_perform_clone()`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46216
diff changeset
355 upgrade_op,
46194
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
356 sidedatacompanion,
4d1cec4e5e1f engine: unwrap a hard to understand for loop
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46193
diff changeset
357 oncopiedrevision,
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 info = newrl.storageinfo(storedsize=True)
46214
5dfa837d933e engine: refactor how total dstsize is calculated
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
360 cdstsize += info[b'storedsize'] or 0
38399
185588cb0c4b upgrade: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents: 38398
diff changeset
361 progress.complete()
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
362 ui.status(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
363 _(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
364 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
365 b'%s\n'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
366 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
367 % (crevcount, util.bytecount(cdstsize - csrcsize))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
368 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
369
46214
5dfa837d933e engine: refactor how total dstsize is calculated
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46210
diff changeset
370 dstsize = fdstsize + mdstsize + cdstsize
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
371 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
372 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
373 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
374 b'size: %s\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
375 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
376 % (revcount, util.bytecount(dstsize - srcsize))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
377 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
378
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
379
46229
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
380 def _files_to_copy_post_revlog_clone(srcrepo):
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
381 """yields files which should be copied to destination after revlogs
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
382 are cloned"""
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
383 for path, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
384 # don't copy revlogs as they are already cloned
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
385 if path.endswith((b'.i', b'.d', b'.n', b'.nd')):
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
386 continue
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
387 # Skip transaction related files.
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
388 if path.startswith(b'undo'):
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
389 continue
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
390 # Only copy regular files.
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
391 if kind != stat.S_IFREG:
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
392 continue
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
393 # Skip other skipped files.
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
394 if path in (b'lock', b'fncache'):
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
395 continue
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
396 # TODO: should we skip cache too?
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
397
46229
52abb1af2995 engine: prevent a function call for each store file
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46222
diff changeset
398 yield path
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
399
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
400
46220
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
401 def _replacestores(currentrepo, upgradedrepo, backupvfs, upgrade_op):
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
402 """Replace the stores after current repository is upgraded
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
403
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
404 Creates a backup of current repository store at backup path
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
405 Replaces upgraded store files in current repo from upgraded one
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
406
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
407 Arguments:
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
408 currentrepo: repo object of current repository
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
409 upgradedrepo: repo object of the upgraded data
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
410 backupvfs: vfs object for the backup path
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
411 upgrade_op: upgrade operation object
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
412 to be used to decide what all is upgraded
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
413 """
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
414 # TODO: don't blindly rename everything in store
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
415 # There can be upgrades where store is not touched at all
46375
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46252
diff changeset
416 if upgrade_op.backup_store:
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46252
diff changeset
417 util.rename(currentrepo.spath, backupvfs.join(b'store'))
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46252
diff changeset
418 else:
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46252
diff changeset
419 currentrepo.vfs.rmtree(b'store', forcibly=True)
46220
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
420 util.rename(upgradedrepo.spath, currentrepo.spath)
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
421
1ca7865c245d engine: refactor code to replace stores in separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46219
diff changeset
422
46219
481d9aed669c engine: make hook point for extension a public function
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46218
diff changeset
423 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
424 """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
425
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
426 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
427 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
428 """
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
429
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
430
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
431 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
432 """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
433
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
434 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
435 repository and a temporary destination 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 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
438 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
439 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
440 """
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
441 assert srcrepo.currentwlock()
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
442 assert dstrepo.currentwlock()
46375
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46252
diff changeset
443 backuppath = None
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46252
diff changeset
444 backupvfs = None
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
445
44798
e295ba238bd8 upgrade: support the --quiet flag
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44797
diff changeset
446 ui.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
447 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
448 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
449 b'data migration completes)\n'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
450 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
451 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
452
46467
45c3a263d5d1 engine: 'if not, else' -> 'if, else'
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46380
diff changeset
453 if upgrade_op.requirements_only:
45c3a263d5d1 engine: 'if not, else' -> 'if, else'
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46380
diff changeset
454 ui.status(_(b'upgrading repository requirements\n'))
45c3a263d5d1 engine: 'if not, else' -> 'if, else'
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46380
diff changeset
455 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
46472
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
456 # if there is only one action and that is persistent nodemap upgrade
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
457 # directly write the nodemap file and update requirements instead of going
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
458 # through the whole cloning process
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
459 elif (
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
460 len(upgrade_op.upgrade_actions) == 1
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
461 and b'persistent-nodemap' in upgrade_op._upgrade_actions_names
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
462 and not upgrade_op.removed_actions
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
463 ):
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
464 ui.status(
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
465 _(b'upgrading repository to use persistent nodemap feature\n')
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
466 )
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
467 with srcrepo.transaction(b'upgrade') as tr:
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
468 unfi = srcrepo.unfiltered()
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
469 cl = unfi.changelog
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
470 nodemap.persist_nodemap(tr, cl, force=True)
46525
636853347e14 upgrade: write nodemap for manifests too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46472
diff changeset
471 # we want to directly operate on the underlying revlog to force
636853347e14 upgrade: write nodemap for manifests too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46472
diff changeset
472 # create a nodemap file. This is fine since this is upgrade code
636853347e14 upgrade: write nodemap for manifests too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46472
diff changeset
473 # and it heavily relies on repository being revlog based
636853347e14 upgrade: write nodemap for manifests too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46472
diff changeset
474 # hence accessing private attributes can be justified
636853347e14 upgrade: write nodemap for manifests too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46472
diff changeset
475 nodemap.persist_nodemap(
636853347e14 upgrade: write nodemap for manifests too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46472
diff changeset
476 tr, unfi.manifestlog._rootstore._revlog, force=True
636853347e14 upgrade: write nodemap for manifests too
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46472
diff changeset
477 )
46472
98e39f04d60e upgrade: implement partial upgrade for upgrading persistent-nodemap
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46467
diff changeset
478 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
46526
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
479 elif (
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
480 len(upgrade_op.removed_actions) == 1
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
481 and [
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
482 x
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
483 for x in upgrade_op.removed_actions
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
484 if x.name == b'persistent-nodemap'
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
485 ]
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
486 and not upgrade_op.upgrade_actions
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
487 ):
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
488 ui.status(
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
489 _(b'downgrading repository to not use persistent nodemap feature\n')
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
490 )
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
491 with srcrepo.transaction(b'upgrade') as tr:
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
492 unfi = srcrepo.unfiltered()
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
493 cl = unfi.changelog
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
494 nodemap.delete_nodemap(tr, srcrepo, cl)
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
495 # check comment 20 lines above for accessing private attributes
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
496 nodemap.delete_nodemap(
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
497 tr, srcrepo, unfi.manifestlog._rootstore._revlog
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
498 )
67b5fafd3a46 upgrade: speed up when we have only nodemap to downgrade
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46525
diff changeset
499 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
46467
45c3a263d5d1 engine: 'if not, else' -> 'if, else'
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46380
diff changeset
500 else:
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
501 with dstrepo.transaction(b'upgrade') as tr:
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
502 _clonerevlogs(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
503 ui,
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
504 srcrepo,
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
505 dstrepo,
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
506 tr,
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
507 upgrade_op,
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
508 )
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
509
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
510 # Now copy other files in the store directory.
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
511 for p in _files_to_copy_post_revlog_clone(srcrepo):
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
512 srcrepo.ui.status(_(b'copying %s\n') % p)
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
513 src = srcrepo.store.rawvfs.join(p)
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
514 dst = dstrepo.store.rawvfs.join(p)
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
515 util.copyfile(src, dst, copystat=True)
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
516
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
517 finishdatamigration(ui, srcrepo, dstrepo, requirements)
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
518
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
519 ui.status(_(b'data fully upgraded in a temporary repository\n'))
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
520
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
521 if upgrade_op.backup_store:
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
522 backuppath = pycompat.mkdtemp(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
523 prefix=b'upgradebackup.', dir=srcrepo.path
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
524 )
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
525 backupvfs = vfsmod.vfs(backuppath)
30780
2603d04889e1 repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30779
diff changeset
526
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
527 # Make a backup of requires file first, as it is the first to be modified.
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
528 util.copyfile(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
529 srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires')
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
530 )
30779
38aa1ca97b6a repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30777
diff changeset
531
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
532 # We install an arbitrary requirement that clients must not support
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
533 # as a mechanism to lock out new clients during the data swap. This is
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
534 # better than allowing a client to continue while the repository is in
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
535 # an inconsistent state.
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
536 ui.status(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
537 _(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
538 b'marking source repository as being upgraded; clients will be '
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
539 b'unable to read from repository\n'
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
540 )
46375
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46252
diff changeset
541 )
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
542 scmutil.writereporequirements(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
543 srcrepo, srcrepo.requirements | {b'upgradeinprogress'}
46375
2e8a844d0ae0 upgrade: don't create store backup if `--no-backup` is passed
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46252
diff changeset
544 )
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
545
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
546 ui.status(_(b'starting in-place swap of repository data\n'))
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
547 if upgrade_op.backup_store:
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
548 ui.status(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
549 _(b'replaced files will be backed up at %s\n') % backuppath
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
550 )
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
551
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
552 # Now swap in the new store directory. Doing it as a rename should make
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
553 # the operation nearly instantaneous and atomic (at least in well-behaved
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
554 # environments).
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
555 ui.status(_(b'replacing store...\n'))
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
556 tstart = util.timer()
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
557 _replacestores(srcrepo, dstrepo, backupvfs, upgrade_op)
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
558 elapsed = util.timer() - tstart
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
559 ui.status(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
560 _(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
561 b'store replacement complete; repository was inconsistent for '
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
562 b'%0.1fs\n'
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
563 )
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
564 % elapsed
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
565 )
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
566
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
567 # We first write the requirements file. Any new requirements will lock
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
568 # out legacy clients.
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
569 ui.status(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
570 _(
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
571 b'finalizing requirements file and making repository readable '
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
572 b'again\n'
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
573 )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43031
diff changeset
574 )
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
575 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
576
46379
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
577 if upgrade_op.backup_store:
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
578 # The lock file from the old store won't be removed because nothing has a
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
579 # reference to its new location. So clean it up manually. Alternatively, we
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
580 # could update srcrepo.svfs and other variables to point to the new
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
581 # location. This is simpler.
ee9002b99595 engine: add `if True` to prepare for next patch
Pulkit Goyal <7895pulkit@gmail.com>
parents: 46375
diff changeset
582 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
583
30777
7de7afd8bdd9 repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30776
diff changeset
584 return backuppath