Mercurial > hg
changeset 31899:cccd8e1538b0
upgrade: filter optimizations outside of 'determineactions'
This sounds like higher level logic to process arguments.
Moving it out of 'determineactions' will allow passing only deficiencies to the
function. Then, in a future changeset, we will remove dispatch on "improvement
type" within the function. See next changeset for details.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 11 Apr 2017 23:46:16 +0200 |
parents | 9db45228da52 |
children | 0f0d7005b9ad |
files | mercurial/upgrade.py |
diffstat | 1 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/upgrade.py Fri Apr 07 18:46:27 2017 +0200 +++ b/mercurial/upgrade.py Tue Apr 11 23:46:16 2017 +0200 @@ -261,8 +261,7 @@ return optimizations -def determineactions(repo, improvements, sourcereqs, destreqs, - optimize): +def determineactions(repo, improvements, sourcereqs, destreqs): """Determine upgrade actions that will be performed. Given a list of improvements as returned by ``finddeficiencies`` and @@ -290,8 +289,6 @@ if i.type == deficiency: newactions.append(name) - newactions.extend(o for o in sorted(optimize) if o not in newactions) - # FUTURE consider adding some optimizations here for certain transitions. # e.g. adding generaldelta could schedule parent redeltas. @@ -621,20 +618,27 @@ _(', ').join(sorted(unsupportedreqs))) # Find and validate all improvements that can be made. - alloptimizations = optimizations = findoptimizations(repo) + alloptimizations = findoptimizations(repo) - # Validate arguments. - unknownoptimize = optimize - set(i.name for i in optimizations) - if unknownoptimize: + # Apply and Validate arguments. + optimizations = [] + for o in alloptimizations: + if o.name in optimize: + optimizations.append(o) + optimize.discard(o.name) + + if optimize: # anything left is unknown raise error.Abort(_('unknown optimization action requested: %s') % - ', '.join(sorted(unknownoptimize)), + ', '.join(sorted(optimize)), hint=_('run without arguments to see valid ' 'optimizations')) deficiencies = finddeficiencies(repo) improvements = deficiencies + optimizations - actions = determineactions(repo, improvements, repo.requirements, - newreqs, optimize) + actions = determineactions(repo, deficiencies, repo.requirements, newreqs) + actions.extend(o.name for o in sorted(optimizations) + # determineactions could have added optimisation + if o.name not in actions) def printrequirements(): ui.write(_('requirements\n'))