Mercurial > hg
comparison mercurial/localrepo.py @ 15932:4154338f0bc0
discovery: diet discovery.prepush from non-discovery code
The ``discovery.prepush`` function was doing multiple things not related to
discovery. This changeset move some code into the ``localrepo.push`` method. The
old ``discovery.prepush`` function jobs is now restricted to checking for
multple head creation. It was then renamed ``discovery.checkheads``.
This new ``discovery.checkheads`` function may receive several other changes in
the future but we are a bit too much near the freeze for a wider refactoring.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 19 Jan 2012 15:50:55 +0100 |
parents | 4091660dc130 |
children | b8696a6676be |
comparison
equal
deleted
inserted
replaced
15931:44b5de2d1876 | 15932:4154338f0bc0 |
---|---|
1604 lock = remote.lock() | 1604 lock = remote.lock() |
1605 try: | 1605 try: |
1606 # get local lock as we might write phase data | 1606 # get local lock as we might write phase data |
1607 locallock = self.lock() | 1607 locallock = self.lock() |
1608 try: | 1608 try: |
1609 cg, remote_heads, fut = discovery.prepush(self, remote, force, | 1609 # discovery |
1610 revs, newbranch) | 1610 fci = discovery.findcommonincoming |
1611 ret = remote_heads | 1611 commoninc = fci(self, remote, force=force) |
1612 # create a callback for addchangegroup. | 1612 common, inc, remoteheads = commoninc |
1613 # If will be used branch of the conditionnal too. | 1613 fco = discovery.findcommonoutgoing |
1614 if cg is not None: | 1614 outgoing = fco(self, remote, onlyheads=revs, |
1615 commoninc=commoninc, force=force) | |
1616 | |
1617 | |
1618 if not outgoing.missing: | |
1619 # nothing to push | |
1620 if outgoing.excluded: | |
1621 msg = "no changes to push but %i secret changesets\n" | |
1622 self.ui.status(_(msg) % len(outgoing.excluded)) | |
1623 else: | |
1624 self.ui.status(_("no changes found\n")) | |
1625 fut = outgoing.common | |
1626 ret = 1 | |
1627 else: | |
1628 # something to push | |
1629 if not force: | |
1630 discovery.checkheads(self, remote, outgoing, | |
1631 remoteheads, newbranch) | |
1632 | |
1633 # create a changegroup from local | |
1634 if revs is None and not outgoing.excluded: | |
1635 # push everything, | |
1636 # use the fast path, no race possible on push | |
1637 cg = self._changegroup(outgoing.missing, 'push') | |
1638 else: | |
1639 cg = self.getlocalbundle('push', outgoing) | |
1640 | |
1641 # apply changegroup to remote | |
1615 if unbundle: | 1642 if unbundle: |
1616 # local repo finds heads on server, finds out what | 1643 # local repo finds heads on server, finds out what |
1617 # revs it must push. once revs transferred, if server | 1644 # revs it must push. once revs transferred, if server |
1618 # finds it has different heads (someone else won | 1645 # finds it has different heads (someone else won |
1619 # commit/push race), server aborts. | 1646 # commit/push race), server aborts. |
1620 if force: | 1647 if force: |
1621 remote_heads = ['force'] | 1648 remoteheads = ['force'] |
1622 # ssh: return remote's addchangegroup() | 1649 # ssh: return remote's addchangegroup() |
1623 # http: return remote's addchangegroup() or 0 for error | 1650 # http: return remote's addchangegroup() or 0 for error |
1624 ret = remote.unbundle(cg, remote_heads, 'push') | 1651 ret = remote.unbundle(cg, remoteheads, 'push') |
1625 else: | 1652 else: |
1626 # we return an integer indicating remote head count change | 1653 # we return an integer indicating remote head count change |
1627 ret = remote.addchangegroup(cg, 'push', self.url()) | 1654 ret = remote.addchangegroup(cg, 'push', self.url()) |
1628 | 1655 |
1656 # compute what should be the now common | |
1657 # | |
1658 # XXX If push failed we should use strict common and not | |
1659 # future to avoid pushing phase data on unknown changeset. | |
1660 # This is to done later. | |
1661 fut = outgoing.commonheads + outgoing.missingheads | |
1629 # even when we don't push, exchanging phase data is useful | 1662 # even when we don't push, exchanging phase data is useful |
1630 remotephases = remote.listkeys('phases') | 1663 remotephases = remote.listkeys('phases') |
1631 if not remotephases: # old server or public only repo | 1664 if not remotephases: # old server or public only repo |
1632 phases.advanceboundary(self, phases.public, fut) | 1665 phases.advanceboundary(self, phases.public, fut) |
1633 # don't push any phase data as there is nothing to push | 1666 # don't push any phase data as there is nothing to push |
1639 phases.advanceboundary(self, phases.public, fut) | 1672 phases.advanceboundary(self, phases.public, fut) |
1640 else: # publish = False | 1673 else: # publish = False |
1641 phases.advanceboundary(self, phases.public, pheads) | 1674 phases.advanceboundary(self, phases.public, pheads) |
1642 phases.advanceboundary(self, phases.draft, fut) | 1675 phases.advanceboundary(self, phases.draft, fut) |
1643 ### Apply local phase on remote | 1676 ### Apply local phase on remote |
1644 # | |
1645 # XXX If push failed we should use strict common and not | |
1646 # future to avoid pushing phase data on unknown changeset. | |
1647 # This is to done later. | |
1648 | 1677 |
1649 # Get the list of all revs draft on remote by public here. | 1678 # Get the list of all revs draft on remote by public here. |
1650 # XXX Beware that revset break if droots is not strictly | 1679 # XXX Beware that revset break if droots is not strictly |
1651 # XXX root we may want to ensure it is but it is costly | 1680 # XXX root we may want to ensure it is but it is costly |
1652 outdated = self.set('heads((%ln::%ln) and public())', | 1681 outdated = self.set('heads((%ln::%ln) and public())', |