Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ensure_dependencies.py

Issue 4879490828206080: Issue 2438 - Update buildtools dependency to revision 97e212af6e8 (Closed)
Patch Set: Created May 4, 2015, 7:06 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« defaults/prefs.json ('K') | « dependencies ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ensure_dependencies.py
===================================================================
--- a/ensure_dependencies.py
+++ b/ensure_dependencies.py
@@ -79,6 +79,9 @@
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 @@
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)
+ return url
+
repo_types = OrderedDict((
("hg", Mercurial()),
("git", Git()),
@@ -187,10 +196,14 @@
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)
+ postprocess_url = repo_types[type].postprocess_url
+ root = postprocess_url(roots[type])
+ sourcename = 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)
« defaults/prefs.json ('K') | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld