remote-hg: store converted URL

Mercurial might convert the URL to something more appropriate, like an absolute path. Lets store that instead of the original URL, which won't work from a different working directory if it's relative. Suggested-by: Max Horn <max@quendi.de> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Max Horn <max@quendi.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Jan 9, 2013 at 20:43 UTC e6bc8a33286599f99a3a7c38654c85b8d37d6605
1 file changed +11
contrib/remote-helpers/git-remote-hg
+11
@@ -720,6 +720,14 @@ def do_export(parser):
720 if peer:
721 parser.repo.push(peer, force=False)
722
723 +def fix_path(alias, repo, orig_url):
724 + repo_url = util.url(repo.url())
725 + url = util.url(orig_url)
726 + if str(url) == str(repo_url):
727 + return
728 + cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % repo_url]
729 + subprocess.call(cmd)
730 +
731 def main(args):
732 global prefix, dirname, branches, bmarks
733 global marks, blob_marks, parsed_refs
@@ -766,6 +774,9 @@ def main(args):
774 repo = get_repo(url, alias)
775 prefix = 'refs/hg/%s' % alias
776
777 + if not is_tmp:
778 + fix_path(alias, peer or repo, url)
779 +
780 if not os.path.exists(dirname):
781 os.makedirs(dirname)
782