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