##// END OF EJS Templates
upgrade: take advantage of the new information returned by `store.walk`...
marmoute -
r47658:cf49e54e default
parent child Browse files
Show More
@@ -21,30 +21,34 b' from .. import ('
21 requirements,
21 requirements,
22 revlog,
22 revlog,
23 scmutil,
23 scmutil,
24 store,
24 util,
25 util,
25 vfs as vfsmod,
26 vfs as vfsmod,
26 )
27 )
27 from ..revlogutils import nodemap
28 from ..revlogutils import nodemap
28
29
29
30
30 def _revlogfrompath(repo, path):
31 def _revlogfrompath(repo, rl_type, path):
31 """Obtain a revlog from a repo path.
32 """Obtain a revlog from a repo path.
32
33
33 An instance of the appropriate class is returned.
34 An instance of the appropriate class is returned.
34 """
35 """
35 if path == b'00changelog.i':
36 if rl_type & store.FILEFLAGS_CHANGELOG:
36 return changelog.changelog(repo.svfs)
37 return changelog.changelog(repo.svfs)
37 elif path.endswith(b'00manifest.i'):
38 elif rl_type & store.FILEFLAGS_MANIFESTLOG:
38 mandir = path[: -len(b'00manifest.i')]
39 mandir = b''
40 if b'/' in path:
41 mandir = path.rsplit(b'/', 1)[0]
39 return manifest.manifestrevlog(
42 return manifest.manifestrevlog(
40 repo.nodeconstants, repo.svfs, tree=mandir
43 repo.nodeconstants, repo.svfs, tree=mandir
41 )
44 )
42 else:
45 else:
43 # reverse of "/".join(("data", path + ".i"))
46 # drop the extension and the `data/` prefix
44 return filelog.filelog(repo.svfs, path[5:-2])
47 path = path.rsplit(b'.', 1)[0].split(b'/', 1)[1]
48 return filelog.filelog(repo.svfs, path)
45
49
46
50
47 def _copyrevlog(tr, destrepo, oldrl, unencodedname):
51 def _copyrevlog(tr, destrepo, oldrl, rl_type, unencodedname):
48 """copy all relevant files for `oldrl` into `destrepo` store
52 """copy all relevant files for `oldrl` into `destrepo` store
49
53
50 Files are copied "as is" without any transformation. The copy is performed
54 Files are copied "as is" without any transformation. The copy is performed
@@ -52,7 +56,7 b' def _copyrevlog(tr, destrepo, oldrl, une'
52 content is compatible with format of the destination repository.
56 content is compatible with format of the destination repository.
53 """
57 """
54 oldrl = getattr(oldrl, '_revlog', oldrl)
58 oldrl = getattr(oldrl, '_revlog', oldrl)
55 newrl = _revlogfrompath(destrepo, unencodedname)
59 newrl = _revlogfrompath(destrepo, rl_type, unencodedname)
56 newrl = getattr(newrl, '_revlog', newrl)
60 newrl = getattr(newrl, '_revlog', newrl)
57
61
58 oldvfs = oldrl.opener
62 oldvfs = oldrl.opener
@@ -70,10 +74,7 b' def _copyrevlog(tr, destrepo, oldrl, une'
70 if copydata:
74 if copydata:
71 util.copyfile(olddata, newdata)
75 util.copyfile(olddata, newdata)
72
76
73 if not (
77 if rl_type & store.FILEFLAGS_FILELOG:
74 unencodedname.endswith(b'00changelog.i')
75 or unencodedname.endswith(b'00manifest.i')
76 ):
77 destrepo.svfs.fncache.add(unencodedname)
78 destrepo.svfs.fncache.add(unencodedname)
78 if copydata:
79 if copydata:
79 destrepo.svfs.fncache.add(unencodedname[:-2] + b'.d')
80 destrepo.svfs.fncache.add(unencodedname[:-2] + b'.d')
@@ -107,17 +108,18 b' def getsidedatacompanion(srcrepo, dstrep'
107 return sidedatacompanion
108 return sidedatacompanion
108
109
109
110
110 def matchrevlog(revlogfilter, entry):
111 def matchrevlog(revlogfilter, rl_type):
111 """check if a revlog is selected for cloning.
112 """check if a revlog is selected for cloning.
112
113
113 In other words, are there any updates which need to be done on revlog
114 In other words, are there any updates which need to be done on revlog
114 or it can be blindly copied.
115 or it can be blindly copied.
115
116
116 The store entry is checked against the passed filter"""
117 The store entry is checked against the passed filter"""
117 if entry.endswith(b'00changelog.i'):
118 if rl_type & store.FILEFLAGS_CHANGELOG:
118 return UPGRADE_CHANGELOG in revlogfilter
119 return UPGRADE_CHANGELOG in revlogfilter
119 elif entry.endswith(b'00manifest.i'):
120 elif rl_type & store.FILEFLAGS_MANIFESTLOG:
120 return UPGRADE_MANIFEST in revlogfilter
121 return UPGRADE_MANIFEST in revlogfilter
122 assert rl_type & store.FILEFLAGS_FILELOG
121 return UPGRADE_FILELOGS in revlogfilter
123 return UPGRADE_FILELOGS in revlogfilter
122
124
123
125
@@ -126,6 +128,7 b' def _perform_clone('
126 dstrepo,
128 dstrepo,
127 tr,
129 tr,
128 old_revlog,
130 old_revlog,
131 rl_type,
129 unencoded,
132 unencoded,
130 upgrade_op,
133 upgrade_op,
131 sidedatacompanion,
134 sidedatacompanion,
@@ -133,11 +136,11 b' def _perform_clone('
133 ):
136 ):
134 """ returns the new revlog object created"""
137 """ returns the new revlog object created"""
135 newrl = None
138 newrl = None
136 if matchrevlog(upgrade_op.revlogs_to_process, unencoded):
139 if matchrevlog(upgrade_op.revlogs_to_process, rl_type):
137 ui.note(
140 ui.note(
138 _(b'cloning %d revisions from %s\n') % (len(old_revlog), unencoded)
141 _(b'cloning %d revisions from %s\n') % (len(old_revlog), unencoded)
139 )
142 )
140 newrl = _revlogfrompath(dstrepo, unencoded)
143 newrl = _revlogfrompath(dstrepo, rl_type, unencoded)
141 old_revlog.clone(
144 old_revlog.clone(
142 tr,
145 tr,
143 newrl,
146 newrl,
@@ -149,9 +152,9 b' def _perform_clone('
149 else:
152 else:
150 msg = _(b'blindly copying %s containing %i revisions\n')
153 msg = _(b'blindly copying %s containing %i revisions\n')
151 ui.note(msg % (unencoded, len(old_revlog)))
154 ui.note(msg % (unencoded, len(old_revlog)))
152 _copyrevlog(tr, dstrepo, old_revlog, unencoded)
155 _copyrevlog(tr, dstrepo, old_revlog, rl_type, unencoded)
153
156
154 newrl = _revlogfrompath(dstrepo, unencoded)
157 newrl = _revlogfrompath(dstrepo, rl_type, unencoded)
155 return newrl
158 return newrl
156
159
157
160
@@ -192,11 +195,11 b' def _clonerevlogs('
192
195
193 # Perform a pass to collect metadata. This validates we can open all
196 # Perform a pass to collect metadata. This validates we can open all
194 # source files and allows a unified progress bar to be displayed.
197 # source files and allows a unified progress bar to be displayed.
195 for revlog_type, unencoded, encoded, size in alldatafiles:
198 for rl_type, unencoded, encoded, size in alldatafiles:
196 if not unencoded.endswith(b'.i'):
199 if not rl_type & store.FILEFLAGS_REVLOG_MAIN:
197 continue
200 continue
198
201
199 rl = _revlogfrompath(srcrepo, unencoded)
202 rl = _revlogfrompath(srcrepo, rl_type, unencoded)
200
203
201 info = rl.storageinfo(
204 info = rl.storageinfo(
202 exclusivefiles=True,
205 exclusivefiles=True,
@@ -213,19 +216,19 b' def _clonerevlogs('
213 srcrawsize += rawsize
216 srcrawsize += rawsize
214
217
215 # This is for the separate progress bars.
218 # This is for the separate progress bars.
216 if isinstance(rl, changelog.changelog):
219 if rl_type & store.FILEFLAGS_CHANGELOG:
217 changelogs[unencoded] = rl
220 changelogs[unencoded] = (rl_type, rl)
218 crevcount += len(rl)
221 crevcount += len(rl)
219 csrcsize += datasize
222 csrcsize += datasize
220 crawsize += rawsize
223 crawsize += rawsize
221 elif isinstance(rl, manifest.manifestrevlog):
224 elif rl_type & store.FILEFLAGS_MANIFESTLOG:
222 manifests[unencoded] = rl
225 manifests[unencoded] = (rl_type, rl)
223 mcount += 1
226 mcount += 1
224 mrevcount += len(rl)
227 mrevcount += len(rl)
225 msrcsize += datasize
228 msrcsize += datasize
226 mrawsize += rawsize
229 mrawsize += rawsize
227 elif isinstance(rl, filelog.filelog):
230 elif rl_type & store.FILEFLAGS_FILELOG:
228 filelogs[unencoded] = rl
231 filelogs[unencoded] = (rl_type, rl)
229 fcount += 1
232 fcount += 1
230 frevcount += len(rl)
233 frevcount += len(rl)
231 fsrcsize += datasize
234 fsrcsize += datasize
@@ -270,12 +273,13 b' def _clonerevlogs('
270 )
273 )
271 )
274 )
272 progress = srcrepo.ui.makeprogress(_(b'file revisions'), total=frevcount)
275 progress = srcrepo.ui.makeprogress(_(b'file revisions'), total=frevcount)
273 for unencoded, oldrl in sorted(filelogs.items()):
276 for unencoded, (rl_type, oldrl) in sorted(filelogs.items()):
274 newrl = _perform_clone(
277 newrl = _perform_clone(
275 ui,
278 ui,
276 dstrepo,
279 dstrepo,
277 tr,
280 tr,
278 oldrl,
281 oldrl,
282 rl_type,
279 unencoded,
283 unencoded,
280 upgrade_op,
284 upgrade_op,
281 sidedatacompanion,
285 sidedatacompanion,
@@ -309,12 +313,13 b' def _clonerevlogs('
309 progress = srcrepo.ui.makeprogress(
313 progress = srcrepo.ui.makeprogress(
310 _(b'manifest revisions'), total=mrevcount
314 _(b'manifest revisions'), total=mrevcount
311 )
315 )
312 for unencoded, oldrl in sorted(manifests.items()):
316 for unencoded, (rl_type, oldrl) in sorted(manifests.items()):
313 newrl = _perform_clone(
317 newrl = _perform_clone(
314 ui,
318 ui,
315 dstrepo,
319 dstrepo,
316 tr,
320 tr,
317 oldrl,
321 oldrl,
322 rl_type,
318 unencoded,
323 unencoded,
319 upgrade_op,
324 upgrade_op,
320 sidedatacompanion,
325 sidedatacompanion,
@@ -347,12 +352,13 b' def _clonerevlogs('
347 progress = srcrepo.ui.makeprogress(
352 progress = srcrepo.ui.makeprogress(
348 _(b'changelog revisions'), total=crevcount
353 _(b'changelog revisions'), total=crevcount
349 )
354 )
350 for unencoded, oldrl in sorted(changelogs.items()):
355 for unencoded, (rl_type, oldrl) in sorted(changelogs.items()):
351 newrl = _perform_clone(
356 newrl = _perform_clone(
352 ui,
357 ui,
353 dstrepo,
358 dstrepo,
354 tr,
359 tr,
355 oldrl,
360 oldrl,
361 rl_type,
356 unencoded,
362 unencoded,
357 upgrade_op,
363 upgrade_op,
358 sidedatacompanion,
364 sidedatacompanion,
General Comments 0
You need to be logged in to leave comments. Login now