[PATCH 08 of 12] upgrade: simplify 'determineactions'

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Apr 11 18:47:48 EDT 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1491583167 -7200
#      Fri Apr 07 18:39:27 2017 +0200
# Node ID d597e0ce2aaaab926589a648caaf2cc6de0c14ce
# Parent  0ac92cae04221762209a3e58ef95ef7c0092c764
# 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 d597e0ce2aaa
upgrade: simplify 'determineactions'

Since we only takes 'deficiencies', we can simplify the function and clarify its
arguments.

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -261,7 +261,7 @@ def findoptimizations(repo):
 
     return optimizations
 
-def determineactions(repo, improvements, sourcereqs, destreqs):
+def determineactions(repo, deficiencies, sourcereqs, destreqs):
     """Determine upgrade actions that will be performed.
 
     Given a list of improvements as returned by ``finddeficiencies`` and
@@ -278,16 +278,15 @@ def determineactions(repo, improvements,
 
     knownreqs = supporteddestrequirements(repo)
 
-    for i in improvements:
-        name = i.name
+    for d in deficiencies:
+        name = d.name
 
         # If the action is a requirement that doesn't show up in the
         # destination requirements, prune the action.
         if name in knownreqs and name not in destreqs:
             continue
 
-        if i.type == deficiency:
-            newactions.append(name)
+        newactions.append(name)
 
     # FUTURE consider adding some optimizations here for certain transitions.
     # e.g. adding generaldelta could schedule parent redeltas.


More information about the Mercurial-devel mailing list