OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 gclient_utils.CheckCallAndFilter(cmd3 + ['always'], **kwargs) | 236 gclient_utils.CheckCallAndFilter(cmd3 + ['always'], **kwargs) |
237 | 237 |
238 gclient_utils.CheckCallAndFilter(cmd4, **kwargs) | 238 gclient_utils.CheckCallAndFilter(cmd4, **kwargs) |
239 | 239 |
240 def _FetchAndReset(self, revision, file_list, options): | 240 def _FetchAndReset(self, revision, file_list, options): |
241 """Equivalent to git fetch; git reset.""" | 241 """Equivalent to git fetch; git reset.""" |
242 quiet = [] | 242 quiet = [] |
243 if not options.verbose: | 243 if not options.verbose: |
244 quiet = ['--quiet'] | 244 quiet = ['--quiet'] |
245 self._UpdateBranchHeads(options, fetch=False) | 245 self._UpdateBranchHeads(options, fetch=False) |
246 self._Run(['fetch', 'origin', '--prune'] + quiet, options) | 246 |
| 247 fetch_cmd = [ |
| 248 '-c', 'core.deltaBaseCacheLimit=2g', 'fetch', 'origin', '--prune'] |
| 249 self._Run(fetch_cmd + quiet, options) |
247 self._Run(['reset', '--hard', revision] + quiet, options) | 250 self._Run(['reset', '--hard', revision] + quiet, options) |
248 self.UpdateSubmoduleConfig() | 251 self.UpdateSubmoduleConfig() |
249 files = self._Capture(['ls-files']).splitlines() | 252 files = self._Capture(['ls-files']).splitlines() |
250 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 253 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
251 | 254 |
252 def update(self, options, args, file_list): | 255 def update(self, options, args, file_list): |
253 """Runs git to update or transparently checkout the working copy. | 256 """Runs git to update or transparently checkout the working copy. |
254 | 257 |
255 All updated files will be appended to file_list. | 258 All updated files will be appended to file_list. |
256 | 259 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 358 |
356 if not self._IsValidGitRepo(): | 359 if not self._IsValidGitRepo(): |
357 # .git directory is hosed for some reason, set it back up. | 360 # .git directory is hosed for some reason, set it back up. |
358 print('_____ %s/.git is corrupted, rebuilding' % self.relpath) | 361 print('_____ %s/.git is corrupted, rebuilding' % self.relpath) |
359 self._Run(['init'], options) | 362 self._Run(['init'], options) |
360 self._Run(['remote', 'set-url', 'origin', url], options) | 363 self._Run(['remote', 'set-url', 'origin', url], options) |
361 | 364 |
362 if not self._HasHead(): | 365 if not self._HasHead(): |
363 # Previous checkout was aborted before branches could be created in repo, | 366 # Previous checkout was aborted before branches could be created in repo, |
364 # so we need to reconstruct them here. | 367 # so we need to reconstruct them here. |
365 self._Run(['pull', 'origin', 'master'], options) | 368 self._Run(['-c', 'core.deltaBaseCacheLimit=2g', 'pull', 'origin', |
| 369 'master'], options) |
366 self._FetchAndReset(revision, file_list, options) | 370 self._FetchAndReset(revision, file_list, options) |
367 | 371 |
368 cur_branch = self._GetCurrentBranch() | 372 cur_branch = self._GetCurrentBranch() |
369 | 373 |
370 # Cases: | 374 # Cases: |
371 # 0) HEAD is detached. Probably from our initial clone. | 375 # 0) HEAD is detached. Probably from our initial clone. |
372 # - make sure HEAD is contained by a named ref, then update. | 376 # - make sure HEAD is contained by a named ref, then update. |
373 # Cases 1-4. HEAD is a branch. | 377 # Cases 1-4. HEAD is a branch. |
374 # 1) current branch is not tracking a remote branch (could be git-svn) | 378 # 1) current branch is not tracking a remote branch (could be git-svn) |
375 # - try to rebase onto the new hash or branch | 379 # - try to rebase onto the new hash or branch |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 | 696 |
693 Once we've cloned the repo, we checkout a working branch if the specified | 697 Once we've cloned the repo, we checkout a working branch if the specified |
694 revision is a branch head. If it is a tag or a specific commit, then we | 698 revision is a branch head. If it is a tag or a specific commit, then we |
695 leave HEAD detached as it makes future updates simpler -- in this case the | 699 leave HEAD detached as it makes future updates simpler -- in this case the |
696 user should first create a new branch or switch to an existing branch before | 700 user should first create a new branch or switch to an existing branch before |
697 making changes in the repo.""" | 701 making changes in the repo.""" |
698 if not options.verbose: | 702 if not options.verbose: |
699 # git clone doesn't seem to insert a newline properly before printing | 703 # git clone doesn't seem to insert a newline properly before printing |
700 # to stdout | 704 # to stdout |
701 print('') | 705 print('') |
702 clone_cmd = ['clone', '--progress'] | 706 clone_cmd = ['-c', 'core.deltaBaseCacheLimit=2g', 'clone', '--progress'] |
703 if revision.startswith('refs/heads/'): | 707 if revision.startswith('refs/heads/'): |
704 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) | 708 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) |
705 detach_head = False | 709 detach_head = False |
706 else: | 710 else: |
707 detach_head = True | 711 detach_head = True |
708 if options.verbose: | 712 if options.verbose: |
709 clone_cmd.append('--verbose') | 713 clone_cmd.append('--verbose') |
710 clone_cmd.extend([url, self.checkout_path]) | 714 clone_cmd.extend([url, self.checkout_path]) |
711 | 715 |
712 # If the parent directory does not exist, Git clone on Windows will not | 716 # If the parent directory does not exist, Git clone on Windows will not |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" | 929 """Adds, and optionally fetches, "branch-heads" refspecs if requested.""" |
926 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: | 930 if hasattr(options, 'with_branch_heads') and options.with_branch_heads: |
927 backoff_time = 5 | 931 backoff_time = 5 |
928 for _ in range(3): | 932 for _ in range(3): |
929 try: | 933 try: |
930 config_cmd = ['config', 'remote.origin.fetch', | 934 config_cmd = ['config', 'remote.origin.fetch', |
931 '+refs/branch-heads/*:refs/remotes/branch-heads/*', | 935 '+refs/branch-heads/*:refs/remotes/branch-heads/*', |
932 '^\\+refs/branch-heads/\\*:.*$'] | 936 '^\\+refs/branch-heads/\\*:.*$'] |
933 self._Run(config_cmd, options) | 937 self._Run(config_cmd, options) |
934 if fetch: | 938 if fetch: |
935 fetch_cmd = ['fetch', 'origin'] | 939 fetch_cmd = ['-c', 'core.deltaBaseCacheLimit=2g', 'fetch', 'origin'] |
936 if options.verbose: | 940 if options.verbose: |
937 fetch_cmd.append('--verbose') | 941 fetch_cmd.append('--verbose') |
938 self._Run(fetch_cmd, options) | 942 self._Run(fetch_cmd, options) |
939 break | 943 break |
940 except subprocess2.CalledProcessError, e: | 944 except subprocess2.CalledProcessError, e: |
941 print(str(e)) | 945 print(str(e)) |
942 print('Retrying in %.1f seconds...' % backoff_time) | 946 print('Retrying in %.1f seconds...' % backoff_time) |
943 time.sleep(backoff_time) | 947 time.sleep(backoff_time) |
944 backoff_time *= 1.3 | 948 backoff_time *= 1.3 |
945 | 949 |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 new_command.append('--force') | 1340 new_command.append('--force') |
1337 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1341 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1338 new_command.extend(('--accept', 'theirs-conflict')) | 1342 new_command.extend(('--accept', 'theirs-conflict')) |
1339 elif options.manually_grab_svn_rev: | 1343 elif options.manually_grab_svn_rev: |
1340 new_command.append('--force') | 1344 new_command.append('--force') |
1341 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1345 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1342 new_command.extend(('--accept', 'postpone')) | 1346 new_command.extend(('--accept', 'postpone')) |
1343 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1347 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1344 new_command.extend(('--accept', 'postpone')) | 1348 new_command.extend(('--accept', 'postpone')) |
1345 return new_command | 1349 return new_command |
OLD | NEW |