Mercurial > hgsubversion
comparison hgsubversion/wrappers.py @ 347:537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 22 May 2009 15:12:31 +0200 |
parents | 4b992ebdecc6 |
children | 62f90781eb10 |
comparison
equal
deleted
inserted
replaced
346:4b992ebdecc6 | 347:537de0300510 |
---|---|
33 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False) | 33 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False) |
34 displayer.show(ha) | 34 displayer.show(ha) |
35 return 0 | 35 return 0 |
36 | 36 |
37 | 37 |
38 def outgoing(orig, ui, repo, dest=None, *args, **opts): | 38 def outgoing(repo, dest=None, heads=None, force=False): |
39 """show changesets not found in the Subversion repository | 39 """show changesets not found in the Subversion repository |
40 """ | 40 """ |
41 svnurl = repo.ui.expandpath(dest or 'default-push', dest or 'default') | 41 assert dest.capable('subversion') |
42 if not hg.repository(ui, svnurl).capable('subversion'): | |
43 return orig(ui, repo, dest, *args, **opts) | |
44 | 42 |
45 # split off #rev; TODO implement --revision/#rev support | 43 # split off #rev; TODO implement --revision/#rev support |
46 svnurl, revs, checkout = hg.parseurl(svnurl, opts.get('rev')) | 44 svnurl, revs, checkout = hg.parseurl(dest.svnurl, heads) |
47 hge = hg_delta_editor.HgChangeReceiver(repo=repo) | 45 hge = hg_delta_editor.HgChangeReceiver(repo=repo) |
48 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 46 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
49 hge.revmap.iterkeys())) | 47 hge.revmap.iterkeys())) |
50 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, | 48 return util.outgoing_revisions(repo.ui, repo, hge, svn_commit_hashes, |
51 repo.parents()[0].node()) | 49 repo.parents()[0].node()) |
52 if not (o_r and len(o_r)): | |
53 ui.status('no changes found\n') | |
54 return 0 | |
55 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False) | |
56 for node in reversed(o_r): | |
57 displayer.show(repo[node]) | |
58 | 50 |
59 | 51 |
60 def diff(orig, ui, repo, *args, **opts): | 52 def diff(orig, ui, repo, *args, **opts): |
61 """show a diff of the most recent revision against its parent from svn | 53 """show a diff of the most recent revision against its parent from svn |
62 """ | 54 """ |
85 'unified': True, | 77 'unified': True, |
86 'text': False, | 78 'text': False, |
87 })) | 79 })) |
88 ui.write(cmdutil.filterdiff(''.join(it), baserev, newrev)) | 80 ui.write(cmdutil.filterdiff(''.join(it), baserev, newrev)) |
89 | 81 |
90 def push(repo, dest="default", force=False, revs=None): | 82 def push(repo, dest, force, revs): |
91 """push revisions starting at a specified head back to Subversion. | 83 """push revisions starting at a specified head back to Subversion. |
92 """ | 84 """ |
93 assert not revs, 'designated revisions for push remains unimplemented.' | 85 assert not revs, 'designated revisions for push remains unimplemented.' |
94 ui = repo.ui | 86 ui = repo.ui |
95 svnurl = util.normalize_url(repo.ui.expandpath(dest)) | 87 svnurl = util.normalize_url(repo.ui.expandpath(dest.svnurl)) |
96 old_encoding = util.swap_out_encoding() | 88 old_encoding = util.swap_out_encoding() |
97 # split of #rev; TODO: implement --rev/#rev support | 89 # split of #rev; TODO: implement --rev/#rev support |
98 svnurl, revs, checkout = hg.parseurl(svnurl, revs) | 90 svnurl, revs, checkout = hg.parseurl(svnurl, revs) |
99 # TODO: do credentials specified in the URL still work? | 91 # TODO: do credentials specified in the URL still work? |
100 user = repo.ui.config('hgsubversion', 'username') | 92 user = repo.ui.config('hgsubversion', 'username') |
155 ui.warn("Could not push revision %s because it had no changes in svn.\n" % | 147 ui.warn("Could not push revision %s because it had no changes in svn.\n" % |
156 old_ctx) | 148 old_ctx) |
157 return 1 | 149 return 1 |
158 # 3. Fetch revisions from svn | 150 # 3. Fetch revisions from svn |
159 # TODO: this probably should pass in the source explicitly - rev too? | 151 # TODO: this probably should pass in the source explicitly - rev too? |
160 r = pull(repo, source=dest, force=force) | 152 r = repo.pull(dest, force=force) |
161 assert not r or r == 0 | 153 assert not r or r == 0 |
162 # 4. Find the new head of the target branch | 154 # 4. Find the new head of the target branch |
163 oldtipctx = repo[oldtip] | 155 oldtipctx = repo[oldtip] |
164 replacement = [c for c in oldtipctx.children() if c not in old_children | 156 replacement = [c for c in oldtipctx.children() if c not in old_children |
165 and c.branch() == oldtipctx.branch()] | 157 and c.branch() == oldtipctx.branch()] |
192 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) | 184 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), hge.revmap.iterkeys())) |
193 util.swap_out_encoding(old_encoding) | 185 util.swap_out_encoding(old_encoding) |
194 return 0 | 186 return 0 |
195 | 187 |
196 | 188 |
197 def pull(repo, source="default", heads=None, force=False): | 189 def pull(repo, source, heads=[], force=False): |
198 """pull new revisions from Subversion | 190 """pull new revisions from Subversion""" |
199 | 191 assert source.capable('subversion') |
200 Also takes svn, svn_stupid, and create_new_dest kwargs. | 192 svn_url = source.svnurl |
201 """ | |
202 url = repo.ui.expandpath(source) | |
203 svn_url = util.normalize_url(url) | |
204 | 193 |
205 # Split off #rev | 194 # Split off #rev |
206 svn_url, heads, checkout = hg.parseurl(svn_url, heads) | 195 svn_url, heads, checkout = hg.parseurl(svn_url, heads) |
207 old_encoding = util.swap_out_encoding() | 196 old_encoding = util.swap_out_encoding() |
208 | 197 |
215 'only numbers work.' % checkout) | 204 'only numbers work.' % checkout) |
216 | 205 |
217 have_replay = not repo.ui.configbool('hgsubversion', 'stupid') | 206 have_replay = not repo.ui.configbool('hgsubversion', 'stupid') |
218 if have_replay and not callable( | 207 if have_replay and not callable( |
219 delta.svn_txdelta_apply(None, None, None)[0]): #pragma: no cover | 208 delta.svn_txdelta_apply(None, None, None)[0]): #pragma: no cover |
220 ui.status('You are using old Subversion SWIG bindings. Replay will not' | 209 repo.ui.status('You are using old Subversion SWIG bindings. Replay ' |
221 ' work until you upgrade to 1.5.0 or newer. Falling back to' | 210 'will not work until you upgrade to 1.5.0 or newer. ' |
222 ' a slower method that may be buggier. Please upgrade, or' | 211 'Falling back to a slower method that may be buggier. ' |
223 ' contribute a patch to use the ctypes bindings instead' | 212 'Please upgrade, or contribute a patch to use the ' |
224 ' of SWIG.\n') | 213 'ctypes bindings instead of SWIG.\n') |
225 have_replay = False | 214 have_replay = False |
215 elif not have_replay: | |
216 repo.ui.note('fetching stupidly...\n') | |
226 | 217 |
227 # TODO: do credentials specified in the URL still work? | 218 # TODO: do credentials specified in the URL still work? |
228 user = repo.ui.config('hgsubversion', 'username') | 219 user = repo.ui.config('hgsubversion', 'username') |
229 passwd = repo.ui.config('hgsubversion', 'password') | 220 passwd = repo.ui.config('hgsubversion', 'password') |
230 svn = svnwrap.SubversionRepo(svn_url, user, passwd) | 221 svn = svnwrap.SubversionRepo(svn_url, user, passwd) |
240 'remains unimplemented.') | 231 'remains unimplemented.') |
241 | 232 |
242 revisions = 0 | 233 revisions = 0 |
243 | 234 |
244 try: | 235 try: |
245 # start converting revisions | 236 # start converting revisions |
246 for r in svn.revisions(start=start, stop=stopat_rev): | 237 for r in svn.revisions(start=start, stop=stopat_rev): |
247 valid = True | 238 if (r.author is None and |
248 hg_editor.update_branch_tag_map_for_rev(r) | 239 r.message == 'This is an empty revision for padding.'): |
249 for p in r.paths: | 240 continue |
250 if hg_editor._is_path_valid(p): | 241 hg_editor.update_branch_tag_map_for_rev(r) |
251 valid = True | |
252 break | |
253 if valid: | |
254 # got a 502? Try more than once! | 242 # got a 502? Try more than once! |
255 tries = 0 | 243 tries = 0 |
256 converted = False | 244 converted = False |
257 while not converted: | 245 while not converted: |
258 try: | 246 try: |
277 else: | 265 else: |
278 raise hgutil.Abort(*e.args) | 266 raise hgutil.Abort(*e.args) |
279 revisions += 1 | 267 revisions += 1 |
280 except KeyboardInterrupt: | 268 except KeyboardInterrupt: |
281 pass | 269 pass |
282 | 270 finally: |
283 util.swap_out_encoding(old_encoding) | 271 util.swap_out_encoding(old_encoding) |
284 | 272 |
285 if revisions == 0: | 273 if revisions == 0: |
286 ui.status(i18n._("no changes found\n")) | 274 ui.status(i18n._("no changes found\n")) |
287 return | 275 return 0 |
288 else: | 276 else: |
289 ui.status("pulled %d revisions\n" % revisions) | 277 ui.status("pulled %d revisions\n" % revisions) |
290 | 278 |
291 def rebase(orig, ui, repo, **opts): | 279 def rebase(orig, ui, repo, **opts): |
292 """rebase current unpushed revisions onto the Subversion head | 280 """rebase current unpushed revisions onto the Subversion head |