19 |
19 |
20 A new should be created at the begining of each push and discarded |
20 A new should be created at the begining of each push and discarded |
21 afterward. |
21 afterward. |
22 """ |
22 """ |
23 |
23 |
24 def __init__(self, repo, remote, force=False, revs=None): |
24 def __init__(self, repo, remote, force=False, revs=None, newbranch=False): |
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 |
28 # repo we push to |
29 self.remote = remote |
29 self.remote = remote |
30 # force option provided |
30 # force option provided |
31 self.force = force |
31 self.force = force |
32 # revs to be pushed (None is "all") |
32 # revs to be pushed (None is "all") |
33 self.revs = revs |
33 self.revs = revs |
|
34 # allow push of new branch |
|
35 self.newbranch = newbranch |
34 |
36 |
35 def push(repo, remote, force=False, revs=None, newbranch=False): |
37 def push(repo, remote, force=False, revs=None, newbranch=False): |
36 '''Push outgoing changesets (limited by revs) from a local |
38 '''Push outgoing changesets (limited by revs) from a local |
37 repository to remote. Return an integer: |
39 repository to remote. Return an integer: |
38 - None means nothing to push |
40 - None means nothing to push |
39 - 0 means HTTP error |
41 - 0 means HTTP error |
40 - 1 means we pushed and remote head count is unchanged *or* |
42 - 1 means we pushed and remote head count is unchanged *or* |
41 we have outgoing changesets but refused to push |
43 we have outgoing changesets but refused to push |
42 - other values as described by addchangegroup() |
44 - other values as described by addchangegroup() |
43 ''' |
45 ''' |
44 pushop = pushoperation(repo, remote, force, revs) |
46 pushop = pushoperation(repo, remote, force, revs, newbranch) |
45 if pushop.remote.local(): |
47 if pushop.remote.local(): |
46 missing = (set(pushop.repo.requirements) |
48 missing = (set(pushop.repo.requirements) |
47 - pushop.remote.local().supported) |
49 - pushop.remote.local().supported) |
48 if missing: |
50 if missing: |
49 msg = _("required features are not" |
51 msg = _("required features are not" |
132 raise util.Abort(_(mst) |
134 raise util.Abort(_(mst) |
133 % (ctx.troubles()[0], |
135 % (ctx.troubles()[0], |
134 ctx)) |
136 ctx)) |
135 newbm = pushop.ui.configlist('bookmarks', 'pushing') |
137 newbm = pushop.ui.configlist('bookmarks', 'pushing') |
136 discovery.checkheads(unfi, pushop.remote, outgoing, |
138 discovery.checkheads(unfi, pushop.remote, outgoing, |
137 remoteheads, newbranch, |
139 remoteheads, pushop.newbranch, |
138 bool(inc), newbm) |
140 bool(inc), newbm) |
139 |
141 |
140 # TODO: get bundlecaps from remote |
142 # TODO: get bundlecaps from remote |
141 bundlecaps = None |
143 bundlecaps = None |
142 # create a changegroup from local |
144 # create a changegroup from local |