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

Side by Side Diff: gclient_scm.py

Issue 12616006: Revert 186598 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 9 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 | « gclient.py ('k') | 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 logging 7 import logging
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 print('') 648 print('')
649 649
650 clone_cmd = ['clone', '--progress'] 650 clone_cmd = ['clone', '--progress']
651 if revision.startswith('refs/heads/'): 651 if revision.startswith('refs/heads/'):
652 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) 652 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')])
653 detach_head = False 653 detach_head = False
654 else: 654 else:
655 detach_head = True 655 detach_head = True
656 if options.verbose: 656 if options.verbose:
657 clone_cmd.append('--verbose') 657 clone_cmd.append('--verbose')
658 if options.with_branch_heads:
659 clone_cmd.extend(['--config', 'remote.origin.fetch=+refs/branch-heads/*:'
660 'refs/remotes/branch-heads/*'])
661 clone_cmd.extend([url, self.checkout_path]) 658 clone_cmd.extend([url, self.checkout_path])
662 659
663 # If the parent directory does not exist, Git clone on Windows will not 660 # If the parent directory does not exist, Git clone on Windows will not
664 # create it, so we need to do it manually. 661 # create it, so we need to do it manually.
665 parent_dir = os.path.dirname(self.checkout_path) 662 parent_dir = os.path.dirname(self.checkout_path)
666 if not os.path.exists(parent_dir): 663 if not os.path.exists(parent_dir):
667 gclient_utils.safe_makedirs(parent_dir) 664 gclient_utils.safe_makedirs(parent_dir)
668 665
669 percent_re = re.compile('.* ([0-9]{1,2})% .*') 666 percent_re = re.compile('.* ([0-9]{1,2})% .*')
670 def _GitFilter(line): 667 def _GitFilter(line):
671 # git uses an escape sequence to clear the line; elide it. 668 # git uses an escape sequence to clear the line; elide it.
672 esc = line.find(unichr(033)) 669 esc = line.find(unichr(033))
673 if esc > -1: 670 if esc > -1:
674 line = line[:esc] 671 line = line[:esc]
675 match = percent_re.match(line) 672 match = percent_re.match(line)
676 if not match or not int(match.group(1)) % 10: 673 if not match or not int(match.group(1)) % 10:
677 print '%s' % line 674 print '%s' % line
678 675
679 for _ in range(3): 676 for _ in range(3):
680 try: 677 try:
681 self._Run(clone_cmd, options, cwd=self._root_dir, filter_fn=_GitFilter, 678 self._Run(clone_cmd, options, cwd=self._root_dir, filter_fn=_GitFilter,
682 print_stdout=False) 679 print_stdout=False)
683 # Update the "branch-heads" remote-tracking branches, since clone
684 # doesn't automatically fetch those, and we might need it to checkout a
685 # specific revision below.
686 if options.with_branch_heads:
687 fetch_cmd = ['fetch', 'origin']
688 if options.verbose:
689 fetch_cmd.append('--verbose')
690 self._Run(fetch_cmd, options)
691 break 680 break
692 except subprocess2.CalledProcessError, e: 681 except subprocess2.CalledProcessError, e:
693 # Too bad we don't have access to the actual output yet. 682 # Too bad we don't have access to the actual output yet.
694 # We should check for "transfer closed with NNN bytes remaining to 683 # We should check for "transfer closed with NNN bytes remaining to
695 # read". In the meantime, just make sure .git exists. 684 # read". In the meantime, just make sure .git exists.
696 if (e.returncode == 128 and 685 if (e.returncode == 128 and
697 os.path.exists(os.path.join(self.checkout_path, '.git'))): 686 os.path.exists(os.path.join(self.checkout_path, '.git'))):
698 print(str(e)) 687 print(str(e))
699 print('Retrying...') 688 print('Retrying...')
700 continue 689 continue
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 new_command.append('--force') 1225 new_command.append('--force')
1237 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1226 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1238 new_command.extend(('--accept', 'theirs-conflict')) 1227 new_command.extend(('--accept', 'theirs-conflict'))
1239 elif options.manually_grab_svn_rev: 1228 elif options.manually_grab_svn_rev:
1240 new_command.append('--force') 1229 new_command.append('--force')
1241 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1230 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1242 new_command.extend(('--accept', 'postpone')) 1231 new_command.extend(('--accept', 'postpone'))
1243 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1232 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1244 new_command.extend(('--accept', 'postpone')) 1233 new_command.extend(('--accept', 'postpone'))
1245 return new_command 1234 return new_command
OLDNEW
« no previous file with comments | « gclient.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698