Patchwork [14,of,16] push: extract common heads computation in a dedicated method

login
register
mail settings
Submitter Pierre-Yves David
Date April 17, 2013, 3:58 p.m.
Message ID <ffde5609443882bd9249.1366214329@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/1400/
State Deferred, archived
Headers show

Comments

Pierre-Yves David - April 17, 2013, 3:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# 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

Patch

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"""