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

Side by Side Diff: gclient_scm.py

Issue 43273005: Remove git_filter=True from git cache_dir commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 1 month 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 # 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 collections 7 import collections
8 import logging 8 import logging
9 import os 9 import os
10 import posixpath 10 import posixpath
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 gclient_utils.safe_makedirs(self.cache_dir) 794 gclient_utils.safe_makedirs(self.cache_dir)
795 if not os.path.exists(os.path.join(folder, 'config')): 795 if not os.path.exists(os.path.join(folder, 'config')):
796 gclient_utils.rmtree(folder) 796 gclient_utils.rmtree(folder)
797 cmd = ['clone'] + v + ['-c', 'core.deltaBaseCacheLimit=2g', 797 cmd = ['clone'] + v + ['-c', 'core.deltaBaseCacheLimit=2g',
798 '--progress', '--mirror'] 798 '--progress', '--mirror']
799 799
800 if use_reference: 800 if use_reference:
801 cmd += ['--reference', os.path.abspath(self.checkout_path)] 801 cmd += ['--reference', os.path.abspath(self.checkout_path)]
802 802
803 self._Run(cmd + [url, folder], 803 self._Run(cmd + [url, folder],
804 options, git_filter=True, filter_fn=filter_fn, 804 options, filter_fn=filter_fn, cwd=self.cache_dir, retry=True)
805 cwd=self.cache_dir, retry=True)
806 else: 805 else:
807 # For now, assert that host/path/to/repo.git is identical. We may want 806 # For now, assert that host/path/to/repo.git is identical. We may want
808 # to relax this restriction in the future to allow for smarter cache 807 # to relax this restriction in the future to allow for smarter cache
809 # repo update schemes (such as pulling the same repo, but from a 808 # repo update schemes (such as pulling the same repo, but from a
810 # different host). 809 # different host).
811 existing_url = self._Capture(['config', 'remote.origin.url'], 810 existing_url = self._Capture(['config', 'remote.origin.url'],
812 cwd=folder) 811 cwd=folder)
813 assert self._NormalizeGitURL(existing_url) == self._NormalizeGitURL(url) 812 assert self._NormalizeGitURL(existing_url) == self._NormalizeGitURL(url)
814 813
815 if use_reference: 814 if use_reference:
816 with open(altfile, 'w') as f: 815 with open(altfile, 'w') as f:
817 f.write(os.path.abspath(checkout_objects)) 816 f.write(os.path.abspath(checkout_objects))
818 817
819 # Would normally use `git remote update`, but it doesn't support 818 # Would normally use `git remote update`, but it doesn't support
820 # --progress, so use fetch instead. 819 # --progress, so use fetch instead.
821 self._Run(['fetch'] + v + ['--multiple', '--progress', '--all'], 820 self._Run(['fetch'] + v + ['--multiple', '--progress', '--all'],
822 options, git_filter=True, filter_fn=filter_fn, cwd=folder, 821 options, filter_fn=filter_fn, cwd=folder, retry=True)
823 retry=True)
824 822
825 # If the clone has an object dependency on the existing repo, break it 823 # If the clone has an object dependency on the existing repo, break it
826 # with repack and remove the linkage. 824 # with repack and remove the linkage.
827 if os.path.exists(altfile): 825 if os.path.exists(altfile):
828 self._Run(['repack', '-a'], options, cwd=folder) 826 self._Run(['repack', '-a'], options, cwd=folder)
829 os.remove(altfile) 827 os.remove(altfile)
830 return folder 828 return folder
831 829
832 def _Clone(self, revision, url, options): 830 def _Clone(self, revision, url, options):
833 """Clone a git repository from the given URL. 831 """Clone a git repository from the given URL.
(...skipping 18 matching lines...) Expand all
852 clone_cmd.append(url) 850 clone_cmd.append(url)
853 # If the parent directory does not exist, Git clone on Windows will not 851 # If the parent directory does not exist, Git clone on Windows will not
854 # create it, so we need to do it manually. 852 # create it, so we need to do it manually.
855 parent_dir = os.path.dirname(self.checkout_path) 853 parent_dir = os.path.dirname(self.checkout_path)
856 gclient_utils.safe_makedirs(parent_dir) 854 gclient_utils.safe_makedirs(parent_dir)
857 tmp_dir = tempfile.mkdtemp( 855 tmp_dir = tempfile.mkdtemp(
858 prefix='_gclient_%s_' % os.path.basename(self.checkout_path), 856 prefix='_gclient_%s_' % os.path.basename(self.checkout_path),
859 dir=parent_dir) 857 dir=parent_dir)
860 try: 858 try:
861 clone_cmd.append(tmp_dir) 859 clone_cmd.append(tmp_dir)
862 self._Run(clone_cmd, options, cwd=self._root_dir, git_filter=True, 860 self._Run(clone_cmd, options, cwd=self._root_dir, retry=True)
863 retry=True)
864 gclient_utils.safe_makedirs(self.checkout_path) 861 gclient_utils.safe_makedirs(self.checkout_path)
865 gclient_utils.safe_rename(os.path.join(tmp_dir, '.git'), 862 gclient_utils.safe_rename(os.path.join(tmp_dir, '.git'),
866 os.path.join(self.checkout_path, '.git')) 863 os.path.join(self.checkout_path, '.git'))
867 finally: 864 finally:
868 if os.listdir(tmp_dir): 865 if os.listdir(tmp_dir):
869 print('\n_____ removing non-empty tmp dir %s' % tmp_dir) 866 print('\n_____ removing non-empty tmp dir %s' % tmp_dir)
870 gclient_utils.rmtree(tmp_dir) 867 gclient_utils.rmtree(tmp_dir)
871 if revision.startswith('refs/heads/'): 868 if revision.startswith('refs/heads/'):
872 self._Run( 869 self._Run(
873 ['checkout', '--quiet', revision.replace('refs/heads/', '')], options) 870 ['checkout', '--quiet', revision.replace('refs/heads/', '')], options)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 config_cmd = ['config', 'remote.origin.fetch', 1027 config_cmd = ['config', 'remote.origin.fetch',
1031 '+refs/branch-heads/*:refs/remotes/branch-heads/*', 1028 '+refs/branch-heads/*:refs/remotes/branch-heads/*',
1032 '^\\+refs/branch-heads/\\*:.*$'] 1029 '^\\+refs/branch-heads/\\*:.*$']
1033 self._Run(config_cmd, options) 1030 self._Run(config_cmd, options)
1034 if fetch: 1031 if fetch:
1035 fetch_cmd = ['-c', 'core.deltaBaseCacheLimit=2g', 'fetch', 'origin'] 1032 fetch_cmd = ['-c', 'core.deltaBaseCacheLimit=2g', 'fetch', 'origin']
1036 if options.verbose: 1033 if options.verbose:
1037 fetch_cmd.append('--verbose') 1034 fetch_cmd.append('--verbose')
1038 self._Run(fetch_cmd, options, retry=True) 1035 self._Run(fetch_cmd, options, retry=True)
1039 1036
1040 def _Run(self, args, _options, git_filter=False, **kwargs): 1037 def _Run(self, args, options, **kwargs):
1041 kwargs.setdefault('cwd', self.checkout_path) 1038 kwargs.setdefault('cwd', self.checkout_path)
1039 git_filter = not options.verbose
1042 if git_filter: 1040 if git_filter:
iannucci 2013/10/25 18:54:43 I'd combine this, but I'm pretty indifferent.
1043 kwargs['filter_fn'] = GitFilter(kwargs.get('filter_fn')) 1041 kwargs['filter_fn'] = GitFilter(kwargs.get('filter_fn'))
1044 kwargs.setdefault('print_stdout', False) 1042 kwargs.setdefault('print_stdout', False)
1045 # Don't prompt for passwords; just fail quickly and noisily. 1043 # Don't prompt for passwords; just fail quickly and noisily.
1046 # By default, git will use an interactive terminal prompt when a username/ 1044 # By default, git will use an interactive terminal prompt when a username/
1047 # password is needed. That shouldn't happen in the chromium workflow, 1045 # password is needed. That shouldn't happen in the chromium workflow,
1048 # and if it does, then gclient may hide the prompt in the midst of a flood 1046 # and if it does, then gclient may hide the prompt in the midst of a flood
1049 # of terminal spew. The only indication that something has gone wrong 1047 # of terminal spew. The only indication that something has gone wrong
1050 # will be when gclient hangs unresponsively. Instead, we disable the 1048 # will be when gclient hangs unresponsively. Instead, we disable the
1051 # password prompt and simply allow git to fail noisily. The error 1049 # password prompt and simply allow git to fail noisily. The error
1052 # message produced by git will be copied to gclient's output. 1050 # message produced by git will be copied to gclient's output.
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 new_command.append('--force') 1450 new_command.append('--force')
1453 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1451 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1454 new_command.extend(('--accept', 'theirs-conflict')) 1452 new_command.extend(('--accept', 'theirs-conflict'))
1455 elif options.manually_grab_svn_rev: 1453 elif options.manually_grab_svn_rev:
1456 new_command.append('--force') 1454 new_command.append('--force')
1457 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1455 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1458 new_command.extend(('--accept', 'postpone')) 1456 new_command.extend(('--accept', 'postpone'))
1459 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1457 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1460 new_command.extend(('--accept', 'postpone')) 1458 new_command.extend(('--accept', 'postpone'))
1461 return new_command 1459 return new_command
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