Patchwork D9666: actions: store deltareuse mode of whole operation in UpgradeOperation

login
register
mail settings
Submitter phabricator
Date Dec. 30, 2020, 11:53 a.m.
Message ID <differential-rev-PHID-DREV-ja242ugi45dmr3ueudz7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47977/
State Superseded
Headers show

Comments

phabricator - Dec. 30, 2020, 11:53 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  UpgradeOperation should provide easy access to all the things related to the
  current operation. Clients should not need to compute them.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




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

Patch

diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -446,24 +446,13 @@ 
         )
     )
 
-    if upgrade_op.has_upgrade_action(b're-delta-all'):
-        deltareuse = revlog.revlog.DELTAREUSENEVER
-    elif upgrade_op.has_upgrade_action(b're-delta-parent'):
-        deltareuse = revlog.revlog.DELTAREUSESAMEREVS
-    elif upgrade_op.has_upgrade_action(b're-delta-multibase'):
-        deltareuse = revlog.revlog.DELTAREUSESAMEREVS
-    elif upgrade_op.has_upgrade_action(b're-delta-fulladd'):
-        deltareuse = revlog.revlog.DELTAREUSEFULLADD
-    else:
-        deltareuse = revlog.revlog.DELTAREUSEALWAYS
-
     with dstrepo.transaction(b'upgrade') as tr:
         _clonerevlogs(
             ui,
             srcrepo,
             dstrepo,
             tr,
-            deltareuse,
+            upgrade_op.delta_reuse_mode,
             upgrade_op.has_upgrade_action(b're-delta-multibase'),
             revlogs=upgrade_op.revlogs_to_process,
         )
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
@@ -12,6 +12,7 @@ 
     error,
     localrepo,
     requirements,
+    revlog,
     util,
 )
 
@@ -646,6 +647,17 @@ 
             i for i in all_optimizations if i not in self.upgrade_actions
         ]
 
+        # delta reuse mode of this upgrade operation
+        self.delta_reuse_mode = revlog.revlog.DELTAREUSEALWAYS
+        if b're-delta-all' in self._upgrade_actions_names:
+            self.delta_reuse_mode = revlog.revlog.DELTAREUSENEVER
+        elif b're-delta-parent' in self._upgrade_actions_names:
+            self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
+        elif b're-delta-multibase' in self._upgrade_actions_names:
+            self.delta_reuse_mode = revlog.revlog.DELTAREUSESAMEREVS
+        elif b're-delta-fulladd' in self._upgrade_actions_names:
+            self.delta_reuse_mode = revlog.revlog.DELTAREUSEFULLADD
+
     def _write_labeled(self, l, label):
         """
         Utility function to aid writing of a list under one label