remote-hg: store converted URL
authorFelipe Contreras <felipe.contreras@gmail.com>
Wed, 9 Jan 2013 19:43:38 +0000 (20:43 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Jan 2013 17:57:57 +0000 (09:57 -0800)
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>
contrib/remote-helpers/git-remote-hg

index c7006000a6f4a19fa4e5f4bf3fc543d4756a1f4d..7c74d8bfdcf178d861be87f36bd3c894c81c2e42 100755 (executable)
@@ -720,6 +720,14 @@ def do_export(parser):
     if peer:
         parser.repo.push(peer, force=False)
 
+def fix_path(alias, repo, orig_url):
+    repo_url = util.url(repo.url())
+    url = util.url(orig_url)
+    if str(url) == str(repo_url):
+        return
+    cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % repo_url]
+    subprocess.call(cmd)
+
 def main(args):
     global prefix, dirname, branches, bmarks
     global marks, blob_marks, parsed_refs
@@ -766,6 +774,9 @@ def main(args):
     repo = get_repo(url, alias)
     prefix = 'refs/hg/%s' % alias
 
+    if not is_tmp:
+        fix_path(alias, peer or repo, url)
+
     if not os.path.exists(dirname):
         os.makedirs(dirname)