remote-bzr: store converted URL
Bazaar 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. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 26, 2013 at 16:12 UTC
d82c912c430d63456350ae39ea6d1fa7ba88006d
1 file changed
+12
-1
contrib/remote-helpers/git-remote-bzr
+12
-1
@@ -32,7 +32,7 @@ import os
32
import json
33
import re
34
import StringIO
35
-import atexit, shutil, hashlib
35
+import atexit, shutil, hashlib, urlparse, subprocess
36
37
NAME_RE = re.compile('^([^<>]+)')
38
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
@@ -713,6 +713,14 @@ def get_repo(url, alias):
713
714
return branch
715
716
+def fix_path(alias, orig_url):
717
+ url = urlparse.urlparse(orig_url, 'file')
718
+ if url.scheme != 'file' or os.path.isabs(url.path):
719
+ return
720
+ abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url)
721
+ cmd = ['git', 'config', 'remote.%s.url' % alias, "bzr::%s" % abs_url]
722
+ subprocess.call(cmd)
723
+
724
def main(args):
725
global marks, prefix, dirname
726
global tags, filenodes
@@ -741,6 +749,9 @@ def main(args):
749
gitdir = os.environ['GIT_DIR']
750
dirname = os.path.join(gitdir, 'bzr', alias)
751
752
+ if not is_tmp:
753
+ fix_path(alias, url)
754
+
755
if not os.path.exists(dirname):
756
os.makedirs(dirname)
757