diff mercurial/phases.py @ 51583:22cc679a7312

phases: move RemotePhasesSummary to revision number This continue our quest to align more logic on revision number instead of node-ids. The motivation is similar to the change to `new_heads` and `analyze_remote_phases` a few changeset earlier. Again, we take this as an opportunity to rename the class, and the attribute to the new naming scheme. This will highlight the need for code update for any code using it an expecting node-ids. Many of the rev-num → node-id conversion we had to introduce in the previous changesets can now be removed. More will be removed in the future as we continue to align code toward rev-num usage. time saved in the 100 milliseconds order of magnitude for the mozilla-try benchmark I have been using.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 05 Apr 2024 14:11:02 +0200
parents d8287e43540f
children c11d21faa73c
line wrap: on
line diff
--- a/mercurial/phases.py	Fri Apr 05 12:24:47 2024 +0200
+++ b/mercurial/phases.py	Fri Apr 05 14:11:02 2024 +0200
@@ -1132,30 +1132,32 @@
     return public_heads, draft_roots
 
 
-class remotephasessummary:
+class RemotePhasesSummary:
     """summarize phase information on the remote side
 
     :publishing: True is the remote is publishing
-    :publicheads: list of remote public phase heads (nodes)
-    :draftheads: list of remote draft phase heads (nodes)
-    :draftroots: list of remote draft phase root (nodes)
+    :public_heads: list of remote public phase heads (revs)
+    :draft_heads: list of remote draft phase heads (revs)
+    :draft_roots: list of remote draft phase root (revs)
     """
 
-    def __init__(self, repo, remotesubset, remoteroots):
+    def __init__(
+        self,
+        repo,
+        remote_subset: Collection[int],
+        remote_roots: Dict[bytes, bytes],
+    ):
         unfi = repo.unfiltered()
-        to_rev = unfi.changelog.index.rev
-        to_node = unfi.changelog.node
-        self._allremoteroots = remoteroots
+        self._allremoteroots: Dict[bytes, bytes] = remote_roots
 
-        self.publishing = remoteroots.get(b'publishing', False)
+        self.publishing: bool = bool(remote_roots.get(b'publishing', False))
 
-        remote_subset = [to_rev(n) for n in remotesubset]
-        heads, roots = analyze_remote_phases(repo, remote_subset, remoteroots)
-        self.publicheads = [to_node(r) for r in heads]
-        self.draftroots = [to_node(r) for r in roots]
+        heads, roots = analyze_remote_phases(repo, remote_subset, remote_roots)
+        self.public_heads: Collection[int] = heads
+        self.draft_roots: Collection[int] = roots
         # Get the list of all "heads" revs draft on remote
         dheads = unfi.revs(b'heads(%ld::%ld)', roots, remote_subset)
-        self.draftheads = [to_node(r) for r in dheads]
+        self.draft_heads: Collection[int] = dheads
 
 
 def new_heads(