Mercurial > hg-stable
comparison mercurial/exchange.py @ 20440:400da8bc7786
push: move outgoing object in the push object
The set of outgoing and common changeset are used by phases to compute the new
common set between local and remote. So we need to move it into the object to
extract the phase sync from the god function.
Note that this information will be used by obsolescence markers too.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 30 Jan 2014 20:18:26 -0800 |
parents | 0d3ccf285ff2 |
children | eca9d5375606 |
comparison
equal
deleted
inserted
replaced
20439:0d3ccf285ff2 | 20440:400da8bc7786 |
---|---|
40 # - 0 means HTTP error | 40 # - 0 means HTTP error |
41 # - 1 means we pushed and remote head count is unchanged *or* | 41 # - 1 means we pushed and remote head count is unchanged *or* |
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) | |
46 self.outgoing = None | |
45 | 47 |
46 def push(repo, remote, force=False, revs=None, newbranch=False): | 48 def push(repo, remote, force=False, revs=None, newbranch=False): |
47 '''Push outgoing changesets (limited by revs) from a local | 49 '''Push outgoing changesets (limited by revs) from a local |
48 repository to remote. Return an integer: | 50 repository to remote. Return an integer: |
49 - None means nothing to push | 51 - None means nothing to push |
99 commoninc = fci(unfi, pushop.remote, force=pushop.force) | 101 commoninc = fci(unfi, pushop.remote, force=pushop.force) |
100 common, inc, remoteheads = commoninc | 102 common, inc, remoteheads = commoninc |
101 fco = discovery.findcommonoutgoing | 103 fco = discovery.findcommonoutgoing |
102 outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs, | 104 outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs, |
103 commoninc=commoninc, force=pushop.force) | 105 commoninc=commoninc, force=pushop.force) |
106 pushop.outgoing = outgoing | |
104 | 107 |
105 | 108 |
106 if not outgoing.missing: | 109 if not outgoing.missing: |
107 # nothing to push | 110 # nothing to push |
108 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded) | 111 scmutil.nochangesfound(unfi.ui, unfi, outgoing.excluded) |
170 pushop.ret = pushop.remote.addchangegroup(cg, 'push', | 173 pushop.ret = pushop.remote.addchangegroup(cg, 'push', |
171 pushop.repo.url()) | 174 pushop.repo.url()) |
172 | 175 |
173 if pushop.ret: | 176 if pushop.ret: |
174 # push succeed, synchronize target of the push | 177 # push succeed, synchronize target of the push |
175 cheads = outgoing.missingheads | 178 cheads = pushop.outgoing.missingheads |
176 elif pushop.revs is None: | 179 elif pushop.revs is None: |
177 # All out push fails. synchronize all common | 180 # All out push fails. synchronize all common |
178 cheads = outgoing.commonheads | 181 cheads = pushop.outgoing.commonheads |
179 else: | 182 else: |
180 # I want cheads = heads(::missingheads and ::commonheads) | 183 # I want cheads = heads(::missingheads and ::commonheads) |
181 # (missingheads is revs with secret changeset filtered out) | 184 # (missingheads is revs with secret changeset filtered out) |
182 # | 185 # |
183 # This can be expressed as: | 186 # This can be expressed as: |
189 # common = (::commonheads) | 192 # common = (::commonheads) |
190 # missing = ((commonheads::missingheads) - commonheads) | 193 # missing = ((commonheads::missingheads) - commonheads) |
191 # | 194 # |
192 # We can pick: | 195 # We can pick: |
193 # * missingheads part of common (::commonheads) | 196 # * missingheads part of common (::commonheads) |
194 common = set(outgoing.common) | 197 common = set(pushop.outgoing.common) |
195 nm = pushop.repo.changelog.nodemap | 198 nm = pushop.repo.changelog.nodemap |
196 cheads = [node for node in pushop.revs if nm[node] in common] | 199 cheads = [node for node in pushop.revs if nm[node] in common] |
197 # and | 200 # and |
198 # * commonheads parents on missing | 201 # * commonheads parents on missing |
199 revset = unfi.set('%ln and parents(roots(%ln))', | 202 revset = unfi.set('%ln and parents(roots(%ln))', |
200 outgoing.commonheads, | 203 pushop.outgoing.commonheads, |
201 outgoing.missing) | 204 pushop.outgoing.missing) |
202 cheads.extend(c.node() for c in revset) | 205 cheads.extend(c.node() for c in revset) |
203 # even when we don't push, exchanging phase data is useful | 206 # even when we don't push, exchanging phase data is useful |
204 remotephases = pushop.remote.listkeys('phases') | 207 remotephases = pushop.remote.listkeys('phases') |
205 if (pushop.ui.configbool('ui', '_usedassubrepo', False) | 208 if (pushop.ui.configbool('ui', '_usedassubrepo', False) |
206 and remotephases # server supports phases | 209 and remotephases # server supports phases |