OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Meta checkout manager supporting both Subversion and GIT. | 6 """Meta checkout manager supporting both Subversion and GIT. |
7 | 7 |
8 Files | 8 Files |
9 .gclient : Current client configuration, written by 'config' command. | 9 .gclient : Current client configuration, written by 'config' command. |
10 Format is a Python script defining 'solutions', a list whose | 10 Format is a Python script defining 'solutions', a list whose |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 If the "target_os_only" key is also present and true, then *only* the | 59 If the "target_os_only" key is also present and true, then *only* the |
60 operating systems listed in "target_os" will be used. | 60 operating systems listed in "target_os" will be used. |
61 | 61 |
62 Example: | 62 Example: |
63 target_os = [ "ios" ] | 63 target_os = [ "ios" ] |
64 target_os_only = True | 64 target_os_only = True |
65 """ | 65 """ |
66 | 66 |
67 __version__ = "0.6.4" | 67 __version__ = "0.6.4" |
68 | 68 |
69 import collections | |
69 import copy | 70 import copy |
70 import logging | 71 import logging |
71 import optparse | 72 import optparse |
72 import os | 73 import os |
73 import platform | 74 import platform |
74 import posixpath | 75 import posixpath |
75 import pprint | 76 import pprint |
76 import re | 77 import re |
77 import sys | 78 import sys |
79 import threading | |
78 import urllib | 80 import urllib |
79 import urlparse | 81 import urlparse |
80 | 82 |
81 import breakpad # pylint: disable=W0611 | 83 import breakpad # pylint: disable=W0611 |
82 | 84 |
83 import fix_encoding | 85 import fix_encoding |
84 import gclient_scm | 86 import gclient_scm |
85 import gclient_utils | 87 import gclient_utils |
86 from third_party.repo.progress import Progress | 88 from third_party.repo.progress import Progress |
87 import subprocess2 | 89 import subprocess2 |
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1536 'fast-forward or rebase') | 1538 'fast-forward or rebase') |
1537 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', | 1539 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', |
1538 help='override deps for the specified (comma-separated) ' | 1540 help='override deps for the specified (comma-separated) ' |
1539 'platform(s); \'all\' will process all deps_os ' | 1541 'platform(s); \'all\' will process all deps_os ' |
1540 'references') | 1542 'references') |
1541 parser.add_option('-m', '--manually_grab_svn_rev', action='store_true', | 1543 parser.add_option('-m', '--manually_grab_svn_rev', action='store_true', |
1542 help='Skip svn up whenever possible by requesting ' | 1544 help='Skip svn up whenever possible by requesting ' |
1543 'actual HEAD revision from the repository') | 1545 'actual HEAD revision from the repository') |
1544 parser.add_option('--upstream', action='store_true', | 1546 parser.add_option('--upstream', action='store_true', |
1545 help='Make repo state match upstream branch.') | 1547 help='Make repo state match upstream branch.') |
1548 parser.add_option('--cache-dir', | |
1549 help='For git, cache all repos into this dir and do shared ' | |
1550 'clones from the cache, instead of cloning directly ' | |
1551 'from the remote.') | |
1546 (options, args) = parser.parse_args(args) | 1552 (options, args) = parser.parse_args(args) |
1547 client = GClient.LoadCurrentConfig(options) | 1553 client = GClient.LoadCurrentConfig(options) |
1548 | 1554 |
1555 if options.cache_dir: | |
1556 # If a given cache is used in a solution more than once, prevent multiple | |
1557 # threads from updating it simultaneously. |cache_lock| is used to prevent | |
1558 # races on the defaultdict's construction of Locks. | |
1559 options.cache_lock = threading.Lock() | |
szager1
2013/07/01 23:38:29
options.cache_lock shouldn't be necessary; vivifyi
iannucci
2013/07/01 23:55:52
defaultdict guarantees that item addition is atomi
szager1
2013/07/02 00:08:05
As long as the __init__ method for the subject cla
| |
1560 options.cache_locks = collections.defaultdict(threading.Lock) | |
1561 | |
1549 if not client: | 1562 if not client: |
1550 raise gclient_utils.Error('client not configured; see \'gclient config\'') | 1563 raise gclient_utils.Error('client not configured; see \'gclient config\'') |
1551 | 1564 |
1552 if options.revisions and options.head: | 1565 if options.revisions and options.head: |
1553 # TODO(maruel): Make it a parser.error if it doesn't break any builder. | 1566 # TODO(maruel): Make it a parser.error if it doesn't break any builder. |
1554 print('Warning: you cannot use both --head and --revision') | 1567 print('Warning: you cannot use both --head and --revision') |
1555 | 1568 |
1556 if options.verbose: | 1569 if options.verbose: |
1557 # Print out the .gclient file. This is longer than if we just printed the | 1570 # Print out the .gclient file. This is longer than if we just printed the |
1558 # client dict, but more legible, and it might contain helpful comments. | 1571 # client dict, but more legible, and it might contain helpful comments. |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1807 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1820 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1808 print >> sys.stderr, 'Error: %s' % str(e) | 1821 print >> sys.stderr, 'Error: %s' % str(e) |
1809 return 1 | 1822 return 1 |
1810 | 1823 |
1811 | 1824 |
1812 if '__main__' == __name__: | 1825 if '__main__' == __name__: |
1813 fix_encoding.fix_encoding() | 1826 fix_encoding.fix_encoding() |
1814 sys.exit(Main(sys.argv[1:])) | 1827 sys.exit(Main(sys.argv[1:])) |
1815 | 1828 |
1816 # vim: ts=2:sw=2:tw=80:et: | 1829 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |