From patchwork Wed Apr 17 15:58:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [14, of, 16] push: extract common heads computation in a dedicated method From: Pierre-Yves David X-Patchwork-Id: 1400 Message-Id: To: mercurial-devel@selenic.com Cc: pierre-yves.david@logilab.fr Date: Wed, 17 Apr 2013 17:58:49 +0200 # HG changeset patch # User Pierre-Yves David # Date 1366211583 -7200 # Wed Apr 17 17:13:03 2013 +0200 # Node ID ffde5609443882bd9249e613d861fae2e817f0d6 # Parent 99eb16416b76967917af430896db6628431951e0 push: extract common heads computation in a dedicated method diff --git a/mercurial/exchangeutil.py b/mercurial/exchangeutil.py --- a/mercurial/exchangeutil.py +++ b/mercurial/exchangeutil.py @@ -64,39 +64,12 @@ class pushoperation(object): scmutil.nochangesfound(unfi.ui, unfi, self._outgoing.excluded) else: self._ret = self._pushbundle() - if self._ret: - # push succeed, synchronize target of the push - cheads = self._outgoing.missingheads - elif self.revs is None: - # All out push fails. synchronize all common - cheads = self._outgoing.commonheads - else: - # I want cheads = heads(::missingheads and ::commonheads) - # (missingheads is revs with secret changeset filtered out) - # - # This can be expressed as: - # cheads = ( (missingheads and ::commonheads) - # + (commonheads and ::missingheads))" - # ) - # - # while trying to push we already computed the following: - # common = (::commonheads) - # missing = ((commonheads::missingheads) - commonheads) - # - # We can pick: - # * missingheads part of common (::commonheads) - common = set(self._outgoing.common) - cheads = [node for node in self.revs if node in common] - # and - # * commonheads parents on missing - revset = unfi.set('%ln and parents(roots(%ln))', - self._outgoing.commonheads, - self._outgoing.missing) - cheads.extend(c.node() for c in revset) + heads = self._findcommonheads() + # even when we don't push, exchanging phase data is useful remotephases = remote.listkeys('phases') if (repo.ui.configbool('ui', '_usedassubrepo', False) and remotephases # server supports phases and self._ret is None # nothing was pushed @@ -211,10 +184,42 @@ class pushoperation(object): else: # we return an integer indicating remote head count # change return self.remote.addchangegroup(cg, 'push', self.repo.url()) + def _findcommonheads(self): + if self._ret: + # push succeed, synchronize target of the push + cheads = self._outgoing.missingheads + elif self.revs is None: + # All out push fails. synchronize all common + cheads = self._outgoing.commonheads + else: + # I want cheads = heads(::missingheads and ::commonheads) + # (missingheads is revs with secret changeset filtered out) + # + # This can be expressed as: + # cheads = ( (missingheads and ::commonheads) + # + (commonheads and ::missingheads))" + # ) + # + # while trying to push we already computed the following: + # common = (::commonheads) + # missing = ((commonheads::missingheads) - commonheads) + # + # We can pick: + # * missingheads part of common (::commonheads) + common = set(self._outgoing.common) + cheads = [node for node in self.revs if node in common] + # and + # * commonheads parents on missing + unfi = self.repo.unfiltered() + revset = unfi.set('%ln and parents(roots(%ln))', + self._outgoing.commonheads, + self._outgoing.missing) + cheads.extend(c.node() for c in revset) + return cheads def _pushobsolescence(self): """Send local obsolescence marker to remote"""