619 def _pushdiscoveryphase(pushop): |
619 def _pushdiscoveryphase(pushop): |
620 """discover the phase that needs to be pushed |
620 """discover the phase that needs to be pushed |
621 |
621 |
622 (computed for both success and failure case for changesets push)""" |
622 (computed for both success and failure case for changesets push)""" |
623 outgoing = pushop.outgoing |
623 outgoing = pushop.outgoing |
624 unfi = pushop.repo.unfiltered() |
624 repo = pushop.repo |
625 to_rev = unfi.changelog.index.rev |
625 unfi = repo.unfiltered() |
|
626 cl = unfi.changelog |
|
627 to_rev = cl.index.rev |
626 remotephases = listkeys(pushop.remote, b'phases') |
628 remotephases = listkeys(pushop.remote, b'phases') |
627 |
629 |
628 if ( |
630 if ( |
629 pushop.ui.configbool(b'ui', b'_usedassubrepo') |
631 pushop.ui.configbool(b'ui', b'_usedassubrepo') |
630 and remotephases # server supports phases |
632 and remotephases # server supports phases |
642 # on the remote. |
644 # on the remote. |
643 pushop.outdatedphases = [] |
645 pushop.outdatedphases = [] |
644 pushop.fallbackoutdatedphases = [] |
646 pushop.fallbackoutdatedphases = [] |
645 return |
647 return |
646 |
648 |
647 fallbackheads_rev = [to_rev(n) for n in pushop.fallbackheads] |
649 fallbackheads_rev = {to_rev(n) for n in pushop.fallbackheads} |
648 futureheads_rev = [to_rev(n) for n in pushop.futureheads] |
|
649 |
|
650 pushop.remotephases = phases.RemotePhasesSummary( |
650 pushop.remotephases = phases.RemotePhasesSummary( |
651 pushop.repo, |
651 pushop.repo, |
652 fallbackheads_rev, |
652 fallbackheads_rev, |
653 remotephases, |
653 remotephases, |
654 ) |
654 ) |
655 droots = pushop.remotephases.draft_roots |
655 droots = set(pushop.remotephases.draft_roots) |
656 |
656 |
657 extracond = b'' |
657 fallback_publishing = pushop.remotephases.publishing |
658 if not pushop.remotephases.publishing: |
658 push_publishing = pushop.remotephases.publishing or pushop.publish |
659 extracond = b' and public()' |
659 missing_revs = {to_rev(n) for n in outgoing.missing} |
660 revset = b'heads((%%ld::%%ld) %s)' % extracond |
660 drafts = unfi._phasecache.get_raw_set(unfi, phases.draft) |
661 # Get the list of all revs draft on remote by public here. |
661 |
662 # XXX Beware that revset break if droots is not strictly |
662 if fallback_publishing: |
663 # XXX root we may want to ensure it is but it is costly |
663 fallback_roots = droots - missing_revs |
664 fallback = list(unfi.set(revset, droots, fallbackheads_rev)) |
664 revset = b'heads(%ld::%ld)' |
665 if not pushop.remotephases.publishing and pushop.publish: |
|
666 future = list( |
|
667 unfi.set( |
|
668 b'%ld and (not public() or %ld::)', futureheads_rev, droots |
|
669 ) |
|
670 ) |
|
671 elif not outgoing.missing: |
|
672 future = fallback |
|
673 else: |
665 else: |
674 # adds changeset we are going to push as draft |
666 fallback_roots = droots - drafts |
675 # |
667 fallback_roots -= missing_revs |
676 # should not be necessary for publishing server, but because of an |
668 # Get the list of all revs draft on remote but public here. |
677 # issue fixed in xxxxx we have to do it anyway. |
669 revset = b'heads((%ld::%ld) and public())' |
678 missing_rev = [to_rev(n) for n in outgoing.missing] |
670 if not fallback_roots: |
679 fdroots = list(unfi.set(b'roots(%ld + %ld::)', missing_rev, droots)) |
671 fallback = fallback_rev = [] |
680 fdroots = [f.rev() for f in fdroots] |
672 else: |
681 future = list(unfi.set(revset, fdroots, futureheads_rev)) |
673 fallback_rev = unfi.revs(revset, fallback_roots, fallbackheads_rev) |
682 pushop.outdatedphases = future |
674 fallback = [repo[r] for r in fallback_rev] |
|
675 |
|
676 if push_publishing: |
|
677 published = missing_revs.copy() |
|
678 else: |
|
679 published = missing_revs - drafts |
|
680 if pushop.publish: |
|
681 published.update(fallbackheads_rev & drafts) |
|
682 elif fallback: |
|
683 published.update(fallback_rev) |
|
684 |
|
685 pushop.outdatedphases = [repo[r] for r in cl.headrevs(published)] |
683 pushop.fallbackoutdatedphases = fallback |
686 pushop.fallbackoutdatedphases = fallback |
684 |
687 |
685 |
688 |
686 @pushdiscovery(b'obsmarker') |
689 @pushdiscovery(b'obsmarker') |
687 def _pushdiscoveryobsmarkers(pushop): |
690 def _pushdiscoveryobsmarkers(pushop): |