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