Show More
@@ -21,10 +21,12 class pushoperation(object): | |||||
21 | afterward. |
|
21 | afterward. | |
22 | """ |
|
22 | """ | |
23 |
|
23 | |||
24 | def __init__(self, repo): |
|
24 | def __init__(self, repo, remote): | |
25 | # repo we push from |
|
25 | # repo we push from | |
26 | self.repo = repo |
|
26 | self.repo = repo | |
27 | self.ui = repo.ui |
|
27 | self.ui = repo.ui | |
|
28 | # repo we push to | |||
|
29 | self.remote = remote | |||
28 |
|
30 | |||
29 | def push(repo, remote, force=False, revs=None, newbranch=False): |
|
31 | def push(repo, remote, force=False, revs=None, newbranch=False): | |
30 | '''Push outgoing changesets (limited by revs) from a local |
|
32 | '''Push outgoing changesets (limited by revs) from a local | |
@@ -35,9 +37,10 def push(repo, remote, force=False, revs | |||||
35 | we have outgoing changesets but refused to push |
|
37 | we have outgoing changesets but refused to push | |
36 | - other values as described by addchangegroup() |
|
38 | - other values as described by addchangegroup() | |
37 | ''' |
|
39 | ''' | |
38 | pushop = pushoperation(repo) |
|
40 | pushop = pushoperation(repo, remote) | |
39 | if remote.local(): |
|
41 | if pushop.remote.local(): | |
40 |
missing = set(pushop.repo.requirements) |
|
42 | missing = (set(pushop.repo.requirements) | |
|
43 | - pushop.remote.local().supported) | |||
41 | if missing: |
|
44 | if missing: | |
42 | msg = _("required features are not" |
|
45 | msg = _("required features are not" | |
43 | " supported in the destination:" |
|
46 | " supported in the destination:" | |
@@ -52,7 +55,7 def push(repo, remote, force=False, revs | |||||
52 | # unbundle assumes local user cannot lock remote repo (new ssh |
|
55 | # unbundle assumes local user cannot lock remote repo (new ssh | |
53 | # servers, http servers). |
|
56 | # servers, http servers). | |
54 |
|
57 | |||
55 | if not remote.canpush(): |
|
58 | if not pushop.remote.canpush(): | |
56 | raise util.Abort(_("destination does not support push")) |
|
59 | raise util.Abort(_("destination does not support push")) | |
57 | unfi = pushop.repo.unfiltered() |
|
60 | unfi = pushop.repo.unfiltered() | |
58 | def localphasemove(nodes, phase=phases.public): |
|
61 | def localphasemove(nodes, phase=phases.public): | |
@@ -83,16 +86,16 def push(repo, remote, force=False, revs | |||||
83 | try: |
|
86 | try: | |
84 | pushop.repo.checkpush(force, revs) |
|
87 | pushop.repo.checkpush(force, revs) | |
85 | lock = None |
|
88 | lock = None | |
86 | unbundle = remote.capable('unbundle') |
|
89 | unbundle = pushop.remote.capable('unbundle') | |
87 | if not unbundle: |
|
90 | if not unbundle: | |
88 | lock = remote.lock() |
|
91 | lock = pushop.remote.lock() | |
89 | try: |
|
92 | try: | |
90 | # discovery |
|
93 | # discovery | |
91 | fci = discovery.findcommonincoming |
|
94 | fci = discovery.findcommonincoming | |
92 | commoninc = fci(unfi, remote, force=force) |
|
95 | commoninc = fci(unfi, pushop.remote, force=force) | |
93 | common, inc, remoteheads = commoninc |
|
96 | common, inc, remoteheads = commoninc | |
94 | fco = discovery.findcommonoutgoing |
|
97 | fco = discovery.findcommonoutgoing | |
95 | outgoing = fco(unfi, remote, onlyheads=revs, |
|
98 | outgoing = fco(unfi, pushop.remote, onlyheads=revs, | |
96 | commoninc=commoninc, force=force) |
|
99 | commoninc=commoninc, force=force) | |
97 |
|
100 | |||
98 |
|
101 | |||
@@ -126,7 +129,7 def push(repo, remote, force=False, revs | |||||
126 | % (ctx.troubles()[0], |
|
129 | % (ctx.troubles()[0], | |
127 | ctx)) |
|
130 | ctx)) | |
128 | newbm = pushop.ui.configlist('bookmarks', 'pushing') |
|
131 | newbm = pushop.ui.configlist('bookmarks', 'pushing') | |
129 | discovery.checkheads(unfi, remote, outgoing, |
|
132 | discovery.checkheads(unfi, pushop.remote, outgoing, | |
130 | remoteheads, newbranch, |
|
133 | remoteheads, newbranch, | |
131 | bool(inc), newbm) |
|
134 | bool(inc), newbm) | |
132 |
|
135 | |||
@@ -156,11 +159,12 def push(repo, remote, force=False, revs | |||||
156 | remoteheads = ['force'] |
|
159 | remoteheads = ['force'] | |
157 | # ssh: return remote's addchangegroup() |
|
160 | # ssh: return remote's addchangegroup() | |
158 | # http: return remote's addchangegroup() or 0 for error |
|
161 | # http: return remote's addchangegroup() or 0 for error | |
159 | ret = remote.unbundle(cg, remoteheads, 'push') |
|
162 | ret = pushop.remote.unbundle(cg, remoteheads, 'push') | |
160 | else: |
|
163 | else: | |
161 | # we return an integer indicating remote head count |
|
164 | # we return an integer indicating remote head count | |
162 | # change |
|
165 | # change | |
163 |
ret = remote.addchangegroup(cg, 'push', |
|
166 | ret = pushop.remote.addchangegroup(cg, 'push', | |
|
167 | pushop.repo.url()) | |||
164 |
|
168 | |||
165 | if ret: |
|
169 | if ret: | |
166 | # push succeed, synchronize target of the push |
|
170 | # push succeed, synchronize target of the push | |
@@ -193,7 +197,7 def push(repo, remote, force=False, revs | |||||
193 | outgoing.missing) |
|
197 | outgoing.missing) | |
194 | cheads.extend(c.node() for c in revset) |
|
198 | cheads.extend(c.node() for c in revset) | |
195 | # even when we don't push, exchanging phase data is useful |
|
199 | # even when we don't push, exchanging phase data is useful | |
196 | remotephases = remote.listkeys('phases') |
|
200 | remotephases = pushop.remote.listkeys('phases') | |
197 | if (pushop.ui.configbool('ui', '_usedassubrepo', False) |
|
201 | if (pushop.ui.configbool('ui', '_usedassubrepo', False) | |
198 | and remotephases # server supports phases |
|
202 | and remotephases # server supports phases | |
199 | and ret is None # nothing was pushed |
|
203 | and ret is None # nothing was pushed | |
@@ -229,7 +233,7 def push(repo, remote, force=False, revs | |||||
229 | outdated = unfi.set('heads((%ln::%ln) and public())', |
|
233 | outdated = unfi.set('heads((%ln::%ln) and public())', | |
230 | droots, cheads) |
|
234 | droots, cheads) | |
231 | for newremotehead in outdated: |
|
235 | for newremotehead in outdated: | |
232 | r = remote.pushkey('phases', |
|
236 | r = pushop.remote.pushkey('phases', | |
233 | newremotehead.hex(), |
|
237 | newremotehead.hex(), | |
234 | str(phases.draft), |
|
238 | str(phases.draft), | |
235 | str(phases.public)) |
|
239 | str(phases.public)) | |
@@ -237,7 +241,7 def push(repo, remote, force=False, revs | |||||
237 | pushop.ui.warn(_('updating %s to public failed!\n') |
|
241 | pushop.ui.warn(_('updating %s to public failed!\n') | |
238 | % newremotehead) |
|
242 | % newremotehead) | |
239 | pushop.ui.debug('try to push obsolete markers to remote\n') |
|
243 | pushop.ui.debug('try to push obsolete markers to remote\n') | |
240 | obsolete.syncpush(pushop.repo, remote) |
|
244 | obsolete.syncpush(pushop.repo, pushop.remote) | |
241 | finally: |
|
245 | finally: | |
242 | if lock is not None: |
|
246 | if lock is not None: | |
243 | lock.release() |
|
247 | lock.release() | |
@@ -245,5 +249,5 def push(repo, remote, force=False, revs | |||||
245 | if locallock is not None: |
|
249 | if locallock is not None: | |
246 | locallock.release() |
|
250 | locallock.release() | |
247 |
|
251 | |||
248 | bookmarks.updateremote(pushop.ui, unfi, remote, revs) |
|
252 | bookmarks.updateremote(pushop.ui, unfi, pushop.remote, revs) | |
249 | return ret |
|
253 | return ret |
General Comments 0
You need to be logged in to leave comments.
Login now