mercurial/phases.py
changeset 15892 592b3d1742a1
parent 15821 e3ee8bf5d0cc
child 15902 4252d9f08d7e
equal deleted inserted replaced
15891:249d3420ec9c 15892:592b3d1742a1
   201 
   201 
   202 
   202 
   203 def listphases(repo):
   203 def listphases(repo):
   204     """List phases root for serialisation over pushkey"""
   204     """List phases root for serialisation over pushkey"""
   205     keys = {}
   205     keys = {}
   206     for phase in trackedphases:
   206     value = '%i' % draft
   207         for root in repo._phaseroots[phase]:
   207     for root in repo._phaseroots[draft]:
   208             keys[hex(root)] = '%i' % phase
   208         keys[hex(root)] = value
       
   209 
   209     if repo.ui.configbool('phases', 'publish', True):
   210     if repo.ui.configbool('phases', 'publish', True):
   210         # Add an extra data to let remote know we are a publishing repo.
   211         # Add an extra data to let remote know we are a publishing repo.
   211         # Publishing repo can't just pretend they are old repo. When pushing to
   212         # Publishing repo can't just pretend they are old repo. When pushing to
   212         # a publishing repo, the client still need to push phase boundary
   213         # a publishing repo, the client still need to push phase boundary
   213         #
   214         #
   262     * roots is {<nodeid> => phase} mapping. key and value are string.
   263     * roots is {<nodeid> => phase} mapping. key and value are string.
   263 
   264 
   264     Accept unknown element input
   265     Accept unknown element input
   265     """
   266     """
   266     # build list from dictionary
   267     # build list from dictionary
   267     phaseroots = [[] for p in allphases]
   268     draftroots = []
       
   269     nm = repo.changelog.nodemap # to filter unknown node
   268     for nhex, phase in roots.iteritems():
   270     for nhex, phase in roots.iteritems():
   269         if nhex == 'publishing': # ignore data related to publish option
   271         if nhex == 'publishing': # ignore data related to publish option
   270             continue
   272             continue
   271         node = bin(nhex)
   273         node = bin(nhex)
   272         phase = int(phase)
   274         phase = int(phase)
   273         if node in repo:
   275         if phase == 0:
   274             phaseroots[phase].append(node)
   276             if node != nullid:
       
   277                 msg = _('ignoring inconsistense public root from remote: %s')
       
   278                 repo.ui.warn(msg, nhex)
       
   279         elif phase == 1:
       
   280             if node in nm:
       
   281                 draftroots.append(node)
       
   282         else:
       
   283             msg = _('ignoring unexpected root from remote: %i %s')
       
   284             repo.ui.warn(msg, phase, nhex)
   275     # compute heads
   285     # compute heads
   276     phaseheads = [[] for p in allphases]
   286     revset = repo.set('heads((%ln + parents(%ln)) - (%ln::%ln))',
   277     for phase in allphases[:-1]:
   287                       subset, draftroots, draftroots, subset)
   278         toproof = phaseroots[phase + 1]
   288     publicheads = [c.node() for c in revset]
   279         revset = repo.set('heads((%ln + parents(%ln)) - (%ln::%ln))',
   289     return publicheads, draftroots
   280                           subset, toproof, toproof, subset)
   290 
   281         phaseheads[phase].extend(c.node() for c in revset)
       
   282     return phaseheads, phaseroots
       
   283