Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Jan 19 11:30:37 2012 +0100 +++ b/mercurial/localrepo.py Thu Jan 19 15:50:55 2012 +0100 @@ -1606,26 +1606,59 @@ # get local lock as we might write phase data locallock = self.lock() try: - cg, remote_heads, fut = discovery.prepush(self, remote, force, - revs, newbranch) - ret = remote_heads - # create a callback for addchangegroup. - # If will be used branch of the conditionnal too. - if cg is not None: + # discovery + fci = discovery.findcommonincoming + commoninc = fci(self, remote, force=force) + common, inc, remoteheads = commoninc + fco = discovery.findcommonoutgoing + outgoing = fco(self, remote, onlyheads=revs, + commoninc=commoninc, force=force) + + + if not outgoing.missing: + # nothing to push + if outgoing.excluded: + msg = "no changes to push but %i secret changesets\n" + self.ui.status(_(msg) % len(outgoing.excluded)) + else: + self.ui.status(_("no changes found\n")) + fut = outgoing.common + ret = 1 + else: + # something to push + if not force: + discovery.checkheads(self, remote, outgoing, + remoteheads, newbranch) + + # create a changegroup from local + if revs is None and not outgoing.excluded: + # push everything, + # use the fast path, no race possible on push + cg = self._changegroup(outgoing.missing, 'push') + else: + cg = self.getlocalbundle('push', outgoing) + + # apply changegroup to remote if unbundle: # local repo finds heads on server, finds out what # revs it must push. once revs transferred, if server # finds it has different heads (someone else won # commit/push race), server aborts. if force: - remote_heads = ['force'] + remoteheads = ['force'] # ssh: return remote's addchangegroup() # http: return remote's addchangegroup() or 0 for error - ret = remote.unbundle(cg, remote_heads, 'push') + ret = remote.unbundle(cg, remoteheads, 'push') else: # we return an integer indicating remote head count change ret = remote.addchangegroup(cg, 'push', self.url()) + # compute what should be the now common + # + # XXX If push failed we should use strict common and not + # future to avoid pushing phase data on unknown changeset. + # This is to done later. + fut = outgoing.commonheads + outgoing.missingheads # even when we don't push, exchanging phase data is useful remotephases = remote.listkeys('phases') if not remotephases: # old server or public only repo @@ -1641,10 +1674,6 @@ phases.advanceboundary(self, phases.public, pheads) phases.advanceboundary(self, phases.draft, fut) ### Apply local phase on remote - # - # XXX If push failed we should use strict common and not - # future to avoid pushing phase data on unknown changeset. - # This is to done later. # Get the list of all revs draft on remote by public here. # XXX Beware that revset break if droots is not strictly