[PATCH 1 of 7 (push is done; 12 more to go for pull)] push: move `remoteheads` into the push object

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Tue Feb 11 15:32:51 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1391142875 28800
#      Thu Jan 30 20:34:35 2014 -0800
# Node ID 783539ede731dee892842d1d07d27e8be95f8fa3
# Parent  1478a9ce679097c03234201d179e48c58d0b5c1d
push: move `remoteheads` into the push object

The heads of the remote repository are used to detect race when pushing
changeset. We now store this information in `pushoperation` object  to allow
extraction of the changeset pushing part.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -42,10 +42,12 @@ class pushoperation(object):
         #   we have outgoing changesets but refused to push
         # - other values as described by addchangegroup()
         self.ret = None
         # discover.outgoing object (contains common and outgoin data)
         self.outgoing = None
+        # all remote heads before the push
+        self.remoteheads = None
 
 def push(repo, remote, force=False, revs=None, newbranch=False):
     '''Push outgoing changesets (limited by revs) from a local
     repository to remote. Return an integer:
       - None means nothing to push
@@ -102,10 +104,11 @@ def push(repo, remote, force=False, revs
             common, inc, remoteheads = commoninc
             fco = discovery.findcommonoutgoing
             outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs,
                            commoninc=commoninc, force=pushop.force)
             pushop.outgoing = outgoing
+            pushop.remoteheads = remoteheads
 
 
             if not outgoing.missing:
                 # nothing to push
                 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded)
@@ -161,10 +164,12 @@ def push(repo, remote, force=False, revs
                     # revs it must push. once revs transferred, if server
                     # finds it has different heads (someone else won
                     # commit/push race), server aborts.
                     if pushop.force:
                         remoteheads = ['force']
+                    else:
+                        remoteheads = pushop.remoteheads
                     # ssh: return remote's addchangegroup()
                     # http: return remote's addchangegroup() or 0 for error
                     pushop.ret = pushop.remote.unbundle(cg, remoteheads,
                                                         'push')
                 else:


More information about the Mercurial-devel mailing list