Mercurial > hgsubversion
comparison wrappers.py @ 284:f8f9a2993705
Implement parseurl support (#revision in repository urls)
Note: Normally when using parseurl, hg clone will treat the revision after # as
if it was passed in as --rev, treats that rev as a head and won't clone beyond
that. This wasn't implemented here, hence all the TODO's in the comments.
All we do is use the checkout parameter where appropriate to update the wc to
the selected revision.
author | Martijn Pieters <mj@zopatista.com> |
---|---|
date | Mon, 27 Apr 2009 09:39:39 -0500 |
parents | 521d9c1bb11d |
children | 1d48d9a34c19 |
comparison
equal
deleted
inserted
replaced
283:521d9c1bb11d | 284:f8f9a2993705 |
---|---|
40 """ | 40 """ |
41 svnurl = repo.ui.expandpath(dest or 'default-push', dest or 'default') | 41 svnurl = repo.ui.expandpath(dest or 'default-push', dest or 'default') |
42 if not (cmdutil.issvnurl(svnurl) or opts.get('svn', False)): | 42 if not (cmdutil.issvnurl(svnurl) or opts.get('svn', False)): |
43 return orig(ui, repo, dest, *args, **opts) | 43 return orig(ui, repo, dest, *args, **opts) |
44 | 44 |
45 # split off #rev; TODO implement --revision/#rev support | |
46 svnurl, revs, checkout = hg.parseurl(svnurl, opts.get('rev')) | |
45 hge = hg_delta_editor.HgChangeReceiver(repo=repo) | 47 hge = hg_delta_editor.HgChangeReceiver(repo=repo) |
46 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 48 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
47 hge.revmap.iterkeys())) | 49 hge.revmap.iterkeys())) |
48 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, | 50 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, |
49 repo.parents()[0].node()) | 51 repo.parents()[0].node()) |
94 if not cmdutil.issvnurl(svnurl): | 96 if not cmdutil.issvnurl(svnurl): |
95 return orig(ui, repo, dest=dest, *args, **opts) | 97 return orig(ui, repo, dest=dest, *args, **opts) |
96 old_encoding = util.swap_out_encoding() | 98 old_encoding = util.swap_out_encoding() |
97 hge = hg_delta_editor.HgChangeReceiver(repo=repo) | 99 hge = hg_delta_editor.HgChangeReceiver(repo=repo) |
98 svnurl = util.normalize_url(svnurl) | 100 svnurl = util.normalize_url(svnurl) |
101 # split of #rev; TODO: implement --rev/#rev support | |
102 svnurl, revs, checkout = hg.parseurl(svnurl, opts.get('rev')) | |
99 if svnurl != hge.url: | 103 if svnurl != hge.url: |
100 raise hgutil.Abort('wrong subversion url!') | 104 raise hgutil.Abort('wrong subversion url!') |
101 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | 105 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
102 hge.revmap.iterkeys())) | 106 hge.revmap.iterkeys())) |
103 user, passwd = util.getuserpass(opts) | 107 user, passwd = util.getuserpass(opts) |
189 svnurl = ui.expandpath(source) | 193 svnurl = ui.expandpath(source) |
190 if not cmdutil.issvnurl(svnurl): | 194 if not cmdutil.issvnurl(svnurl): |
191 return orig(ui, source=source, dest=dest, *args, **opts) | 195 return orig(ui, source=source, dest=dest, *args, **opts) |
192 | 196 |
193 if not dest: | 197 if not dest: |
194 dest = hg.defaultdest(source) + '-hg' | 198 dest = hg.defaultdest(hg.parseurl(source)[0]) + '-hg' |
195 ui.status("Assuming destination %s\n" % dest) | 199 ui.status("Assuming destination %s\n" % dest) |
196 | 200 |
197 if os.path.exists(dest): | 201 if os.path.exists(dest): |
198 raise hgutil.Abort("destination '%s' already exists" % dest) | 202 raise hgutil.Abort("destination '%s' already exists" % dest) |
199 url = util.normalize_url(svnurl) | 203 url = util.normalize_url(svnurl) |
215 fp.write("[paths]\n") | 219 fp.write("[paths]\n") |
216 # percent needs to be escaped for ConfigParser | 220 # percent needs to be escaped for ConfigParser |
217 fp.write("default = %(url)s\nsvn = %(url)s\n" % {'url': svnurl}) | 221 fp.write("default = %(url)s\nsvn = %(url)s\n" % {'url': svnurl}) |
218 fp.close() | 222 fp.close() |
219 if (res is None or res == 0) and not opts.get('noupdate', False): | 223 if (res is None or res == 0) and not opts.get('noupdate', False): |
220 for test in ('default', 'tip'): | 224 # Split off #rev |
225 url, revs, checkout = hg.parseurl(svnurl) | |
226 for test in (checkout, 'default', 'tip'): | |
221 try: | 227 try: |
222 uprev = repo.lookup(test) | 228 uprev = repo.lookup(test) |
223 break | 229 break |
224 except: | 230 except: |
225 continue | 231 continue |
239 url = ((repo and repo.ui) or ui).expandpath(source) | 245 url = ((repo and repo.ui) or ui).expandpath(source) |
240 if not (cmdutil.issvnurl(url) or svn or create_new_dest): | 246 if not (cmdutil.issvnurl(url) or svn or create_new_dest): |
241 return orig(ui, repo, source=source, *args, **opts) | 247 return orig(ui, repo, source=source, *args, **opts) |
242 svn_url = url | 248 svn_url = url |
243 svn_url = util.normalize_url(svn_url) | 249 svn_url = util.normalize_url(svn_url) |
250 # Split off #rev; TODO: implement --rev/#rev support limiting the pulled/cloned revisions | |
251 svn_url, revs, checkout = hg.parseurl(svn_url, opts.get('rev')) | |
244 old_encoding = util.swap_out_encoding() | 252 old_encoding = util.swap_out_encoding() |
245 # TODO implement skipto support | 253 # TODO implement skipto support |
246 skipto_rev = 0 | 254 skipto_rev = 0 |
247 have_replay = not svn_stupid | 255 have_replay = not svn_stupid |
248 if have_replay and not callable( | 256 if have_replay and not callable( |
339 newheads = len(repo.changelog.heads()) | 347 newheads = len(repo.changelog.heads()) |
340 # postincoming needs to know if heads were added or removed | 348 # postincoming needs to know if heads were added or removed |
341 # calculation based on mercurial.localrepo.addchangegroup | 349 # calculation based on mercurial.localrepo.addchangegroup |
342 # 0 means no changes, 1 no new heads, > 1 new heads, < 0 heads removed | 350 # 0 means no changes, 1 no new heads, > 1 new heads, < 0 heads removed |
343 modheads = newheads - oldheads + (newheads < oldheads and -1 or 1) | 351 modheads = newheads - oldheads + (newheads < oldheads and -1 or 1) |
344 commands.postincoming(ui, repo, modheads, opts.get('update'), None) | 352 commands.postincoming(ui, repo, modheads, opts.get('update'), checkout) |
345 | 353 |
346 | 354 |
347 def rebase(orig, ui, repo, **opts): | 355 def rebase(orig, ui, repo, **opts): |
348 """rebase current unpushed revisions onto the Subversion head | 356 """rebase current unpushed revisions onto the Subversion head |
349 | 357 |