##// 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 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()
@@ -365,7 +365,7 b' class cg1unpacker(object):'
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
@@ -423,7 +423,7 b' class cg1unpacker(object):'
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.
@@ -443,9 +443,10 b' class cg1unpacker(object):'
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
@@ -458,9 +459,9 b' class cg1unpacker(object):'
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
@@ -510,21 +510,25 b' class phasecache(object):'
510 tr.addfilegenerator(b'phase', (b'phaseroots',), self._write)
510 tr.addfilegenerator(b'phase', (b'phaseroots',), self._write)
511 tr.hookargs[b'phases_moved'] = b'1'
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 repo = repo.unfiltered()
516 repo = repo.unfiltered()
515 self._retractboundary(repo, tr, targetphase, nodes)
517 self._retractboundary(repo, tr, targetphase, nodes, revs=revs)
516 if tr is not None and b'phases' in tr.changes:
518 if tr is not None and b'phases' in tr.changes:
517 phasetracking = tr.changes[b'phases']
519 phasetracking = tr.changes[b'phases']
518 torev = repo.changelog.rev
520 torev = repo.changelog.rev
519 phase = self.phase
521 phase = self.phase
520 revs = [torev(node) for node in nodes]
522 revs = [torev(node) for node in nodes] + sorted(revs)
521 revs.sort()
523 revs.sort()
522 for rev in revs:
524 for rev in revs:
523 revphase = phase(repo, rev)
525 revphase = phase(repo, rev)
524 _trackphasechange(phasetracking, rev, None, revphase)
526 _trackphasechange(phasetracking, rev, None, revphase)
525 repo.invalidatevolatilesets()
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 """Set all 'nodes' to phase 'targetphase'
532 """Set all 'nodes' to phase 'targetphase'
529
533
530 Nodes with a phase lower than 'targetphase' are not affected.
534 Nodes with a phase lower than 'targetphase' are not affected.
@@ -535,26 +539,27 b' class phasecache(object):'
535 """
539 """
536 # Be careful to preserve shallow-copied values: do not update
540 # Be careful to preserve shallow-copied values: do not update
537 # phaseroots values, replace them.
541 # phaseroots values, replace them.
542 if revs is None:
543 revs = []
538 if tr is None:
544 if tr is None:
539 phasetracking = None
545 phasetracking = None
540 else:
546 else:
541 phasetracking = tr.changes.get(b'phases')
547 phasetracking = tr.changes.get(b'phases')
542
548
543 repo = repo.unfiltered()
549 repo = repo.unfiltered()
550 revs = [repo[n].rev() for n in nodes] + [r for r in revs]
544
551
545 changes = set() # set of revisions to be changed
552 changes = set() # set of revisions to be changed
546 delroots = [] # set of root deleted by this path
553 delroots = [] # set of root deleted by this path
547 for phase in (phase for phase in allphases if phase > targetphase):
554 for phase in (phase for phase in allphases if phase > targetphase):
548 # filter nodes that are not in a compatible phase already
555 # filter nodes that are not in a compatible phase already
549 nodes = [
556 revs = [rev for rev in revs if self.phase(repo, rev) >= phase]
550 n for n in nodes if self.phase(repo, repo[n].rev()) >= phase
557 if not revs:
551 ]
552 if not nodes:
553 break # no roots to move anymore
558 break # no roots to move anymore
554
559
555 olds = self.phaseroots[phase]
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 changes.update(affected)
563 changes.update(affected)
559 if dryrun:
564 if dryrun:
560 continue
565 continue
@@ -611,9 +616,11 b' class phasecache(object):'
611 _trackphasechange(phasetracking, r, phase, targetphase)
616 _trackphasechange(phasetracking, r, phase, targetphase)
612 repo.invalidatevolatilesets()
617 repo.invalidatevolatilesets()
613
618
614 def _retractboundary(self, repo, tr, targetphase, nodes):
619 def _retractboundary(self, repo, tr, targetphase, nodes, revs=None):
615 # Be careful to preserve shallow-copied values: do not update
620 # Be careful to preserve shallow-copied values: do not update
616 # phaseroots values, replace them.
621 # phaseroots values, replace them.
622 if revs is None:
623 revs = []
617 if targetphase in (archived, internal) and not supportinternal(repo):
624 if targetphase in (archived, internal) and not supportinternal(repo):
618 name = phasenames[targetphase]
625 name = phasenames[targetphase]
619 msg = b'this repository does not support the %s phase' % name
626 msg = b'this repository does not support the %s phase' % name
@@ -624,7 +631,7 b' class phasecache(object):'
624 tonode = repo.changelog.node
631 tonode = repo.changelog.node
625 currentroots = {torev(node) for node in self.phaseroots[targetphase]}
632 currentroots = {torev(node) for node in self.phaseroots[targetphase]}
626 finalroots = oldroots = set(currentroots)
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 newroots = [
635 newroots = [
629 rev for rev in newroots if self.phase(repo, rev) < targetphase
636 rev for rev in newroots if self.phase(repo, rev) < targetphase
630 ]
637 ]
@@ -679,7 +686,7 b' class phasecache(object):'
679 self.invalidate()
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 """Add nodes to a phase changing other nodes phases if necessary.
690 """Add nodes to a phase changing other nodes phases if necessary.
684
691
685 This function move boundary *forward* this means that all nodes
692 This function move boundary *forward* this means that all nodes
@@ -691,9 +698,11 b' def advanceboundary(repo, tr, targetphas'
691
698
692 Returns a set of revs whose phase is changed or should be changed
699 Returns a set of revs whose phase is changed or should be changed
693 """
700 """
701 if revs is None:
702 revs = []
694 phcache = repo._phasecache.copy()
703 phcache = repo._phasecache.copy()
695 changes = phcache.advanceboundary(
704 changes = phcache.advanceboundary(
696 repo, tr, targetphase, nodes, dryrun=dryrun
705 repo, tr, targetphase, nodes, revs=revs, dryrun=dryrun
697 )
706 )
698 if not dryrun:
707 if not dryrun:
699 repo._phasecache.replace(phcache)
708 repo._phasecache.replace(phcache)
@@ -713,14 +722,16 b' def retractboundary(repo, tr, targetphas'
713 repo._phasecache.replace(phcache)
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 """register a new revision and its phase
726 """register a new revision and its phase
718
727
719 Code adding revisions to the repository should use this function to
728 Code adding revisions to the repository should use this function to
720 set new changeset in their target phase (or higher).
729 set new changeset in their target phase (or higher).
721 """
730 """
731 if revs is None:
732 revs = []
722 phcache = repo._phasecache.copy()
733 phcache = repo._phasecache.copy()
723 phcache.registernew(repo, tr, targetphase, nodes)
734 phcache.registernew(repo, tr, targetphase, nodes, revs=revs)
724 repo._phasecache.replace(phcache)
735 repo._phasecache.replace(phcache)
725
736
726
737
General Comments 0
You need to be logged in to leave comments. Login now