Mercurial > hg
comparison mercurial/upgrade.py @ 31897:d0067250542d
upgrade: simplify optimisations validation
Since we fetch optimizations distinctly from the deficiencies, we can simplify
some code.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 10 Apr 2017 21:01:06 +0200 |
parents | 127b41e975fd |
children | 9db45228da52 |
comparison
equal
deleted
inserted
replaced
31896:127b41e975fd | 31897:d0067250542d |
---|---|
619 raise error.Abort(_('cannot upgrade repository; do not support ' | 619 raise error.Abort(_('cannot upgrade repository; do not support ' |
620 'destination requirement: %s') % | 620 'destination requirement: %s') % |
621 _(', ').join(sorted(unsupportedreqs))) | 621 _(', ').join(sorted(unsupportedreqs))) |
622 | 622 |
623 # Find and validate all improvements that can be made. | 623 # Find and validate all improvements that can be made. |
624 improvements = finddeficiencies(repo) + findoptimizations(repo) | 624 optimizations = findoptimizations(repo) |
625 for i in improvements: | |
626 if i.type not in (deficiency, optimisation): | |
627 raise error.Abort(_('unexpected improvement type %s for %s') % ( | |
628 i.type, i.name)) | |
629 | 625 |
630 # Validate arguments. | 626 # Validate arguments. |
631 unknownoptimize = optimize - set(i.name for i in improvements | 627 unknownoptimize = optimize - set(i.name for i in optimizations) |
632 if i.type == optimisation) | |
633 if unknownoptimize: | 628 if unknownoptimize: |
634 raise error.Abort(_('unknown optimization action requested: %s') % | 629 raise error.Abort(_('unknown optimization action requested: %s') % |
635 ', '.join(sorted(unknownoptimize)), | 630 ', '.join(sorted(unknownoptimize)), |
636 hint=_('run without arguments to see valid ' | 631 hint=_('run without arguments to see valid ' |
637 'optimizations')) | 632 'optimizations')) |
638 | 633 |
634 deficiencies = finddeficiencies(repo) | |
635 improvements = deficiencies + optimizations | |
639 actions = determineactions(repo, improvements, repo.requirements, | 636 actions = determineactions(repo, improvements, repo.requirements, |
640 newreqs, optimize) | 637 newreqs, optimize) |
641 | 638 |
642 def printrequirements(): | 639 def printrequirements(): |
643 ui.write(_('requirements\n')) | 640 ui.write(_('requirements\n')) |