Show More
@@ -118,6 +118,7 b' def upgraderepo(' | |||
|
118 | 118 | up_actions, |
|
119 | 119 | removed_actions, |
|
120 | 120 | revlogs, |
|
121 | backup, | |
|
121 | 122 | ) |
|
122 | 123 | |
|
123 | 124 | if not run: |
@@ -215,12 +216,6 b' def upgraderepo(' | |||
|
215 | 216 | backuppath = upgrade_engine.upgrade( |
|
216 | 217 | ui, repo, dstrepo, upgrade_op |
|
217 | 218 | ) |
|
218 | if not backup: | |
|
219 | ui.status( | |
|
220 | _(b'removing old repository content %s\n') % backuppath | |
|
221 | ) | |
|
222 | repo.vfs.rmtree(backuppath, forcibly=True) | |
|
223 | backuppath = None | |
|
224 | 219 | |
|
225 | 220 | finally: |
|
226 | 221 | ui.status(_(b'removing temporary repository %s\n') % tmppath) |
@@ -626,6 +626,7 b' class UpgradeOperation(object):' | |||
|
626 | 626 | upgrade_actions, |
|
627 | 627 | removed_actions, |
|
628 | 628 | revlogs_to_process, |
|
629 | backup_store, | |
|
629 | 630 | ): |
|
630 | 631 | self.ui = ui |
|
631 | 632 | self.new_requirements = new_requirements |
@@ -670,6 +671,9 b' class UpgradeOperation(object):' | |||
|
670 | 671 | b're-delta-multibase' in self._upgrade_actions_names |
|
671 | 672 | ) |
|
672 | 673 | |
|
674 | # should this operation create a backup of the store | |
|
675 | self.backup_store = backup_store | |
|
676 | ||
|
673 | 677 | def _write_labeled(self, l, label): |
|
674 | 678 | """ |
|
675 | 679 | Utility function to aid writing of a list under one label |
@@ -412,7 +412,10 b' def _replacestores(currentrepo, upgraded' | |||
|
412 | 412 | """ |
|
413 | 413 | # TODO: don't blindly rename everything in store |
|
414 | 414 | # There can be upgrades where store is not touched at all |
|
415 | util.rename(currentrepo.spath, backupvfs.join(b'store')) | |
|
415 | if upgrade_op.backup_store: | |
|
416 | util.rename(currentrepo.spath, backupvfs.join(b'store')) | |
|
417 | else: | |
|
418 | currentrepo.vfs.rmtree(b'store', forcibly=True) | |
|
416 | 419 | util.rename(upgradedrepo.spath, currentrepo.spath) |
|
417 | 420 | |
|
418 | 421 | |
@@ -436,6 +439,8 b' def upgrade(ui, srcrepo, dstrepo, upgrad' | |||
|
436 | 439 | """ |
|
437 | 440 | assert srcrepo.currentwlock() |
|
438 | 441 | assert dstrepo.currentwlock() |
|
442 | backuppath = None | |
|
443 | backupvfs = None | |
|
439 | 444 | |
|
440 | 445 | ui.status( |
|
441 | 446 | _( |
@@ -464,11 +469,16 b' def upgrade(ui, srcrepo, dstrepo, upgrad' | |||
|
464 | 469 | |
|
465 | 470 | ui.status(_(b'data fully upgraded in a temporary repository\n')) |
|
466 | 471 | |
|
467 | backuppath = pycompat.mkdtemp(prefix=b'upgradebackup.', dir=srcrepo.path) | |
|
468 | backupvfs = vfsmod.vfs(backuppath) | |
|
472 | if upgrade_op.backup_store: | |
|
473 | backuppath = pycompat.mkdtemp( | |
|
474 | prefix=b'upgradebackup.', dir=srcrepo.path | |
|
475 | ) | |
|
476 | backupvfs = vfsmod.vfs(backuppath) | |
|
469 | 477 | |
|
470 | # Make a backup of requires file first, as it is the first to be modified. | |
|
471 | util.copyfile(srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires')) | |
|
478 | # Make a backup of requires file first, as it is the first to be modified. | |
|
479 | util.copyfile( | |
|
480 | srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires') | |
|
481 | ) | |
|
472 | 482 | |
|
473 | 483 | # We install an arbitrary requirement that clients must not support |
|
474 | 484 | # as a mechanism to lock out new clients during the data swap. This is |
@@ -485,7 +495,8 b' def upgrade(ui, srcrepo, dstrepo, upgrad' | |||
|
485 | 495 | ) |
|
486 | 496 | |
|
487 | 497 | ui.status(_(b'starting in-place swap of repository data\n')) |
|
488 | ui.status(_(b'replaced files will be backed up at %s\n') % backuppath) | |
|
498 | if upgrade_op.backup_store: | |
|
499 | ui.status(_(b'replaced files will be backed up at %s\n') % backuppath) | |
|
489 | 500 | |
|
490 | 501 | # Now swap in the new store directory. Doing it as a rename should make |
|
491 | 502 | # the operation nearly instantaneous and atomic (at least in well-behaved |
@@ -512,10 +523,11 b' def upgrade(ui, srcrepo, dstrepo, upgrad' | |||
|
512 | 523 | ) |
|
513 | 524 | scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) |
|
514 | 525 | |
|
515 | # The lock file from the old store won't be removed because nothing has a | |
|
516 | # reference to its new location. So clean it up manually. Alternatively, we | |
|
517 | # could update srcrepo.svfs and other variables to point to the new | |
|
518 | # location. This is simpler. | |
|
519 | backupvfs.unlink(b'store/lock') | |
|
526 | if upgrade_op.backup_store: | |
|
527 | # The lock file from the old store won't be removed because nothing has a | |
|
528 | # reference to its new location. So clean it up manually. Alternatively, we | |
|
529 | # could update srcrepo.svfs and other variables to point to the new | |
|
530 | # location. This is simpler. | |
|
531 | backupvfs.unlink(b'store/lock') | |
|
520 | 532 | |
|
521 | 533 | return backuppath |
@@ -632,11 +632,9 b' unless --no-backup is passed' | |||
|
632 | 632 | data fully upgraded in a temporary repository |
|
633 | 633 | marking source repository as being upgraded; clients will be unable to read from repository |
|
634 | 634 | starting in-place swap of repository data |
|
635 | replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
636 | 635 | replacing store... |
|
637 | 636 | store replacement complete; repository was inconsistent for * (glob) |
|
638 | 637 | finalizing requirements file and making repository readable again |
|
639 | removing old repository content $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
640 | 638 | removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob) |
|
641 | 639 | $ ls -1 .hg/ | grep upgradebackup |
|
642 | 640 | [1] |
@@ -679,11 +677,9 b' We can restrict optimization to some rev' | |||
|
679 | 677 | data fully upgraded in a temporary repository |
|
680 | 678 | marking source repository as being upgraded; clients will be unable to read from repository |
|
681 | 679 | starting in-place swap of repository data |
|
682 | replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
683 | 680 | replacing store... |
|
684 | 681 | store replacement complete; repository was inconsistent for *s (glob) |
|
685 | 682 | finalizing requirements file and making repository readable again |
|
686 | removing old repository content $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
687 | 683 | removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob) |
|
688 | 684 | |
|
689 | 685 | Check that the repo still works fine |
@@ -759,11 +755,9 b' Check we can select negatively' | |||
|
759 | 755 | data fully upgraded in a temporary repository |
|
760 | 756 | marking source repository as being upgraded; clients will be unable to read from repository |
|
761 | 757 | starting in-place swap of repository data |
|
762 | replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
763 | 758 | replacing store... |
|
764 | 759 | store replacement complete; repository was inconsistent for *s (glob) |
|
765 | 760 | finalizing requirements file and making repository readable again |
|
766 | removing old repository content $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
767 | 761 | removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob) |
|
768 | 762 | $ hg verify |
|
769 | 763 | checking changesets |
@@ -810,11 +804,9 b' Check that we can select changelog only' | |||
|
810 | 804 | data fully upgraded in a temporary repository |
|
811 | 805 | marking source repository as being upgraded; clients will be unable to read from repository |
|
812 | 806 | starting in-place swap of repository data |
|
813 | replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
814 | 807 | replacing store... |
|
815 | 808 | store replacement complete; repository was inconsistent for *s (glob) |
|
816 | 809 | finalizing requirements file and making repository readable again |
|
817 | removing old repository content $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
818 | 810 | removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob) |
|
819 | 811 | $ hg verify |
|
820 | 812 | checking changesets |
@@ -861,11 +853,9 b' Check that we can select filelog only' | |||
|
861 | 853 | data fully upgraded in a temporary repository |
|
862 | 854 | marking source repository as being upgraded; clients will be unable to read from repository |
|
863 | 855 | starting in-place swap of repository data |
|
864 | replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
865 | 856 | replacing store... |
|
866 | 857 | store replacement complete; repository was inconsistent for *s (glob) |
|
867 | 858 | finalizing requirements file and making repository readable again |
|
868 | removing old repository content $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
869 | 859 | removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob) |
|
870 | 860 | $ hg verify |
|
871 | 861 | checking changesets |
@@ -919,11 +909,9 b" Check you can't skip revlog clone during" | |||
|
919 | 909 | data fully upgraded in a temporary repository |
|
920 | 910 | marking source repository as being upgraded; clients will be unable to read from repository |
|
921 | 911 | starting in-place swap of repository data |
|
922 | replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
923 | 912 | replacing store... |
|
924 | 913 | store replacement complete; repository was inconsistent for *s (glob) |
|
925 | 914 | finalizing requirements file and making repository readable again |
|
926 | removing old repository content $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
927 | 915 | removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob) |
|
928 | 916 | $ hg verify |
|
929 | 917 | checking changesets |
@@ -978,11 +966,9 b" Check you can't skip revlog clone during" | |||
|
978 | 966 | data fully upgraded in a temporary repository |
|
979 | 967 | marking source repository as being upgraded; clients will be unable to read from repository |
|
980 | 968 | starting in-place swap of repository data |
|
981 | replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
982 | 969 | replacing store... |
|
983 | 970 | store replacement complete; repository was inconsistent for *s (glob) |
|
984 | 971 | finalizing requirements file and making repository readable again |
|
985 | removing old repository content $TESTTMP/upgradegd/.hg/upgradebackup.* (glob) | |
|
986 | 972 | removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob) |
|
987 | 973 | $ hg verify |
|
988 | 974 | checking changesets |
General Comments 0
You need to be logged in to leave comments.
Login now