Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: git_cache.py

Issue 216013002: Suppress spurious warning about overriding cache dir. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """A git command for managing a local cache of git repositories.""" 6 """A git command for managing a local cache of git repositories."""
7 7
8 import errno 8 import errno
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 self.add_option('-v', '--verbose', action='count', default=0, 283 self.add_option('-v', '--verbose', action='count', default=0,
284 help='Increase verbosity (can be passed multiple times)') 284 help='Increase verbosity (can be passed multiple times)')
285 285
286 def parse_args(self, args=None, values=None): 286 def parse_args(self, args=None, values=None):
287 options, args = optparse.OptionParser.parse_args(self, args, values) 287 options, args = optparse.OptionParser.parse_args(self, args, values)
288 288
289 try: 289 try:
290 global_cache_dir = subprocess.check_output( 290 global_cache_dir = subprocess.check_output(
291 [GIT_EXECUTABLE, 'config', '--global', 'cache.cachepath']).strip() 291 [GIT_EXECUTABLE, 'config', '--global', 'cache.cachepath']).strip()
292 if options.cache_dir: 292 if options.cache_dir:
293 logging.warn('Overriding globally-configured cache directory.') 293 if global_cache_dir and (
294 os.path.abspath(options.cache_dir) !=
295 os.path.abspath(global_cache_dir)):
296 logging.warn('Overriding globally-configured cache directory.')
294 else: 297 else:
295 options.cache_dir = global_cache_dir 298 options.cache_dir = global_cache_dir
296 except subprocess.CalledProcessError: 299 except subprocess.CalledProcessError:
297 if not options.cache_dir: 300 if not options.cache_dir:
298 self.error('No cache directory specified on command line ' 301 self.error('No cache directory specified on command line '
299 'or in cache.cachepath.') 302 'or in cache.cachepath.')
300 options.cache_dir = os.path.abspath(options.cache_dir) 303 options.cache_dir = os.path.abspath(options.cache_dir)
301 304
302 levels = [logging.WARNING, logging.INFO, logging.DEBUG] 305 levels = [logging.WARNING, logging.INFO, logging.DEBUG]
303 logging.basicConfig(level=levels[min(options.verbose, len(levels) - 1)]) 306 logging.basicConfig(level=levels[min(options.verbose, len(levels) - 1)])
304 307
305 return options, args 308 return options, args
306 309
307 310
308 def main(argv): 311 def main(argv):
309 dispatcher = subcommand.CommandDispatcher(__name__) 312 dispatcher = subcommand.CommandDispatcher(__name__)
310 return dispatcher.execute(OptionParser(), argv) 313 return dispatcher.execute(OptionParser(), argv)
311 314
312 315
313 if __name__ == '__main__': 316 if __name__ == '__main__':
314 sys.exit(main(sys.argv[1:])) 317 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698