upgrade: simplify optimisations validation
Since we fetch optimizations distinctly from the deficiencies, we can simplify
some code.
--- 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)