Mercurial > hg
comparison mercurial/upgrade.py @ 41089:a59a74721c76
debugupgraderepo: add a --no-backup mode
The process has been around for a while and is pretty safe now. Having an
automated way to clean up the old data is useful when running many different
conversion to compare delta algorithm.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 21 Dec 2018 13:17:58 +0100 |
parents | 5608b5a6c323 |
children | d7e751ec679e |
comparison
equal
deleted
inserted
replaced
41088:5608b5a6c323 | 41089:a59a74721c76 |
---|---|
740 # location. This is simpler. | 740 # location. This is simpler. |
741 backupvfs.unlink('store/lock') | 741 backupvfs.unlink('store/lock') |
742 | 742 |
743 return backuppath | 743 return backuppath |
744 | 744 |
745 def upgraderepo(ui, repo, run=False, optimize=None): | 745 def upgraderepo(ui, repo, run=False, optimize=None, backup=True): |
746 """Upgrade a repository in place.""" | 746 """Upgrade a repository in place.""" |
747 if optimize is None: | 747 if optimize is None: |
748 optimize = [] | 748 optimize = [] |
749 optimize = set(legacy_opts_map.get(o, o) for o in optimize) | 749 optimize = set(legacy_opts_map.get(o, o) for o in optimize) |
750 repo = repo.unfiltered() | 750 repo = repo.unfiltered() |
897 dstrepo = hg.repository(repoui, path=tmppath, create=True) | 897 dstrepo = hg.repository(repoui, path=tmppath, create=True) |
898 | 898 |
899 with dstrepo.wlock(), dstrepo.lock(): | 899 with dstrepo.wlock(), dstrepo.lock(): |
900 backuppath = _upgraderepo(ui, repo, dstrepo, newreqs, | 900 backuppath = _upgraderepo(ui, repo, dstrepo, newreqs, |
901 upgradeactions) | 901 upgradeactions) |
902 if not (backup or backuppath is None): | |
903 ui.write(_('removing old repository content%s\n') % backuppath) | |
904 repo.vfs.rmtree(backuppath, forcibly=True) | |
905 backuppath = None | |
902 | 906 |
903 finally: | 907 finally: |
904 ui.write(_('removing temporary repository %s\n') % tmppath) | 908 ui.write(_('removing temporary repository %s\n') % tmppath) |
905 repo.vfs.rmtree(tmppath, forcibly=True) | 909 repo.vfs.rmtree(tmppath, forcibly=True) |
906 | 910 |