D9615: upgrade: move optimization addition to determineactions()

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Dec 16 10:14:51 UTC 2020


pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The documentation of `determineactions()` mention that it is given a list
  returned from `findoptimizations()` however it was not true before this patch.
  
  The code extending actions with optimizations also mentioned about it that this
  should be in determineactions.
  
  So let's do what comments at couple of places say.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9615

AFFECTED FILES
  mercurial/upgrade.py
  mercurial/upgrade_utils/actions.py

CHANGE DETAILS

diff --git a/mercurial/upgrade_utils/actions.py b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -526,7 +526,9 @@
     return list(ALL_OPTIMISATIONS)
 
 
-def determineactions(repo, format_upgrades, sourcereqs, destreqs):
+def determineactions(
+    repo, format_upgrades, optimizations, sourcereqs, destreqs
+):
     """Determine upgrade actions that will be performed.
 
     Given a list of improvements as returned by ``find_format_upgrades`` and
@@ -551,6 +553,8 @@
 
         newactions.append(d)
 
+    newactions.extend(o for o in sorted(optimizations) if o not in newactions)
+
     # FUTURE consider adding some optimizations here for certain transitions.
     # e.g. adding generaldelta could schedule parent redeltas.
 
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -85,13 +85,7 @@
 
     format_upgrades = upgrade_actions.find_format_upgrades(repo)
     actions = upgrade_actions.determineactions(
-        repo, format_upgrades, repo.requirements, newreqs
-    )
-    actions.extend(
-        o
-        for o in sorted(optimizations)
-        # determineactions could have added optimisation
-        if o not in actions
+        repo, format_upgrades, optimizations, repo.requirements, newreqs
     )
 
     removedreqs = repo.requirements - newreqs



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list