diff mercurial/changegroup.py @ 45789:09735cde6275

phases: allow registration and boundary advancement with revision sets The core internals either use revision sets already or can trivially use them. Use the new interface in cg1unpacker.apply to avoid materializing the list of all new nodes as it is normally just a revision range. This avoids about 67 Bytes / changeset on AMD64 in peak RSS. Differential Revision: https://phab.mercurial-scm.org/D9232
author Joerg Sonnenberger <joerg@bec.de>
date Mon, 19 Oct 2020 02:54:12 +0200
parents a5206e71c536
children 5d65e04b6a80
line wrap: on
line diff
--- a/mercurial/changegroup.py	Sun Oct 18 22:18:02 2020 +0200
+++ b/mercurial/changegroup.py	Mon Oct 19 02:54:12 2020 +0200
@@ -318,12 +318,12 @@
             efilesset = set()
             cgnodes = []
 
+            def ondupchangelog(cl, node):
+                if cl.rev(node) < clstart:
+                    cgnodes.append(node)
+
             def onchangelog(cl, node):
                 efilesset.update(cl.readfiles(node))
-                cgnodes.append(node)
-
-            def ondupchangelog(cl, node):
-                cgnodes.append(node)
 
             self.changelogheader()
             deltas = self.deltaiter()
@@ -365,7 +365,7 @@
                 for cset in pycompat.xrange(clstart, clend):
                     mfnode = cl.changelogrevision(cset).manifest
                     mfest = ml[mfnode].readdelta()
-                    # store file cgnodes we must see
+                    # store file nodes we must see
                     for f, n in pycompat.iteritems(mfest):
                         needfiles.setdefault(f, set()).add(n)
 
@@ -423,7 +423,7 @@
                     **pycompat.strkwargs(hookargs)
                 )
 
-            added = [cl.node(r) for r in pycompat.xrange(clstart, clend)]
+            added = pycompat.xrange(clstart, clend)
             phaseall = None
             if srctype in (b'push', b'serve'):
                 # Old servers can not push the boundary themselves.
@@ -443,9 +443,10 @@
                     # ignored.
                     targetphase = phaseall = phases.draft
             if added:
-                phases.registernew(repo, tr, targetphase, added)
+                phases.registernew(repo, tr, targetphase, [], revs=added)
             if phaseall is not None:
-                phases.advanceboundary(repo, tr, phaseall, cgnodes)
+                phases.advanceboundary(repo, tr, phaseall, cgnodes, revs=added)
+                cgnodes = []
 
             if changesets > 0:
 
@@ -458,9 +459,9 @@
 
                     repo.hook(b"changegroup", **pycompat.strkwargs(hookargs))
 
-                    for n in added:
+                    for rev in added:
                         args = hookargs.copy()
-                        args[b'node'] = hex(n)
+                        args[b'node'] = hex(cl.node(rev))
                         del args[b'node_last']
                         repo.hook(b"incoming", **pycompat.strkwargs(args))