Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 15651:e69a3cdad37e
phases: exchange phase boundaries on push
For now phase sync is tried even if push fails with some know pathological
case. The exact behavior is to be discussed and implemented later.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 15 Dec 2011 11:45:01 +0100 |
parents | 5b26667fc4d3 |
children | 7fba5a245acc |
comparison
equal
deleted
inserted
replaced
15650:5b26667fc4d3 | 15651:e69a3cdad37e |
---|---|
1585 locallock = self.lock() | 1585 locallock = self.lock() |
1586 try: | 1586 try: |
1587 cg, remote_heads, fut = discovery.prepush(self, remote, force, | 1587 cg, remote_heads, fut = discovery.prepush(self, remote, force, |
1588 revs, newbranch) | 1588 revs, newbranch) |
1589 ret = remote_heads | 1589 ret = remote_heads |
1590 # create a callback for addchangegroup. | |
1591 # If will be used branch of the conditionnal too. | |
1590 if cg is not None: | 1592 if cg is not None: |
1591 if unbundle: | 1593 if unbundle: |
1592 # local repo finds heads on server, finds out what | 1594 # local repo finds heads on server, finds out what |
1593 # revs it must push. once revs transferred, if server | 1595 # revs it must push. once revs transferred, if server |
1594 # finds it has different heads (someone else won | 1596 # finds it has different heads (someone else won |
1599 # http: return remote's addchangegroup() or 0 for error | 1601 # http: return remote's addchangegroup() or 0 for error |
1600 ret = remote.unbundle(cg, remote_heads, 'push') | 1602 ret = remote.unbundle(cg, remote_heads, 'push') |
1601 else: | 1603 else: |
1602 # we return an integer indicating remote head count change | 1604 # we return an integer indicating remote head count change |
1603 ret = remote.addchangegroup(cg, 'push', self.url()) | 1605 ret = remote.addchangegroup(cg, 'push', self.url()) |
1604 # if we don't push, the common data is already useful | 1606 |
1605 # everything exchange is public for now | 1607 # even when we don't push, exchanging phase data is useful |
1606 phases.advanceboundary(self, 0, fut) | 1608 remotephases = remote.listkeys('phases') |
1609 if not remotephases: # old server or public only repo | |
1610 phases.advanceboundary(self, 0, fut) | |
1611 # don't push any phase data as there is nothing to push | |
1612 else: | |
1613 ana = phases.analyzeremotephases(self, fut, remotephases) | |
1614 rheads, rroots = ana | |
1615 ### Apply remote phase on local | |
1616 if remotephases.get('publishing', False): | |
1617 phases.advanceboundary(self, 0, fut) | |
1618 else: # publish = False | |
1619 for phase, rpheads in enumerate(rheads): | |
1620 phases.advanceboundary(self, phase, rpheads) | |
1621 ### Apply local phase on remote | |
1622 # | |
1623 # XXX If push failed we should use strict common and not | |
1624 # future to avoir pushing phase data on unknown changeset. | |
1625 # This is to done later. | |
1626 futctx = [self[n] for n in fut if n != nullid] | |
1627 for phase in phases.trackedphases[::-1]: | |
1628 prevphase = phase -1 | |
1629 # get all candidate for head in previous phase | |
1630 inprev = [ctx for ctx in futctx | |
1631 if ctx.phase() == prevphase] | |
1632 for newremotehead in self.set('heads(%ld & (%ln::))', | |
1633 inprev, rroots[phase]): | |
1634 r = remote.pushkey('phases', | |
1635 newremotehead.hex(), | |
1636 str(phase), str(prevphase)) | |
1637 if not r: | |
1638 self.ui.warn(_('updating phase of %s' | |
1639 'to %s failed!\n') | |
1640 % (newremotehead, prevphase)) | |
1607 finally: | 1641 finally: |
1608 locallock.release() | 1642 locallock.release() |
1609 finally: | 1643 finally: |
1610 if lock is not None: | 1644 if lock is not None: |
1611 lock.release() | 1645 lock.release() |