Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/upgrade_utils/engine.py @ 46533:98e39f04d60e
upgrade: implement partial upgrade for upgrading persistent-nodemap
Upgrading repositories to use persistent nodemap should be fast and easy as it
requires only two things:
1) Updating the requirements
2) Writing a persistent-nodemap on disk
For both of the steps above, we don't need to edit existing revlogs.
This patch makes upgrade only do the above mentioned two steps if we are
only upgarding to use persistent-nodemap feature.
Since `nodemap.persist_nodemap()` assumes that there exists a nodemap file for
the given revlog if we are trying to call it, this patch adds `force` argument
to create a file if does not exist which is true in our upgrade case.
The test changes demonstrate that we no longer write nodemap files for manifest
after upgrade which I think is desirable.
Differential Revision: https://phab.mercurial-scm.org/D9936
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 01 Feb 2021 00:02:00 +0530 |
parents | 45c3a263d5d1 |
children | 636853347e14 |
comparison
equal
deleted
inserted
replaced
46532:bfaacfa8ebfc | 46533:98e39f04d60e |
---|---|
22 revlog, | 22 revlog, |
23 scmutil, | 23 scmutil, |
24 util, | 24 util, |
25 vfs as vfsmod, | 25 vfs as vfsmod, |
26 ) | 26 ) |
27 from ..revlogutils import nodemap | |
27 | 28 |
28 | 29 |
29 def _revlogfrompath(repo, path): | 30 def _revlogfrompath(repo, path): |
30 """Obtain a revlog from a repo path. | 31 """Obtain a revlog from a repo path. |
31 | 32 |
450 ) | 451 ) |
451 | 452 |
452 if upgrade_op.requirements_only: | 453 if upgrade_op.requirements_only: |
453 ui.status(_(b'upgrading repository requirements\n')) | 454 ui.status(_(b'upgrading repository requirements\n')) |
454 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) | 455 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) |
456 # if there is only one action and that is persistent nodemap upgrade | |
457 # directly write the nodemap file and update requirements instead of going | |
458 # through the whole cloning process | |
459 elif ( | |
460 len(upgrade_op.upgrade_actions) == 1 | |
461 and b'persistent-nodemap' in upgrade_op._upgrade_actions_names | |
462 and not upgrade_op.removed_actions | |
463 ): | |
464 ui.status( | |
465 _(b'upgrading repository to use persistent nodemap feature\n') | |
466 ) | |
467 with srcrepo.transaction(b'upgrade') as tr: | |
468 unfi = srcrepo.unfiltered() | |
469 cl = unfi.changelog | |
470 nodemap.persist_nodemap(tr, cl, force=True) | |
471 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) | |
455 else: | 472 else: |
456 with dstrepo.transaction(b'upgrade') as tr: | 473 with dstrepo.transaction(b'upgrade') as tr: |
457 _clonerevlogs( | 474 _clonerevlogs( |
458 ui, | 475 ui, |
459 srcrepo, | 476 srcrepo, |