Patchwork D9233: phases: convert registernew users to use revision sets

login
register
mail settings
Submitter phabricator
Date Oct. 20, 2020, 3:33 p.m.
Message ID <differential-rev-PHID-DREV-fck65iwh6vvlhhhkuz7u-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47498/
State Superseded
Headers show

Comments

phabricator - Oct. 20, 2020, 3:33 p.m.
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9233

AFFECTED FILES
  hgext/convert/hg.py
  mercurial/changegroup.py
  mercurial/commit.py
  mercurial/exchangev2.py
  mercurial/phases.py

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -510,16 +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=[]):
+    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()
@@ -714,14 +711,14 @@ 
     repo._phasecache.replace(phcache)
 
 
-def registernew(repo, tr, targetphase, nodes, revs=[]):
+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).
     """
     phcache = repo._phasecache.copy()
-    phcache.registernew(repo, tr, targetphase, nodes, revs=revs)
+    phcache.registernew(repo, tr, targetphase, revs)
     repo._phasecache.replace(phcache)
 
 
diff --git a/mercurial/exchangev2.py b/mercurial/exchangev2.py
--- a/mercurial/exchangev2.py
+++ b/mercurial/exchangev2.py
@@ -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():
diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -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
 
 
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -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 = []
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -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"