| 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 | 
|   11 import re |   11 import re | 
|   12 import io |   12 import io | 
|   13 import errno |   13 import errno | 
|   14 import logging |   14 import logging | 
|   15 import subprocess |   15 import subprocess | 
|   16 import urlparse |   16 import urlparse | 
 |   17 import argparse | 
|   17  |   18  | 
|   18 from collections import OrderedDict |   19 from collections import OrderedDict | 
|   19 from ConfigParser import RawConfigParser |   20 from ConfigParser import RawConfigParser | 
|   20  |   21  | 
|   21 USAGE = """ |   22 USAGE = """ | 
|   22 A dependencies file should look like this: |   23 A dependencies file should look like this: | 
|   23  |   24  | 
|   24   # VCS-specific root URLs for the repositories |   25   # VCS-specific root URLs for the repositories | 
|   25   _root = hg:https://hg.adblockplus.org/ git:https://github.com/adblockplus/ |   26   _root = hg:https://hg.adblockplus.org/ git:https://github.com/adblockplus/ | 
|   26   # File to update this script from (optional) |   27   # File to update this script from (optional) | 
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  179     return |  180     return | 
|  180  |  181  | 
|  181   parenttype = get_repo_type(parentrepo) |  182   parenttype = get_repo_type(parentrepo) | 
|  182   type = None |  183   type = None | 
|  183   for key in roots: |  184   for key in roots: | 
|  184     if key == parenttype or (key in repo_types and type is None): |  185     if key == parenttype or (key in repo_types and type is None): | 
|  185       type = key |  186       type = key | 
|  186   if type is None: |  187   if type is None: | 
|  187     raise Exception("No valid source found to create %s" % target) |  188     raise Exception("No valid source found to create %s" % target) | 
|  188  |  189  | 
|  189   url = urlparse.urljoin(roots[type], sourcename) |  190   if os.path.exists(roots[type]): | 
 |  191     url = os.path.join(roots[type], sourcename) | 
 |  192   else: | 
 |  193     url = urlparse.urljoin(roots[type], sourcename) | 
 |  194  | 
|  190   logging.info("Cloning repository %s into %s" % (url, target)) |  195   logging.info("Cloning repository %s into %s" % (url, target)) | 
|  191   repo_types[type].clone(url, target) |  196   repo_types[type].clone(url, target) | 
|  192  |  197  | 
|  193   for repo in repo_types.itervalues(): |  198   for repo in repo_types.itervalues(): | 
|  194     if repo.istype(parentrepo): |  199     if repo.istype(parentrepo): | 
|  195       repo.ignore(target, parentrepo) |  200       repo.ignore(target, parentrepo) | 
|  196  |  201  | 
|  197 def update_repo(target, revisions): |  202 def update_repo(target, revisions): | 
|  198   type = get_repo_type(target) |  203   type = get_repo_type(target) | 
|  199   if type is None: |  204   if type is None: | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  271     file_content = [l.strip() for l in f.readlines()] |  276     file_content = [l.strip() for l in f.readlines()] | 
|  272     if not pattern in file_content: |  277     if not pattern in file_content: | 
|  273       file_content.append(pattern) |  278       file_content.append(pattern) | 
|  274       f.seek(0, os.SEEK_SET) |  279       f.seek(0, os.SEEK_SET) | 
|  275       f.truncate() |  280       f.truncate() | 
|  276       for l in file_content: |  281       for l in file_content: | 
|  277         print >>f, l |  282         print >>f, l | 
|  278  |  283  | 
|  279 if __name__ == "__main__": |  284 if __name__ == "__main__": | 
|  280   logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) |  285   logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) | 
|  281   repos = sys.argv[1:] |  286  | 
 |  287   parser = argparse.ArgumentParser(description="Verify dependencies for a set of
      repositories, by default the repository of this script.") | 
 |  288   parser.add_argument("repos", metavar="repository", type=str, nargs="*", help="
     Repository path") | 
 |  289   parser.add_argument("-q", "--quiet", action="store_true", help="Suppress infor
     mational output") | 
 |  290   args = parser.parse_args() | 
 |  291  | 
 |  292   if args.quiet: | 
 |  293     logging.disable(logging.INFO) | 
 |  294  | 
 |  295   repos = args.repos | 
|  282   if not len(repos): |  296   if not len(repos): | 
|  283     repos = [os.getcwd()] |  297     repos = [os.path.dirname(__file__)] | 
|  284   for repo in repos: |  298   for repo in repos: | 
|  285     resolve_deps(repo) |  299     resolve_deps(repo) | 
| LEFT | RIGHT |