Index: ensure_dependencies.py |
diff --git a/ensure_dependencies.py b/ensure_dependencies.py |
index d8af9e718b27d802acd7cde70301341220c6f7eb..5c9494cd9d93d29f5eb14005be15c8f0237c382a 100755 |
--- a/ensure_dependencies.py |
+++ b/ensure_dependencies.py |
@@ -79,6 +79,9 @@ class Mercurial(): |
module = os.path.relpath(target, repo) |
_ensure_line_exists(ignore_path, module) |
+ def postprocess_url(self, url): |
+ return url |
+ |
class Git(): |
def istype(self, repodir): |
return os.path.exists(os.path.join(repodir, ".git")) |
@@ -104,6 +107,12 @@ class Git(): |
exclude_file = os.path.join(repo, ".git", "info", "exclude") |
_ensure_line_exists(exclude_file, module) |
+ def postprocess_url(self, url): |
+ # Handle alternative syntax of SSH URLS |
+ if "@" in url and ":" in url and not urlparse.urlsplit(url).scheme: |
+ return "ssh://" + url.replace(":", "/", 1) |
Sebastian Noack
2015/04/30 13:34:36
How does git URLs specify ports?
kzar
2015/04/30 14:45:29
Apparently they can't, you have to specify non-sta
|
+ return url |
+ |
repo_types = OrderedDict(( |
("hg", Mercurial()), |
("git", Git()), |
@@ -187,10 +196,13 @@ def ensure_repo(parentrepo, target, roots, sourcename): |
if type is None: |
raise Exception("No valid source found to create %s" % target) |
- if os.path.exists(roots[type]): |
- url = os.path.join(roots[type], sourcename) |
+ root = repo_types[type].postprocess_url(roots[type]) |
Sebastian Noack
2015/04/30 13:34:36
Nit, don't repeat yourself:
postprocess_url = r
kzar
2015/04/30 14:45:29
Done.
Wladimir Palant
2015/04/30 15:48:30
Rather questionable advise in this context IMHO.
Sebastian Noack
2015/04/30 17:58:28
How is caching one variable lookup + one item look
Wladimir Palant
2015/04/30 18:34:07
If it provides a negligible performance gain while
Sebastian Noack
2015/04/30 18:43:31
I didn't even mention performance. "Don't repeat y
|
+ sourcename = repo_types[type].postprocess_url(sourcename) |
+ |
+ if os.path.exists(root): |
+ url = os.path.join(root, sourcename) |
else: |
- url = urlparse.urljoin(roots[type], sourcename) |
+ url = urlparse.urljoin(root, sourcename) |
logging.info("Cloning repository %s into %s" % (url, target)) |
repo_types[type].clone(url, target) |