mercurial/exchange.py
changeset 51583 22cc679a7312
parent 51581 e0194b3ea312
child 51584 5b99b64328f2
equal deleted inserted replaced
51582:d8287e43540f 51583:22cc679a7312
   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     unfi = pushop.repo.unfiltered()
       
   625     to_rev = unfi.changelog.index.rev
   625     remotephases = listkeys(pushop.remote, b'phases')
   626     remotephases = listkeys(pushop.remote, b'phases')
   626 
   627 
   627     if (
   628     if (
   628         pushop.ui.configbool(b'ui', b'_usedassubrepo')
   629         pushop.ui.configbool(b'ui', b'_usedassubrepo')
   629         and remotephases  # server supports phases
   630         and remotephases  # server supports phases
   641         # on the remote.
   642         # on the remote.
   642         pushop.outdatedphases = []
   643         pushop.outdatedphases = []
   643         pushop.fallbackoutdatedphases = []
   644         pushop.fallbackoutdatedphases = []
   644         return
   645         return
   645 
   646 
   646     pushop.remotephases = phases.remotephasessummary(
   647     fallbackheads_rev = [to_rev(n) for n in pushop.fallbackheads]
   647         pushop.repo, pushop.fallbackheads, remotephases
   648 
       
   649     pushop.remotephases = phases.RemotePhasesSummary(
       
   650         pushop.repo,
       
   651         fallbackheads_rev,
       
   652         remotephases,
   648     )
   653     )
   649     droots = pushop.remotephases.draftroots
   654     droots = pushop.remotephases.draft_roots
   650 
   655 
   651     extracond = b''
   656     extracond = b''
   652     if not pushop.remotephases.publishing:
   657     if not pushop.remotephases.publishing:
   653         extracond = b' and public()'
   658         extracond = b' and public()'
   654     revset = b'heads((%%ln::%%ln) %s)' % extracond
   659     revset = b'heads((%%ld::%%ln) %s)' % extracond
   655     # Get the list of all revs draft on remote by public here.
   660     # Get the list of all revs draft on remote by public here.
   656     # XXX Beware that revset break if droots is not strictly
   661     # XXX Beware that revset break if droots is not strictly
   657     # XXX root we may want to ensure it is but it is costly
   662     # XXX root we may want to ensure it is but it is costly
   658     fallback = list(unfi.set(revset, droots, pushop.fallbackheads))
   663     fallback = list(unfi.set(revset, droots, pushop.fallbackheads))
   659     if not pushop.remotephases.publishing and pushop.publish:
   664     if not pushop.remotephases.publishing and pushop.publish:
   660         future = list(
   665         future = list(
   661             unfi.set(
   666             unfi.set(
   662                 b'%ln and (not public() or %ln::)', pushop.futureheads, droots
   667                 b'%ln and (not public() or %ld::)', pushop.futureheads, droots
   663             )
   668             )
   664         )
   669         )
   665     elif not outgoing.missing:
   670     elif not outgoing.missing:
   666         future = fallback
   671         future = fallback
   667     else:
   672     else:
   668         # adds changeset we are going to push as draft
   673         # adds changeset we are going to push as draft
   669         #
   674         #
   670         # should not be necessary for publishing server, but because of an
   675         # should not be necessary for publishing server, but because of an
   671         # issue fixed in xxxxx we have to do it anyway.
   676         # issue fixed in xxxxx we have to do it anyway.
   672         fdroots = list(
   677         fdroots = list(
   673             unfi.set(b'roots(%ln  + %ln::)', outgoing.missing, droots)
   678             unfi.set(b'roots(%ln  + %ld::)', outgoing.missing, droots)
   674         )
   679         )
   675         fdroots = [f.node() for f in fdroots]
   680         fdroots = [f.rev() for f in fdroots]
   676         future = list(unfi.set(revset, fdroots, pushop.futureheads))
   681         future = list(unfi.set(revset, fdroots, pushop.futureheads))
   677     pushop.outdatedphases = future
   682     pushop.outdatedphases = future
   678     pushop.fallbackoutdatedphases = fallback
   683     pushop.fallbackoutdatedphases = fallback
   679 
   684 
   680 
   685 
   901     b2caps = bundle2.bundle2caps(pushop.remote)
   906     b2caps = bundle2.bundle2caps(pushop.remote)
   902     hasphaseheads = b'heads' in b2caps.get(b'phases', ())
   907     hasphaseheads = b'heads' in b2caps.get(b'phases', ())
   903     if pushop.remotephases is not None and hasphaseheads:
   908     if pushop.remotephases is not None and hasphaseheads:
   904         # check that the remote phase has not changed
   909         # check that the remote phase has not changed
   905         checks = {p: [] for p in phases.allphases}
   910         checks = {p: [] for p in phases.allphases}
   906         checks[phases.public].extend(pushop.remotephases.publicheads)
   911         to_node = pushop.repo.unfiltered().changelog.node
   907         checks[phases.draft].extend(pushop.remotephases.draftroots)
   912         checks[phases.public].extend(
       
   913             to_node(r) for r in pushop.remotephases.public_heads
       
   914         )
       
   915         checks[phases.draft].extend(
       
   916             to_node(r) for r in pushop.remotephases.draft_roots
       
   917         )
   908         if any(checks.values()):
   918         if any(checks.values()):
   909             for phase in checks:
   919             for phase in checks:
   910                 checks[phase].sort()
   920                 checks[phase].sort()
   911             checkdata = phases.binaryencode(checks)
   921             checkdata = phases.binaryencode(checks)
   912             bundler.newpart(b'check:phases', data=checkdata)
   922             bundler.newpart(b'check:phases', data=checkdata)