Left: | ||
Right: |
OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 # This Source Code Form is subject to the terms of the Mozilla Public | 4 # This Source Code Form is subject to the terms of the Mozilla Public |
5 # License, v. 2.0. If a copy of the MPL was not distributed with this | 5 # License, v. 2.0. If a copy of the MPL was not distributed with this |
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 6 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
7 | 7 |
8 import sys | 8 import sys |
9 import os | 9 import os |
10 import posixpath | 10 import posixpath |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 if normpath == posixpath.pardir or normpath.startswith(posixpath.pardir + posi xpath.sep): | 190 if normpath == posixpath.pardir or normpath.startswith(posixpath.pardir + posi xpath.sep): |
191 raise Exception("Dependency path %s has to be inside the repository" % subpa th) | 191 raise Exception("Dependency path %s has to be inside the repository" % subpa th) |
192 return os.path.join(path, *normpath.split(posixpath.sep)) | 192 return os.path.join(path, *normpath.split(posixpath.sep)) |
193 | 193 |
194 def get_repo_type(repo): | 194 def get_repo_type(repo): |
195 for name, repotype in repo_types.iteritems(): | 195 for name, repotype in repo_types.iteritems(): |
196 if repotype.istype(repo): | 196 if repotype.istype(repo): |
197 return name | 197 return name |
198 return None | 198 return None |
199 | 199 |
200 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.
| |
201 skip_dependency_updates = os.environ.get("SKIP_DEPENDENCY_UPDATES", "").lower( ) | |
202 return skip_dependency_updates not in ("", "0", "false") | |
203 | |
200 def ensure_repo(parentrepo, target, roots, sourcename): | 204 def ensure_repo(parentrepo, target, roots, sourcename): |
201 if os.path.exists(target): | 205 if os.path.exists(target): |
202 return | 206 return |
203 | 207 |
208 if skip_dependency_updates_p(): | |
209 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.
| |
210 "%s not cloned" % target) | |
211 return | |
212 | |
204 parenttype = get_repo_type(parentrepo) | 213 parenttype = get_repo_type(parentrepo) |
205 type = None | 214 type = None |
206 for key in roots: | 215 for key in roots: |
207 if key == parenttype or (key in repo_types and type is None): | 216 if key == parenttype or (key in repo_types and type is None): |
208 type = key | 217 type = key |
209 if type is None: | 218 if type is None: |
210 raise Exception("No valid source found to create %s" % target) | 219 raise Exception("No valid source found to create %s" % target) |
211 | 220 |
212 postprocess_url = repo_types[type].postprocess_url | 221 postprocess_url = repo_types[type].postprocess_url |
213 root = postprocess_url(roots[type]) | 222 root = postprocess_url(roots[type]) |
(...skipping 19 matching lines...) Expand all Loading... | |
233 | 242 |
234 if type in revisions: | 243 if type in revisions: |
235 revision = revisions[type] | 244 revision = revisions[type] |
236 elif "*" in revisions: | 245 elif "*" in revisions: |
237 revision = revisions["*"] | 246 revision = revisions["*"] |
238 else: | 247 else: |
239 logging.warning("No revision specified for repository %s (type %s), skipping update" % (target, type)) | 248 logging.warning("No revision specified for repository %s (type %s), skipping update" % (target, type)) |
240 return | 249 return |
241 | 250 |
242 resolved_revision = repo_types[type].get_revision_id(target, revision) | 251 resolved_revision = repo_types[type].get_revision_id(target, revision) |
243 if not resolved_revision: | 252 current_revision = repo_types[type].get_revision_id(target) |
244 logging.info("Revision %s is unknown, downloading remote changes" % revision ) | 253 |
245 repo_types[type].pull(target) | 254 if resolved_revision != current_revision: |
246 resolved_revision = repo_types[type].get_revision_id(target, revision) | 255 if skip_dependency_updates_p(): |
256 logging.warning("SKIP_DEPENDENCY_UPDATES environment variable set, " | |
257 "%s not checked out to %s" % (target, revision)) | |
258 return | |
259 | |
247 if not resolved_revision: | 260 if not resolved_revision: |
248 raise Exception("Failed to resolve revision %s" % revision) | 261 logging.info("Revision %s is unknown, downloading remote changes" % revisi on) |
262 repo_types[type].pull(target) | |
263 resolved_revision = repo_types[type].get_revision_id(target, revision) | |
264 if not resolved_revision: | |
265 raise Exception("Failed to resolve revision %s" % revision) | |
249 | 266 |
250 current_revision = repo_types[type].get_revision_id(target) | |
251 if resolved_revision != current_revision: | |
252 logging.info("Updating repository %s to revision %s" % (target, resolved_rev ision)) | 267 logging.info("Updating repository %s to revision %s" % (target, resolved_rev ision)) |
253 repo_types[type].update(target, resolved_revision) | 268 repo_types[type].update(target, resolved_revision) |
254 | 269 |
255 def resolve_deps(repodir, level=0, self_update=True, overrideroots=None, skipdep endencies=set()): | 270 def resolve_deps(repodir, level=0, self_update=True, overrideroots=None, skipdep endencies=set()): |
256 config = read_deps(repodir) | 271 config = read_deps(repodir) |
257 if config is None: | 272 if config is None: |
258 if level == 0: | 273 if level == 0: |
259 logging.warning("No dependencies file in directory %s, nothing to do...\n% s" % (repodir, USAGE)) | 274 logging.warning("No dependencies file in directory %s, nothing to do...\n% s" % (repodir, USAGE)) |
260 return | 275 return |
261 if level >= 10: | 276 if level >= 10: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 args = parser.parse_args() | 332 args = parser.parse_args() |
318 | 333 |
319 if args.quiet: | 334 if args.quiet: |
320 logging.disable(logging.INFO) | 335 logging.disable(logging.INFO) |
321 | 336 |
322 repos = args.repos | 337 repos = args.repos |
323 if not len(repos): | 338 if not len(repos): |
324 repos = [os.path.dirname(__file__)] | 339 repos = [os.path.dirname(__file__)] |
325 for repo in repos: | 340 for repo in repos: |
326 resolve_deps(repo) | 341 resolve_deps(repo) |
OLD | NEW |