| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
| 4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 | 6 |
| 7 import sys | 7 import sys |
| 8 import os | 8 import os |
| 9 import posixpath | 9 import posixpath |
| 10 import re | 10 import re |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 module = os.path.sep + os.path.relpath(target, repo) | 129 module = os.path.sep + os.path.relpath(target, repo) |
| 130 exclude_file = os.path.join(repo, '.git', 'info', 'exclude') | 130 exclude_file = os.path.join(repo, '.git', 'info', 'exclude') |
| 131 _ensure_line_exists(exclude_file, module) | 131 _ensure_line_exists(exclude_file, module) |
| 132 | 132 |
| 133 def postprocess_url(self, url): | 133 def postprocess_url(self, url): |
| 134 # Handle alternative syntax of SSH URLS | 134 # Handle alternative syntax of SSH URLS |
| 135 if '@' in url and ':' in url and not urlparse.urlsplit(url).scheme: | 135 if '@' in url and ':' in url and not urlparse.urlsplit(url).scheme: |
| 136 return 'ssh://' + url.replace(':', '/', 1) | 136 return 'ssh://' + url.replace(':', '/', 1) |
| 137 return url | 137 return url |
| 138 | 138 |
| 139 |
| 139 repo_types = OrderedDict(( | 140 repo_types = OrderedDict(( |
| 140 ('hg', Mercurial()), | 141 ('hg', Mercurial()), |
| 141 ('git', Git()), | 142 ('git', Git()), |
| 142 )) | 143 )) |
| 143 | 144 |
| 144 # [vcs:]value | 145 # [vcs:]value |
| 145 item_regexp = re.compile( | 146 item_regexp = re.compile( |
| 146 '^(?:(' + '|'.join(map(re.escape, repo_types.keys())) + '):)?' | 147 '^(?:(' + '|'.join(map(re.escape, repo_types.keys())) + '):)?' |
| 147 '(.+)$' | 148 '(.+)$' |
| 148 ) | 149 ) |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 with open(path, 'a+') as f: | 400 with open(path, 'a+') as f: |
| 400 f.seek(0, os.SEEK_SET) | 401 f.seek(0, os.SEEK_SET) |
| 401 file_content = [l.strip() for l in f.readlines()] | 402 file_content = [l.strip() for l in f.readlines()] |
| 402 if not pattern in file_content: | 403 if not pattern in file_content: |
| 403 file_content.append(pattern) | 404 file_content.append(pattern) |
| 404 f.seek(0, os.SEEK_SET) | 405 f.seek(0, os.SEEK_SET) |
| 405 f.truncate() | 406 f.truncate() |
| 406 for l in file_content: | 407 for l in file_content: |
| 407 print >>f, l | 408 print >>f, l |
| 408 | 409 |
| 410 |
| 409 if __name__ == '__main__': | 411 if __name__ == '__main__': |
| 410 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) | 412 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) |
| 411 | 413 |
| 412 parser = argparse.ArgumentParser(description='Verify dependencies for a set
of repositories, by default the repository of this script.') | 414 parser = argparse.ArgumentParser(description='Verify dependencies for a set
of repositories, by default the repository of this script.') |
| 413 parser.add_argument('repos', metavar='repository', type=str, nargs='*', help
='Repository path') | 415 parser.add_argument('repos', metavar='repository', type=str, nargs='*', help
='Repository path') |
| 414 parser.add_argument('-q', '--quiet', action='store_true', help='Suppress inf
ormational output') | 416 parser.add_argument('-q', '--quiet', action='store_true', help='Suppress inf
ormational output') |
| 415 args = parser.parse_args() | 417 args = parser.parse_args() |
| 416 | 418 |
| 417 if args.quiet: | 419 if args.quiet: |
| 418 logging.disable(logging.INFO) | 420 logging.disable(logging.INFO) |
| 419 | 421 |
| 420 repos = args.repos | 422 repos = args.repos |
| 421 if not len(repos): | 423 if not len(repos): |
| 422 repos = [os.path.dirname(__file__)] | 424 repos = [os.path.dirname(__file__)] |
| 423 for repo in repos: | 425 for repo in repos: |
| 424 resolve_deps(repo) | 426 resolve_deps(repo) |
| OLD | NEW |