Chromium Code Reviews| Index: gclient.py |
| diff --git a/gclient.py b/gclient.py |
| index 1f4801b9464af43a0bf9e252cde59053de0e23bf..69d8047775c42ce82ba98187c2e79ba1733d45fd 100755 |
| --- a/gclient.py |
| +++ b/gclient.py |
| @@ -66,6 +66,7 @@ Specifying a target OS |
| __version__ = "0.6.4" |
| +import collections |
| import copy |
| import logging |
| import optparse |
| @@ -75,6 +76,7 @@ import posixpath |
| import pprint |
| import re |
| import sys |
| +import threading |
| import urllib |
| import urlparse |
| @@ -1543,9 +1545,20 @@ def CMDsync(parser, args): |
| 'actual HEAD revision from the repository') |
| parser.add_option('--upstream', action='store_true', |
| help='Make repo state match upstream branch.') |
| + parser.add_option('--cache-dir', |
| + help='For git, cache all repos into this dir and do shared ' |
| + 'clones from the cache, instead of cloning directly ' |
| + 'from the remote.') |
| (options, args) = parser.parse_args(args) |
| client = GClient.LoadCurrentConfig(options) |
| + if options.cache_dir: |
| + # If a given cache is used in a solution more than once, prevent multiple |
| + # threads from updating it simultaneously. |cache_lock| is used to prevent |
| + # races on the defaultdict's construction of Locks. |
| + 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
|
| + options.cache_locks = collections.defaultdict(threading.Lock) |
| + |
| if not client: |
| raise gclient_utils.Error('client not configured; see \'gclient config\'') |