phases: convert registernew users to use revision sets
Differential Revision: https://phab.mercurial-scm.org/D9233
--- a/hgext/convert/hg.py Mon Oct 19 02:54:12 2020 +0200
+++ b/hgext/convert/hg.py Tue Oct 20 17:32:45 2020 +0200
@@ -398,7 +398,7 @@
ctx = self.repo[node]
if ctx.phase() < phases.draft:
phases.registernew(
- self.repo, tr, phases.draft, [ctx.node()]
+ self.repo, tr, phases.draft, [ctx.rev()]
)
text = b"(octopus merge fixup)\n"
--- a/mercurial/changegroup.py Mon Oct 19 02:54:12 2020 +0200
+++ b/mercurial/changegroup.py Tue Oct 20 17:32:45 2020 +0200
@@ -443,7 +443,7 @@
# ignored.
targetphase = phaseall = phases.draft
if added:
- phases.registernew(repo, tr, targetphase, [], revs=added)
+ phases.registernew(repo, tr, targetphase, added)
if phaseall is not None:
phases.advanceboundary(repo, tr, phaseall, cgnodes, revs=added)
cgnodes = []
--- a/mercurial/commit.py Mon Oct 19 02:54:12 2020 +0200
+++ b/mercurial/commit.py Tue Oct 20 17:32:45 2020 +0200
@@ -105,7 +105,7 @@
# be compliant anyway
#
# if minimal phase was 0 we don't need to retract anything
- phases.registernew(repo, tr, targetphase, [n])
+ phases.registernew(repo, tr, targetphase, [repo[n].rev()])
return n
--- a/mercurial/exchangev2.py Mon Oct 19 02:54:12 2020 +0200
+++ b/mercurial/exchangev2.py Tue Oct 20 17:32:45 2020 +0200
@@ -79,7 +79,9 @@
# Ensure all new changesets are draft by default. If the repo is
# publishing, the phase will be adjusted by the loop below.
if csetres[b'added']:
- phases.registernew(repo, tr, phases.draft, csetres[b'added'])
+ phases.registernew(
+ repo, tr, phases.draft, [repo[n].rev() for n in csetres[b'added']]
+ )
# And adjust the phase of all changesets accordingly.
for phasenumber, phase in phases.phasenames.items():
--- a/mercurial/phases.py Mon Oct 19 02:54:12 2020 +0200
+++ b/mercurial/phases.py Tue Oct 20 17:32:45 2020 +0200
@@ -510,18 +510,13 @@
tr.addfilegenerator(b'phase', (b'phaseroots',), self._write)
tr.hookargs[b'phases_moved'] = b'1'
- def registernew(self, repo, tr, targetphase, nodes, revs=None):
- if revs is None:
- revs = []
+ def registernew(self, repo, tr, targetphase, revs):
repo = repo.unfiltered()
- self._retractboundary(repo, tr, targetphase, nodes, revs=revs)
+ self._retractboundary(repo, tr, targetphase, [], revs=revs)
if tr is not None and b'phases' in tr.changes:
phasetracking = tr.changes[b'phases']
- torev = repo.changelog.rev
phase = self.phase
- revs = [torev(node) for node in nodes] + sorted(revs)
- revs.sort()
- for rev in revs:
+ for rev in sorted(revs):
revphase = phase(repo, rev)
_trackphasechange(phasetracking, rev, None, revphase)
repo.invalidatevolatilesets()
@@ -722,16 +717,14 @@
repo._phasecache.replace(phcache)
-def registernew(repo, tr, targetphase, nodes, revs=None):
+def registernew(repo, tr, targetphase, revs):
"""register a new revision and its phase
Code adding revisions to the repository should use this function to
set new changeset in their target phase (or higher).
"""
- if revs is None:
- revs = []
phcache = repo._phasecache.copy()
- phcache.registernew(repo, tr, targetphase, nodes, revs=revs)
+ phcache.registernew(repo, tr, targetphase, revs)
repo._phasecache.replace(phcache)