Patchwork [05,of,12] upgrade: simplify optimisations validation

login
register
mail settings
Submitter Pierre-Yves David
Date April 11, 2017, 10:47 p.m.
Message ID <939b9fb52a24570047a2.1491950865@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20112/
State Accepted
Headers show

Comments

Pierre-Yves David - April 11, 2017, 10:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1491850866 -7200
#      Mon Apr 10 21:01:06 2017 +0200
# Node ID 939b9fb52a24570047a29398c24c1cfe02811cfb
# Parent  aeda2237481d03670c215fc0ef215e26f4415bcb
# EXP-Topic upgraderepo
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 939b9fb52a24
upgrade: simplify optimisations validation

Since we fetch optimizations distinctly from the deficiencies, we can simplify
some code.

Patch

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -621,21 +621,18 @@  def upgraderepo(ui, repo, run=False, opt
                           _(', ').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)