upgrade: simplify optimisations validation
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 10 Apr 2017 21:01:06 +0200
changeset 31897 d0067250542d
parent 31896 127b41e975fd
child 31898 9db45228da52
upgrade: simplify optimisations validation Since we fetch optimizations distinctly from the deficiencies, we can simplify some code.
mercurial/upgrade.py
--- a/mercurial/upgrade.py	Mon Apr 10 21:00:52 2017 +0200
+++ b/mercurial/upgrade.py	Mon Apr 10 21:01:06 2017 +0200
@@ -621,21 +621,18 @@
                           _(', ').join(sorted(unsupportedreqs)))
 
     # Find and validate all improvements that can be made.
-    improvements = finddeficiencies(repo) + findoptimizations(repo)
-    for i in improvements:
-        if i.type not in (deficiency, optimisation):
-            raise error.Abort(_('unexpected improvement type %s for %s') % (
-                i.type, i.name))
+    optimizations = findoptimizations(repo)
 
     # Validate arguments.
-    unknownoptimize = optimize - set(i.name for i in improvements
-                                     if i.type == optimisation)
+    unknownoptimize = optimize - set(i.name for i in optimizations)
     if unknownoptimize:
         raise error.Abort(_('unknown optimization action requested: %s') %
                           ', '.join(sorted(unknownoptimize)),
                           hint=_('run without arguments to see valid '
                                  'optimizations'))
 
+    deficiencies = finddeficiencies(repo)
+    improvements = deficiencies + optimizations
     actions = determineactions(repo, improvements, repo.requirements,
                                       newreqs, optimize)