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

Unified Diff: ensure_dependencies.py

Issue 5652679430766592: Issue 2443 - Honour SKIP_DEPENDENCY_UPDATES environment variable (Closed)
Patch Set: Addressed Sebastian's feedback Created May 7, 2015, 1:42 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ensure_dependencies.py
diff --git a/ensure_dependencies.py b/ensure_dependencies.py
index def9a7e9803cf29d8f8f70d644c599981b206163..fb34b8f07d3cdbaa175f1c3a0fd496d84a5c5334 100755
--- a/ensure_dependencies.py
+++ b/ensure_dependencies.py
@@ -197,10 +197,19 @@ def get_repo_type(repo):
return name
return None
+def skip_dependency_updates_p():
Sebastian Noack 2015/05/07 14:06:31 I'd suggest to make it either a constant rather th
kzar 2015/05/07 14:20:01 Done.
+ skip_dependency_updates = os.environ.get("SKIP_DEPENDENCY_UPDATES", "").lower()
+ return skip_dependency_updates not in ("", "0", "false")
+
def ensure_repo(parentrepo, target, roots, sourcename):
if os.path.exists(target):
return
+ if skip_dependency_updates_p():
+ logging.warning("SKIP_DEPENDENCY_UPDATES environment variable set, "
Sebastian Noack 2015/05/07 14:06:31 Note that you don't need/should format the message
kzar 2015/05/07 14:20:01 Done.
+ "%s not cloned" % target)
+ return
+
parenttype = get_repo_type(parentrepo)
type = None
for key in roots:
@@ -240,15 +249,21 @@ def update_repo(target, revisions):
return
resolved_revision = repo_types[type].get_revision_id(target, revision)
- if not resolved_revision:
- logging.info("Revision %s is unknown, downloading remote changes" % revision)
- repo_types[type].pull(target)
- resolved_revision = repo_types[type].get_revision_id(target, revision)
- if not resolved_revision:
- raise Exception("Failed to resolve revision %s" % revision)
-
current_revision = repo_types[type].get_revision_id(target)
+
if resolved_revision != current_revision:
+ if skip_dependency_updates_p():
+ logging.warning("SKIP_DEPENDENCY_UPDATES environment variable set, "
+ "%s not checked out to %s" % (target, revision))
+ return
+
+ if not resolved_revision:
+ logging.info("Revision %s is unknown, downloading remote changes" % revision)
+ repo_types[type].pull(target)
+ resolved_revision = repo_types[type].get_revision_id(target, revision)
+ if not resolved_revision:
+ raise Exception("Failed to resolve revision %s" % revision)
+
logging.info("Updating repository %s to revision %s" % (target, resolved_revision))
repo_types[type].update(target, resolved_revision)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld