remote-hg: use python urlparse

It's simpler, and we don't need to depend on certain Mercurial versions. Also, now we don't update the URL if 'file://' is not present. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Apr 22, 2013 at 16:55 UTC 846cc77676df59d3f7962de95851ff498e273432
1 file changed +5 -4
contrib/remote-helpers/git-remote-hg
+5 -4
@@ -22,6 +22,7 @@ import shutil
22 import subprocess
23 import urllib
24 import atexit
25 +import urlparse
26
27 #
28 # If you want to switch to hg-git compatibility mode:
@@ -793,11 +794,11 @@ def do_export(parser):
794 print
795
796 def fix_path(alias, repo, orig_url):
796 - repo_url = util.url(repo.url())
797 - url = util.url(orig_url)
798 - if str(url) == str(repo_url):
797 + url = urlparse.urlparse(orig_url, 'file')
798 + if url.scheme != 'file' or os.path.isabs(url.path):
799 return
800 - cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % repo_url]
800 + abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url)
801 + cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % abs_url]
802 subprocess.call(cmd)
803
804 def main(args):