changeset 31903:fa1088de2119

upgrade: use 'improvement' object for action too This simplify multiple pieces of code. For now we restrict this upgrade to the top level function to keep this patch simple.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 10 Apr 2017 23:11:45 +0200
parents 6557f0d4ab8e
children 3c77f03f16b3
files mercurial/upgrade.py
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/upgrade.py	Mon Apr 10 23:10:03 2017 +0200
+++ b/mercurial/upgrade.py	Mon Apr 10 23:11:45 2017 +0200
@@ -292,7 +292,7 @@
         if name in knownreqs and name not in destreqs:
             continue
 
-        newactions.append(name)
+        newactions.append(d)
 
     # FUTURE consider adding some optimizations here for certain transitions.
     # e.g. adding generaldelta could schedule parent redeltas.
@@ -639,11 +639,10 @@
                                  'optimizations'))
 
     deficiencies = finddeficiencies(repo)
-    improvements = deficiencies + optimizations
     actions = determineactions(repo, deficiencies, repo.requirements, newreqs)
-    actions.extend(o.name for o in sorted(optimizations)
+    actions.extend(o for o in sorted(optimizations)
                    # determineactions could have added optimisation
-                   if o.name not in actions)
+                   if o not in actions)
 
     def printrequirements():
         ui.write(_('requirements\n'))
@@ -661,11 +660,8 @@
         ui.write('\n')
 
     def printupgradeactions():
-        for action in actions:
-            for i in improvements:
-                if i.name == action:
-                    ui.write('%s\n   %s\n\n' %
-                             (i.name, i.upgrademessage))
+        for a in actions:
+            ui.write('%s\n   %s\n\n' % (a.name, a.upgrademessage))
 
     if not run:
         fromdefault = []
@@ -705,8 +701,8 @@
         printrequirements()
         printupgradeactions()
 
-        unusedoptimize = [i for i in alloptimizations
-                          if i.name not in actions]
+        unusedoptimize = [i for i in alloptimizations if i not in actions]
+
         if unusedoptimize:
             ui.write(_('additional optimizations are available by specifying '
                      '"--optimize <name>":\n\n'))
@@ -719,6 +715,8 @@
     printrequirements()
     printupgradeactions()
 
+    upgradeactions = [a.name for a in actions]
+
     ui.write(_('beginning upgrade...\n'))
     with repo.wlock():
         with repo.lock():
@@ -740,7 +738,7 @@
                 with dstrepo.wlock():
                     with dstrepo.lock():
                         backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,
-                                                  actions)
+                                                  upgradeactions)
 
             finally:
                 ui.write(_('removing temporary repository %s\n') % tmppath)