repo-upgrade: avoid a crash when multiple optimisation are specified stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 05 Jul 2022 17:53:26 +0200
branchstable
changeset 49377 7fe86498e84f
parent 49376 6b04f702c501
child 49378 094a5fa3cf52
repo-upgrade: avoid a crash when multiple optimisation are specified In Python 3, the type are no longer comparable and this expose the error.
mercurial/upgrade_utils/actions.py
tests/test-upgrade-repo.t
--- a/mercurial/upgrade_utils/actions.py	Wed May 25 18:29:21 2022 +0200
+++ b/mercurial/upgrade_utils/actions.py	Tue Jul 05 17:53:26 2022 +0200
@@ -683,7 +683,11 @@
 
         newactions.append(d)
 
-    newactions.extend(o for o in sorted(optimizations) if o not in newactions)
+    newactions.extend(
+        o
+        for o in sorted(optimizations, key=(lambda x: x.name))
+        if o not in newactions
+    )
 
     # FUTURE consider adding some optimizations here for certain transitions.
     # e.g. adding generaldelta could schedule parent redeltas.
--- a/tests/test-upgrade-repo.t	Wed May 25 18:29:21 2022 +0200
+++ b/tests/test-upgrade-repo.t	Tue Jul 05 17:53:26 2022 +0200
@@ -467,6 +467,7 @@
   re-delta-fulladd
      every revision will be re-added as if it was new content. It will go through the full storage mechanism giving extensions a chance to process it (eg. lfs). This is similar to "re-delta-all" but even slower since more logic is involved.
   
+
   $ hg debugupgrade --optimize re-delta-parent --quiet
   requirements
      preserved: dotencode, fncache, generaldelta, revlogv1, share-safe, sparserevlog, store (no-rust !)
@@ -480,6 +481,20 @@
     - manifest
   
 
+passing multiple optimization:
+
+  $ hg debugupgrade --optimize re-delta-parent --optimize re-delta-multibase --quiet
+  requirements
+     preserved: * (glob)
+  
+  optimisations: re-delta-multibase, re-delta-parent
+  
+  processed revlogs:
+    - all-filelogs
+    - changelog
+    - manifest
+  
+
 unknown optimization:
 
   $ hg debugupgrade --optimize foobar