comparison 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
comparison
equal deleted inserted replaced
45788:a5206e71c536 45789:09735cde6275
316 self.callback = progress.increment 316 self.callback = progress.increment
317 317
318 efilesset = set() 318 efilesset = set()
319 cgnodes = [] 319 cgnodes = []
320 320
321 def ondupchangelog(cl, node):
322 if cl.rev(node) < clstart:
323 cgnodes.append(node)
324
321 def onchangelog(cl, node): 325 def onchangelog(cl, node):
322 efilesset.update(cl.readfiles(node)) 326 efilesset.update(cl.readfiles(node))
323 cgnodes.append(node)
324
325 def ondupchangelog(cl, node):
326 cgnodes.append(node)
327 327
328 self.changelogheader() 328 self.changelogheader()
329 deltas = self.deltaiter() 329 deltas = self.deltaiter()
330 if not cl.addgroup( 330 if not cl.addgroup(
331 deltas, 331 deltas,
363 ml = repo.manifestlog 363 ml = repo.manifestlog
364 # validate incoming csets have their manifests 364 # validate incoming csets have their manifests
365 for cset in pycompat.xrange(clstart, clend): 365 for cset in pycompat.xrange(clstart, clend):
366 mfnode = cl.changelogrevision(cset).manifest 366 mfnode = cl.changelogrevision(cset).manifest
367 mfest = ml[mfnode].readdelta() 367 mfest = ml[mfnode].readdelta()
368 # store file cgnodes we must see 368 # store file nodes we must see
369 for f, n in pycompat.iteritems(mfest): 369 for f, n in pycompat.iteritems(mfest):
370 needfiles.setdefault(f, set()).add(n) 370 needfiles.setdefault(f, set()).add(n)
371 371
372 # process the files 372 # process the files
373 repo.ui.status(_(b"adding file changes\n")) 373 repo.ui.status(_(b"adding file changes\n"))
421 b'pretxnchangegroup', 421 b'pretxnchangegroup',
422 throw=True, 422 throw=True,
423 **pycompat.strkwargs(hookargs) 423 **pycompat.strkwargs(hookargs)
424 ) 424 )
425 425
426 added = [cl.node(r) for r in pycompat.xrange(clstart, clend)] 426 added = pycompat.xrange(clstart, clend)
427 phaseall = None 427 phaseall = None
428 if srctype in (b'push', b'serve'): 428 if srctype in (b'push', b'serve'):
429 # Old servers can not push the boundary themselves. 429 # Old servers can not push the boundary themselves.
430 # New servers won't push the boundary if changeset already 430 # New servers won't push the boundary if changeset already
431 # exists locally as secret 431 # exists locally as secret
441 # outside, their phases are going to be pushed 441 # outside, their phases are going to be pushed
442 # alongside. Therefor `targetphase` is 442 # alongside. Therefor `targetphase` is
443 # ignored. 443 # ignored.
444 targetphase = phaseall = phases.draft 444 targetphase = phaseall = phases.draft
445 if added: 445 if added:
446 phases.registernew(repo, tr, targetphase, added) 446 phases.registernew(repo, tr, targetphase, [], revs=added)
447 if phaseall is not None: 447 if phaseall is not None:
448 phases.advanceboundary(repo, tr, phaseall, cgnodes) 448 phases.advanceboundary(repo, tr, phaseall, cgnodes, revs=added)
449 cgnodes = []
449 450
450 if changesets > 0: 451 if changesets > 0:
451 452
452 def runhooks(unused_success): 453 def runhooks(unused_success):
453 # These hooks run when the lock releases, not when the 454 # These hooks run when the lock releases, not when the
456 if clstart >= len(repo): 457 if clstart >= len(repo):
457 return 458 return
458 459
459 repo.hook(b"changegroup", **pycompat.strkwargs(hookargs)) 460 repo.hook(b"changegroup", **pycompat.strkwargs(hookargs))
460 461
461 for n in added: 462 for rev in added:
462 args = hookargs.copy() 463 args = hookargs.copy()
463 args[b'node'] = hex(n) 464 args[b'node'] = hex(cl.node(rev))
464 del args[b'node_last'] 465 del args[b'node_last']
465 repo.hook(b"incoming", **pycompat.strkwargs(args)) 466 repo.hook(b"incoming", **pycompat.strkwargs(args))
466 467
467 newheads = [h for h in repo.heads() if h not in oldheads] 468 newheads = [h for h in repo.heads() if h not in oldheads]
468 repo.ui.log( 469 repo.ui.log(