Patchwork D9615: upgrade: move optimization addition to determineactions()

login
register
mail settings
Submitter phabricator
Date Dec. 16, 2020, 10:14 a.m.
Message ID <differential-rev-PHID-DREV-fikbr5z2ccnbjfl76gnp-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47912/
State Superseded
Headers show

Comments

phabricator - Dec. 16, 2020, 10:14 a.m.
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




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

Patch

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