diff mercurial/upgrade.py @ 41092: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
line wrap: on
line diff
--- a/mercurial/upgrade.py	Fri Jul 13 03:05:30 2018 +0200
+++ b/mercurial/upgrade.py	Fri Dec 21 13:17:58 2018 +0100
@@ -742,7 +742,7 @@
 
     return backuppath
 
-def upgraderepo(ui, repo, run=False, optimize=None):
+def upgraderepo(ui, repo, run=False, optimize=None, backup=True):
     """Upgrade a repository in place."""
     if optimize is None:
         optimize = []
@@ -899,6 +899,10 @@
             with dstrepo.wlock(), dstrepo.lock():
                 backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,
                                           upgradeactions)
+            if not (backup or backuppath is None):
+                ui.write(_('removing old repository content%s\n') % backuppath)
+                repo.vfs.rmtree(backuppath, forcibly=True)
+                backuppath = None
 
         finally:
             ui.write(_('removing temporary repository %s\n') % tmppath)