Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 15 matching lines...) Expand all Loading... | |
26 _root = hg:https://hg.adblockplus.org/ git:https://github.com/adblockplus/ | 26 _root = hg:https://hg.adblockplus.org/ git:https://github.com/adblockplus/ |
27 # File to update this script from (optional) | 27 # File to update this script from (optional) |
28 _self = buildtools/ensure_dependencies.py | 28 _self = buildtools/ensure_dependencies.py |
29 # Check out elemhidehelper repository into extensions/elemhidehelper directory | 29 # Check out elemhidehelper repository into extensions/elemhidehelper directory |
30 # at tag "1.2". | 30 # at tag "1.2". |
31 extensions/elemhidehelper = elemhidehelper 1.2 | 31 extensions/elemhidehelper = elemhidehelper 1.2 |
32 # Check out buildtools repository into buildtools directory at VCS-specific | 32 # Check out buildtools repository into buildtools directory at VCS-specific |
33 # revision IDs. | 33 # revision IDs. |
34 buildtools = buildtools hg:016d16f7137b git:f3f8692f82e5 | 34 buildtools = buildtools hg:016d16f7137b git:f3f8692f82e5 |
35 """ | 35 """ |
36 | |
37 SKIP_DEPENDENCY_UPDATES = os.environ.get( | |
38 "SKIP_DEPENDENCY_UPDATES", "" | |
39 ).lower() not in ("", "0", "false") | |
36 | 40 |
37 class Mercurial(): | 41 class Mercurial(): |
38 def istype(self, repodir): | 42 def istype(self, repodir): |
39 return os.path.exists(os.path.join(repodir, ".hg")) | 43 return os.path.exists(os.path.join(repodir, ".hg")) |
40 | 44 |
41 def clone(self, source, target): | 45 def clone(self, source, target): |
42 if not source.endswith("/"): | 46 if not source.endswith("/"): |
43 source += "/" | 47 source += "/" |
44 subprocess.check_call(["hg", "clone", "--quiet", "--noupdate", source, targe t]) | 48 subprocess.check_call(["hg", "clone", "--quiet", "--noupdate", source, targe t]) |
45 | 49 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 if normpath == posixpath.pardir or normpath.startswith(posixpath.pardir + posi xpath.sep): | 194 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) | 195 raise Exception("Dependency path %s has to be inside the repository" % subpa th) |
192 return os.path.join(path, *normpath.split(posixpath.sep)) | 196 return os.path.join(path, *normpath.split(posixpath.sep)) |
193 | 197 |
194 def get_repo_type(repo): | 198 def get_repo_type(repo): |
195 for name, repotype in repo_types.iteritems(): | 199 for name, repotype in repo_types.iteritems(): |
196 if repotype.istype(repo): | 200 if repotype.istype(repo): |
197 return name | 201 return name |
198 return None | 202 return None |
199 | 203 |
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 | |
204 def ensure_repo(parentrepo, target, roots, sourcename): | 204 def ensure_repo(parentrepo, target, roots, sourcename): |
205 if os.path.exists(target): | 205 if os.path.exists(target): |
206 return | 206 return |
207 | 207 |
208 if skip_dependency_updates_p(): | 208 if SKIP_DEPENDENCY_UPDATES: |
209 logging.warning("SKIP_DEPENDENCY_UPDATES environment variable set, " | 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) | 210 "%s not cloned", target) |
211 return | 211 return |
212 | 212 |
213 parenttype = get_repo_type(parentrepo) | 213 parenttype = get_repo_type(parentrepo) |
214 type = None | 214 type = None |
215 for key in roots: | 215 for key in roots: |
216 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): |
217 type = key | 217 type = key |
218 if type is None: | 218 if type is None: |
219 raise Exception("No valid source found to create %s" % target) | 219 raise Exception("No valid source found to create %s" % target) |
220 | 220 |
(...skipping 24 matching lines...) Expand all Loading... | |
245 elif "*" in revisions: | 245 elif "*" in revisions: |
246 revision = revisions["*"] | 246 revision = revisions["*"] |
247 else: | 247 else: |
248 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)) |
249 return | 249 return |
250 | 250 |
251 resolved_revision = repo_types[type].get_revision_id(target, revision) | 251 resolved_revision = repo_types[type].get_revision_id(target, revision) |
252 current_revision = repo_types[type].get_revision_id(target) | 252 current_revision = repo_types[type].get_revision_id(target) |
253 | 253 |
254 if resolved_revision != current_revision: | 254 if resolved_revision != current_revision: |
255 if skip_dependency_updates_p(): | 255 if SKIP_DEPENDENCY_UPDATES: |
256 logging.warning("SKIP_DEPENDENCY_UPDATES environment variable set, " | 256 logging.warning("SKIP_DEPENDENCY_UPDATES environment variable set, " |
257 "%s not checked out to %s" % (target, revision)) | 257 "%s not checked out to %s", target, revision) |
258 return | 258 return |
259 | 259 |
260 if not resolved_revision: | 260 if not resolved_revision: |
261 logging.info("Revision %s is unknown, downloading remote changes" % revisi on) | 261 logging.info("Revision %s is unknown, downloading remote changes" % revisi on) |
262 repo_types[type].pull(target) | 262 repo_types[type].pull(target) |
263 resolved_revision = repo_types[type].get_revision_id(target, revision) | 263 resolved_revision = repo_types[type].get_revision_id(target, revision) |
264 if not resolved_revision: | 264 if not resolved_revision: |
265 raise Exception("Failed to resolve revision %s" % revision) | 265 raise Exception("Failed to resolve revision %s" % revision) |
266 | 266 |
267 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)) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 args = parser.parse_args() | 332 args = parser.parse_args() |
333 | 333 |
334 if args.quiet: | 334 if args.quiet: |
335 logging.disable(logging.INFO) | 335 logging.disable(logging.INFO) |
336 | 336 |
337 repos = args.repos | 337 repos = args.repos |
338 if not len(repos): | 338 if not len(repos): |
339 repos = [os.path.dirname(__file__)] | 339 repos = [os.path.dirname(__file__)] |
340 for repo in repos: | 340 for repo in repos: |
341 resolve_deps(repo) | 341 resolve_deps(repo) |
LEFT | RIGHT |