vcsreplicator: use `phaseroots` integer keys directly instead of implicit enumeration (
Bug 1727344) r=zeid
Mercurial internals formerly defined phases via an expansion of `range(3)`,
mapping the phases to each integer. Internally the integers are used so
the phases have an order (ie `draft < public`), but these phases are mapped
to names that we use in the Mercurial command line. At some point new phases
were added with their own unique values that break the `range(3)` standard.
In `vcsreplicator` we would read the `phaseroots` dict and enumerate the keys
to determine which phases are present on a given repo, however the presence
of the new phases breaks this assumption. Since the `phaseroots` object is
aleady a mapping of the phase integer representation to revision hash, we
should use the keys of the `phaseroots` mapping directly to determine which
phases are found on a given repo.
Depends on D123481
Differential Revision:
https://phabricator.services.mozilla.com/D123482
--- a/pylib/vcsreplicator/vcsreplicator/hgext.py
+++ b/pylib/vcsreplicator/vcsreplicator/hgext.py
@@ -175,19 +175,22 @@ def phase_heads_handler(op, inpart):
return _ORIG_PHASE_HEADS_HANDLER(op, inpart)
# Else this looks like a push without a changegroup. (A phase only push.)
# We monkeypatch the function for handling phase updates to record what
# changes were made. Then we convert the changes into pushkey messages.
# We make assumptions later that we only update from the draft phase. Double
# check that the source repo doesn't have any secret, etc phase roots.
- seen_phases = set(i for i, v
- in enumerate(op.repo.unfiltered()._phasecache.phaseroots)
- if v)
+ seen_phases = set(
+ phase
+ for phase, roots in
+ op.repo.unfiltered()._phasecache.phaseroots.items()
+ if roots
+ )
supported_phases = {phases.public, phases.draft}
if seen_phases - supported_phases:
raise error.Abort(_(b'only draft and public phases are supported'))
moves = {}
def wrapped_advanceboundary(orig, repo, tr, targetphase, nodes):