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

Side by Side Diff: git_cache.py

Issue 485663003: Non-destructive editing of git cache config. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 4 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 from __future__ import print_function 8 from __future__ import print_function
9 import errno 9 import errno
10 import logging 10 import logging
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 # not stuck. 236 # not stuck.
237 self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd) 237 self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd)
238 238
239 # Allocate more RAM for cache-ing delta chains, for better performance 239 # Allocate more RAM for cache-ing delta chains, for better performance
240 # of "Resolving deltas". 240 # of "Resolving deltas".
241 self.RunGit(['config', 'core.deltaBaseCacheLimit', 241 self.RunGit(['config', 'core.deltaBaseCacheLimit',
242 gclient_utils.DefaultDeltaBaseCacheLimit()], cwd=cwd) 242 gclient_utils.DefaultDeltaBaseCacheLimit()], cwd=cwd)
243 243
244 self.RunGit(['config', 'remote.origin.url', self.url], cwd=cwd) 244 self.RunGit(['config', 'remote.origin.url', self.url], cwd=cwd)
245 self.RunGit(['config', '--replace-all', 'remote.origin.fetch', 245 self.RunGit(['config', '--replace-all', 'remote.origin.fetch',
246 '+refs/heads/*:refs/heads/*'], cwd=cwd) 246 '+refs/heads/*:refs/heads/*', r'\+refs/heads/\*:.*'], cwd=cwd)
247 for ref in self.refs: 247 for ref in self.refs:
248 ref = ref.lstrip('+').rstrip('/') 248 ref = ref.lstrip('+').rstrip('/')
249 if ref.startswith('refs/'): 249 if ref.startswith('refs/'):
250 refspec = '+%s:%s' % (ref, ref) 250 refspec = '+%s:%s' % (ref, ref)
251 regex = r'\+%s:.*' % ref.replace('*', r'\*')
251 else: 252 else:
252 refspec = '+refs/%s/*:refs/%s/*' % (ref, ref) 253 refspec = '+refs/%s/*:refs/%s/*' % (ref, ref)
253 self.RunGit(['config', '--add', 'remote.origin.fetch', refspec], cwd=cwd) 254 regex = r'\+refs/heads/%s:.*' % ref.replace('*', r'\*')
255 self.RunGit(
256 ['config', '--replace-all', 'remote.origin.fetch', refspec, regex],
257 cwd=cwd)
254 258
255 def bootstrap_repo(self, directory): 259 def bootstrap_repo(self, directory):
256 """Bootstrap the repo from Google Stroage if possible. 260 """Bootstrap the repo from Google Stroage if possible.
257 261
258 More apt-ly named bootstrap_repo_from_cloud_if_possible_else_do_nothing(). 262 More apt-ly named bootstrap_repo_from_cloud_if_possible_else_do_nothing().
259 """ 263 """
260 264
261 python_fallback = False 265 python_fallback = False
262 if sys.platform.startswith('win') and not self.FindExecutable('7z'): 266 if sys.platform.startswith('win') and not self.FindExecutable('7z'):
263 python_fallback = True 267 python_fallback = True
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 return options, args 685 return options, args
682 686
683 687
684 def main(argv): 688 def main(argv):
685 dispatcher = subcommand.CommandDispatcher(__name__) 689 dispatcher = subcommand.CommandDispatcher(__name__)
686 return dispatcher.execute(OptionParser(), argv) 690 return dispatcher.execute(OptionParser(), argv)
687 691
688 692
689 if __name__ == '__main__': 693 if __name__ == '__main__':
690 sys.exit(main(sys.argv[1:])) 694 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