diff tests/testlib/ext-phase-report.py @ 44558:fdc802f29b2c

transactions: convert changes['phases'] to list of ranges Consecutive revisions are often in the same phase, especially public revisions. This means that a dictionary keyed by the revision for the phase transitions is highly redundant. Build a list of (range, (old, new)) entries instead and aggressively merge ranges with the same transition. For the test case in issue5691, this reduces memory use by ~20MB. Differential Revision: https://phab.mercurial-scm.org/D8125
author Joerg Sonnenberger <joerg@bec.de>
date Fri, 08 Dec 2017 02:29:02 +0100
parents 2372284d9457
children 6000f5b25c9b
line wrap: on
line diff
--- a/tests/testlib/ext-phase-report.py	Wed Mar 11 17:42:56 2020 +0100
+++ b/tests/testlib/ext-phase-report.py	Fri Dec 08 02:29:02 2017 +0100
@@ -5,21 +5,22 @@
 
 def reposetup(ui, repo):
     def reportphasemove(tr):
-        for rev, move in sorted(tr.changes[b'phases'].items()):
-            if move[0] is None:
-                ui.write(
-                    (
-                        b'test-debug-phase: new rev %d:  x -> %d\n'
-                        % (rev, move[1])
+        for revs, move in sorted(tr.changes[b"phases"], key=lambda r: r[0][0]):
+            for rev in revs:
+                if move[0] is None:
+                    ui.write(
+                        (
+                            b'test-debug-phase: new rev %d:  x -> %d\n'
+                            % (rev, move[1])
+                        )
                     )
-                )
-            else:
-                ui.write(
-                    (
-                        b'test-debug-phase: move rev %d: %d -> %d\n'
-                        % (rev, move[0], move[1])
+                else:
+                    ui.write(
+                        (
+                            b'test-debug-phase: move rev %d: %d -> %d\n'
+                            % (rev, move[0], move[1])
+                        )
                     )
-                )
 
     class reportphaserepo(repo.__class__):
         def transaction(self, *args, **kwargs):