Mercurial > hg
comparison mercurial/exchange.py @ 20462:0031ef5df586
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.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 30 Jan 2014 20:34:35 -0800 |
parents | eca9d5375606 |
children | f1b532a310e4 |
comparison
equal
deleted
inserted
replaced
20461:abd8e56a1038 | 20462:0031ef5df586 |
---|---|
42 # we have outgoing changesets but refused to push | 42 # we have outgoing changesets but refused to push |
43 # - other values as described by addchangegroup() | 43 # - other values as described by addchangegroup() |
44 self.ret = None | 44 self.ret = None |
45 # discover.outgoing object (contains common and outgoin data) | 45 # discover.outgoing object (contains common and outgoin data) |
46 self.outgoing = None | 46 self.outgoing = None |
47 # all remote heads before the push | |
48 self.remoteheads = None | |
47 | 49 |
48 def push(repo, remote, force=False, revs=None, newbranch=False): | 50 def push(repo, remote, force=False, revs=None, newbranch=False): |
49 '''Push outgoing changesets (limited by revs) from a local | 51 '''Push outgoing changesets (limited by revs) from a local |
50 repository to remote. Return an integer: | 52 repository to remote. Return an integer: |
51 - None means nothing to push | 53 - None means nothing to push |
102 common, inc, remoteheads = commoninc | 104 common, inc, remoteheads = commoninc |
103 fco = discovery.findcommonoutgoing | 105 fco = discovery.findcommonoutgoing |
104 outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs, | 106 outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs, |
105 commoninc=commoninc, force=pushop.force) | 107 commoninc=commoninc, force=pushop.force) |
106 pushop.outgoing = outgoing | 108 pushop.outgoing = outgoing |
109 pushop.remoteheads = remoteheads | |
107 | 110 |
108 | 111 |
109 if not outgoing.missing: | 112 if not outgoing.missing: |
110 # nothing to push | 113 # nothing to push |
111 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded) | 114 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded) |
161 # revs it must push. once revs transferred, if server | 164 # revs it must push. once revs transferred, if server |
162 # finds it has different heads (someone else won | 165 # finds it has different heads (someone else won |
163 # commit/push race), server aborts. | 166 # commit/push race), server aborts. |
164 if pushop.force: | 167 if pushop.force: |
165 remoteheads = ['force'] | 168 remoteheads = ['force'] |
169 else: | |
170 remoteheads = pushop.remoteheads | |
166 # ssh: return remote's addchangegroup() | 171 # ssh: return remote's addchangegroup() |
167 # http: return remote's addchangegroup() or 0 for error | 172 # http: return remote's addchangegroup() or 0 for error |
168 pushop.ret = pushop.remote.unbundle(cg, remoteheads, | 173 pushop.ret = pushop.remote.unbundle(cg, remoteheads, |
169 'push') | 174 'push') |
170 else: | 175 else: |