21
21
from breezy.urlutils import URL, quote
23
from dulwich.client import parse_rsync_url
24
26
KNOWN_GIT_SCHEMES = ['git+ssh', 'git', 'http', 'https', 'ftp']
27
def parse_git_url(location):
28
"""Parse a rsync-style URL."""
29
if ':' in location and '@' not in location:
30
# SSH with no user@, zero or one leading slash.
31
(host, path) = location.split(':', 1)
34
# SSH with user@host:foo.
35
user_host, path = location.split(':', 1)
37
user, host = user_host.rsplit('@', 1)
42
raise ValueError('missing : in location')
43
return (user, host, path)
46
29
def git_url_to_bzr_url(location):
47
30
url = URL.from_string(location)
48
31
if url.scheme not in KNOWN_GIT_SCHEMES:
50
(username, host, path) = parse_git_url(location)
33
(username, host, path) = parse_rsync_url(location)
53
36
scheme='file', quoted_user=None, quoted_password=None,