push: move `remoteheads` into the push object
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 30 Jan 2014 20:34:35 -0800
changeset 20462 0031ef5df586
parent 20461 abd8e56a1038
child 20463 f1b532a310e4
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.
mercurial/exchange.py
--- a/mercurial/exchange.py	Tue Feb 04 15:07:03 2014 -0800
+++ b/mercurial/exchange.py	Thu Jan 30 20:34:35 2014 -0800
@@ -44,6 +44,8 @@
         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
@@ -104,6 +106,7 @@
             outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs,
                            commoninc=commoninc, force=pushop.force)
             pushop.outgoing = outgoing
+            pushop.remoteheads = remoteheads
 
 
             if not outgoing.missing:
@@ -163,6 +166,8 @@
                     # 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,