diff mercurial/exchangev2.py @ 45117:b1e51ef4e536

phases: sparsify phase lists When the internal and archived phase was added, allphase became a large, sparsely populated list. This dramatically increased the number of lookup operations for public relations in `phasecache.phase`. As a first step, define allphases and related lists explicitly to contain only the actual phases. Make phasenames a dictionary and create corresponding dictionaries for mapping phase names back to numbers. Adjust various list to be sparse as well with the exception of phaseroots and phasesets members of phasecache. Keep those as a separate step as it involves changes to the C module. Differential Revision: https://phab.mercurial-scm.org/D8697
author Joerg Sonnenberger <joerg@bec.de>
date Wed, 08 Jul 2020 00:15:15 +0200
parents a166fadf5c3b
children a5206e71c536
line wrap: on
line diff
--- a/mercurial/exchangev2.py	Tue Jul 07 22:00:02 2020 +0200
+++ b/mercurial/exchangev2.py	Wed Jul 08 00:15:15 2020 +0200
@@ -82,15 +82,12 @@
         phases.registernew(repo, tr, phases.draft, csetres[b'added'])
 
     # And adjust the phase of all changesets accordingly.
-    for phase in phases.phasenames:
+    for phasenumber, phase in phases.phasenames.items():
         if phase == b'secret' or not csetres[b'nodesbyphase'][phase]:
             continue
 
         phases.advanceboundary(
-            repo,
-            tr,
-            phases.phasenames.index(phase),
-            csetres[b'nodesbyphase'][phase],
+            repo, tr, phasenumber, csetres[b'nodesbyphase'][phase],
         )
 
     # Write bookmark updates.
@@ -361,7 +358,7 @@
         # so we can set the linkrev accordingly when manifests are added.
         manifestnodes[cl.rev(node)] = revision.manifest
 
-    nodesbyphase = {phase: set() for phase in phases.phasenames}
+    nodesbyphase = {phase: set() for phase in phases.phasenames.values()}
     remotebookmarks = {}
 
     # addgroup() expects a 7-tuple describing revisions. This normalizes