##// END OF EJS Templates
phases: allow registration and boundary advancement with revision sets...
Joerg Sonnenberger -
r46374:09735cde default
parent child Browse files
Show More
@@ -318,12 +318,12 b' class cg1unpacker(object):'
318 318 efilesset = set()
319 319 cgnodes = []
320 320
321 def ondupchangelog(cl, node):
322 if cl.rev(node) < clstart:
323 cgnodes.append(node)
324
321 325 def onchangelog(cl, node):
322 326 efilesset.update(cl.readfiles(node))
323 cgnodes.append(node)
324
325 def ondupchangelog(cl, node):
326 cgnodes.append(node)
327 327
328 328 self.changelogheader()
329 329 deltas = self.deltaiter()
@@ -365,7 +365,7 b' class cg1unpacker(object):'
365 365 for cset in pycompat.xrange(clstart, clend):
366 366 mfnode = cl.changelogrevision(cset).manifest
367 367 mfest = ml[mfnode].readdelta()
368 # store file cgnodes we must see
368 # store file nodes we must see
369 369 for f, n in pycompat.iteritems(mfest):
370 370 needfiles.setdefault(f, set()).add(n)
371 371
@@ -423,7 +423,7 b' class cg1unpacker(object):'
423 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 427 phaseall = None
428 428 if srctype in (b'push', b'serve'):
429 429 # Old servers can not push the boundary themselves.
@@ -443,9 +443,10 b' class cg1unpacker(object):'
443 443 # ignored.
444 444 targetphase = phaseall = phases.draft
445 445 if added:
446 phases.registernew(repo, tr, targetphase, added)
446 phases.registernew(repo, tr, targetphase, [], revs=added)
447 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 451 if changesets > 0:
451 452
@@ -458,9 +459,9 b' class cg1unpacker(object):'
458 459
459 460 repo.hook(b"changegroup", **pycompat.strkwargs(hookargs))
460 461
461 for n in added:
462 for rev in added:
462 463 args = hookargs.copy()
463 args[b'node'] = hex(n)
464 args[b'node'] = hex(cl.node(rev))
464 465 del args[b'node_last']
465 466 repo.hook(b"incoming", **pycompat.strkwargs(args))
466 467
@@ -510,21 +510,25 b' class phasecache(object):'
510 510 tr.addfilegenerator(b'phase', (b'phaseroots',), self._write)
511 511 tr.hookargs[b'phases_moved'] = b'1'
512 512
513 def registernew(self, repo, tr, targetphase, nodes):
513 def registernew(self, repo, tr, targetphase, nodes, revs=None):
514 if revs is None:
515 revs = []
514 516 repo = repo.unfiltered()
515 self._retractboundary(repo, tr, targetphase, nodes)
517 self._retractboundary(repo, tr, targetphase, nodes, revs=revs)
516 518 if tr is not None and b'phases' in tr.changes:
517 519 phasetracking = tr.changes[b'phases']
518 520 torev = repo.changelog.rev
519 521 phase = self.phase
520 revs = [torev(node) for node in nodes]
522 revs = [torev(node) for node in nodes] + sorted(revs)
521 523 revs.sort()
522 524 for rev in revs:
523 525 revphase = phase(repo, rev)
524 526 _trackphasechange(phasetracking, rev, None, revphase)
525 527 repo.invalidatevolatilesets()
526 528
527 def advanceboundary(self, repo, tr, targetphase, nodes, dryrun=None):
529 def advanceboundary(
530 self, repo, tr, targetphase, nodes, revs=None, dryrun=None
531 ):
528 532 """Set all 'nodes' to phase 'targetphase'
529 533
530 534 Nodes with a phase lower than 'targetphase' are not affected.
@@ -535,26 +539,27 b' class phasecache(object):'
535 539 """
536 540 # Be careful to preserve shallow-copied values: do not update
537 541 # phaseroots values, replace them.
542 if revs is None:
543 revs = []
538 544 if tr is None:
539 545 phasetracking = None
540 546 else:
541 547 phasetracking = tr.changes.get(b'phases')
542 548
543 549 repo = repo.unfiltered()
550 revs = [repo[n].rev() for n in nodes] + [r for r in revs]
544 551
545 552 changes = set() # set of revisions to be changed
546 553 delroots = [] # set of root deleted by this path
547 554 for phase in (phase for phase in allphases if phase > targetphase):
548 555 # filter nodes that are not in a compatible phase already
549 nodes = [
550 n for n in nodes if self.phase(repo, repo[n].rev()) >= phase
551 ]
552 if not nodes:
556 revs = [rev for rev in revs if self.phase(repo, rev) >= phase]
557 if not revs:
553 558 break # no roots to move anymore
554 559
555 560 olds = self.phaseroots[phase]
556 561
557 affected = repo.revs(b'%ln::%ln', olds, nodes)
562 affected = repo.revs(b'%ln::%ld', olds, revs)
558 563 changes.update(affected)
559 564 if dryrun:
560 565 continue
@@ -611,9 +616,11 b' class phasecache(object):'
611 616 _trackphasechange(phasetracking, r, phase, targetphase)
612 617 repo.invalidatevolatilesets()
613 618
614 def _retractboundary(self, repo, tr, targetphase, nodes):
619 def _retractboundary(self, repo, tr, targetphase, nodes, revs=None):
615 620 # Be careful to preserve shallow-copied values: do not update
616 621 # phaseroots values, replace them.
622 if revs is None:
623 revs = []
617 624 if targetphase in (archived, internal) and not supportinternal(repo):
618 625 name = phasenames[targetphase]
619 626 msg = b'this repository does not support the %s phase' % name
@@ -624,7 +631,7 b' class phasecache(object):'
624 631 tonode = repo.changelog.node
625 632 currentroots = {torev(node) for node in self.phaseroots[targetphase]}
626 633 finalroots = oldroots = set(currentroots)
627 newroots = [torev(node) for node in nodes]
634 newroots = [torev(node) for node in nodes] + [r for r in revs]
628 635 newroots = [
629 636 rev for rev in newroots if self.phase(repo, rev) < targetphase
630 637 ]
@@ -679,7 +686,7 b' class phasecache(object):'
679 686 self.invalidate()
680 687
681 688
682 def advanceboundary(repo, tr, targetphase, nodes, dryrun=None):
689 def advanceboundary(repo, tr, targetphase, nodes, revs=None, dryrun=None):
683 690 """Add nodes to a phase changing other nodes phases if necessary.
684 691
685 692 This function move boundary *forward* this means that all nodes
@@ -691,9 +698,11 b' def advanceboundary(repo, tr, targetphas'
691 698
692 699 Returns a set of revs whose phase is changed or should be changed
693 700 """
701 if revs is None:
702 revs = []
694 703 phcache = repo._phasecache.copy()
695 704 changes = phcache.advanceboundary(
696 repo, tr, targetphase, nodes, dryrun=dryrun
705 repo, tr, targetphase, nodes, revs=revs, dryrun=dryrun
697 706 )
698 707 if not dryrun:
699 708 repo._phasecache.replace(phcache)
@@ -713,14 +722,16 b' def retractboundary(repo, tr, targetphas'
713 722 repo._phasecache.replace(phcache)
714 723
715 724
716 def registernew(repo, tr, targetphase, nodes):
725 def registernew(repo, tr, targetphase, nodes, revs=None):
717 726 """register a new revision and its phase
718 727
719 728 Code adding revisions to the repository should use this function to
720 729 set new changeset in their target phase (or higher).
721 730 """
731 if revs is None:
732 revs = []
722 733 phcache = repo._phasecache.copy()
723 phcache.registernew(repo, tr, targetphase, nodes)
734 phcache.registernew(repo, tr, targetphase, nodes, revs=revs)
724 735 repo._phasecache.replace(phcache)
725 736
726 737
General Comments 0
You need to be logged in to leave comments. Login now