Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/upgrade.py @ 46060:c407513a44a3
upgrade: start moving the "to be happening" data in a dedicated object
The upgrade code has a lot of logic to determine which action needs to be
performed depending of various element (sometimes depending from each other). It
would be nice to have a consistent object representing this. That could be
cleanly passed and avoid some logic duplication.
So we create this object as a start.
Differential Revision: https://phab.mercurial-scm.org/D9487
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 01 Dec 2020 22:37:34 +0100 |
parents | 72b7b4bf3e65 |
children | 945b33a7edfd |
comparison
equal
deleted
inserted
replaced
46059:7740d5102760 | 46060:c407513a44a3 |
---|---|
174 ui.write((b'processed revlogs:\n')) | 174 ui.write((b'processed revlogs:\n')) |
175 for r in sorted(revlogs): | 175 for r in sorted(revlogs): |
176 ui.write((b' - %s\n' % r)) | 176 ui.write((b' - %s\n' % r)) |
177 ui.write((b'\n')) | 177 ui.write((b'\n')) |
178 | 178 |
179 upgrade_op = upgrade_actions.UpgradeOperation( | |
180 newreqs, | |
181 [a.name for a in actions], | |
182 revlogs, | |
183 ) | |
184 | |
179 if not run: | 185 if not run: |
180 fromconfig = [] | 186 fromconfig = [] |
181 onlydefault = [] | 187 onlydefault = [] |
182 | 188 |
183 for d in deficiencies: | 189 for d in deficiencies: |
246 ui.write(_(b'upgrade will perform the following actions:\n\n')) | 252 ui.write(_(b'upgrade will perform the following actions:\n\n')) |
247 printrequirements() | 253 printrequirements() |
248 printoptimisations() | 254 printoptimisations() |
249 printupgradeactions() | 255 printupgradeactions() |
250 print_affected_revlogs() | 256 print_affected_revlogs() |
251 | |
252 upgradeactions = [a.name for a in actions] | |
253 | 257 |
254 ui.status(_(b'beginning upgrade...\n')) | 258 ui.status(_(b'beginning upgrade...\n')) |
255 with repo.wlock(), repo.lock(): | 259 with repo.wlock(), repo.lock(): |
256 ui.status(_(b'repository locked and read-only\n')) | 260 ui.status(_(b'repository locked and read-only\n')) |
257 # Our strategy for upgrading the repository is to create a new, | 261 # Our strategy for upgrading the repository is to create a new, |
274 repoui = repo.ui.__class__(repo.ui) | 278 repoui = repo.ui.__class__(repo.ui) |
275 dstrepo = hg.repository(repoui, path=tmppath, create=True) | 279 dstrepo = hg.repository(repoui, path=tmppath, create=True) |
276 | 280 |
277 with dstrepo.wlock(), dstrepo.lock(): | 281 with dstrepo.wlock(), dstrepo.lock(): |
278 backuppath = upgrade_engine.upgrade( | 282 backuppath = upgrade_engine.upgrade( |
279 ui, repo, dstrepo, newreqs, upgradeactions, revlogs=revlogs | 283 ui, repo, dstrepo, upgrade_op |
280 ) | 284 ) |
281 if not (backup or backuppath is None): | 285 if not (backup or backuppath is None): |
282 ui.status( | 286 ui.status( |
283 _(b'removing old repository content%s\n') % backuppath | 287 _(b'removing old repository content%s\n') % backuppath |
284 ) | 288 ) |