phases: use revision number in analyze_remote_phases
Same logic as the previous change to `new_heads`, see rationnal there.
This avoids a small number of `nodes -> revs` conversion speeding thing up in
the 100 milliseconds order of magnitude for the worses cases. However, the rest
of the logic is noisy enough that it hardly matters for now.
--- a/mercurial/exchange.py Fri Apr 05 11:33:47 2024 +0200
+++ b/mercurial/exchange.py Fri Apr 05 12:02:43 2024 +0200
@@ -1308,8 +1308,16 @@
_localphasemove(pushop, cheads)
# don't push any phase data as there is nothing to push
else:
- ana = phases.analyzeremotephases(pushop.repo, cheads, remotephases)
- pheads, droots = ana
+ unfi = pushop.repo.unfiltered()
+ to_rev = unfi.changelog.index.rev
+ to_node = unfi.changelog.node
+ cheads_revs = [to_rev(n) for n in cheads]
+ pheads_revs, _dr = phases.analyze_remote_phases(
+ pushop.repo,
+ cheads_revs,
+ remotephases,
+ )
+ pheads = [to_node(r) for r in pheads_revs]
### Apply remote phase on local
if remotephases.get(b'publishing', False):
_localphasemove(pushop, cheads)
@@ -2063,10 +2071,17 @@
pullop.stepsdone.add(b'phases')
publishing = bool(remotephases.get(b'publishing', False))
if remotephases and not publishing:
+ unfi = pullop.repo.unfiltered()
+ to_rev = unfi.changelog.index.rev
+ to_node = unfi.changelog.node
+ pulledsubset_revs = [to_rev(n) for n in pullop.pulledsubset]
# remote is new and non-publishing
- pheads, _dr = phases.analyzeremotephases(
- pullop.repo, pullop.pulledsubset, remotephases
+ pheads_revs, _dr = phases.analyze_remote_phases(
+ pullop.repo,
+ pulledsubset_revs,
+ remotephases,
)
+ pheads = [to_node(r) for r in pheads_revs]
dheads = pullop.pulledsubset
else:
# Remote is old or publishing all common changesets
--- a/mercurial/phases.py Fri Apr 05 11:33:47 2024 +0200
+++ b/mercurial/phases.py Fri Apr 05 12:02:43 2024 +0200
@@ -1095,7 +1095,11 @@
advanceboundary(repo, trgetter(), phase, heads)
-def analyzeremotephases(repo, subset, roots):
+def analyze_remote_phases(
+ repo,
+ subset: Collection[int],
+ roots: Dict[bytes, bytes],
+) -> Tuple[Collection[int], Collection[int]]:
"""Compute phases heads and root in a subset of node from root dict
* subset is heads of the subset
@@ -1107,7 +1111,6 @@
# build list from dictionary
draft_roots = []
to_rev = repo.changelog.index.get_rev
- to_node = repo.changelog.node
for nhex, phase in roots.items():
if nhex == b'publishing': # ignore data related to publish option
continue
@@ -1125,11 +1128,8 @@
msg = _(b'ignoring unexpected root from remote: %i %s\n')
repo.ui.warn(msg % (phase, nhex))
# compute heads
- subset_revs = [to_rev(n) for n in subset]
- public_heads = new_heads(repo, subset_revs, draft_roots)
- draft_nodes = [to_node(r) for r in draft_roots]
- public_nodes = [to_node(r) for r in public_heads]
- return public_nodes, draft_nodes
+ public_heads = new_heads(repo, subset, draft_roots)
+ return public_heads, draft_roots
class remotephasessummary:
@@ -1143,14 +1143,18 @@
def __init__(self, repo, remotesubset, remoteroots):
unfi = repo.unfiltered()
+ to_rev = unfi.changelog.index.rev
+ to_node = unfi.changelog.node
self._allremoteroots = remoteroots
self.publishing = remoteroots.get(b'publishing', False)
- ana = analyzeremotephases(repo, remotesubset, remoteroots)
- self.publicheads, self.draftroots = ana
+ 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]
# Get the list of all "heads" revs draft on remote
- dheads = unfi.set(b'heads(%ln::%ln)', self.draftroots, remotesubset)
+ dheads = unfi.set(b'heads(%ld::%ld)', roots, remote_subset)
self.draftheads = [c.node() for c in dheads]