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

Side by Side Diff: gclient_scm.py

Issue 12553006: Reapply r186598 with fix for 'gclient revert'. (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 | « 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 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 # Don't assume 'with_branch_heads' is added by 'gclient sync' setup, since
659 # _Clone() can by reached in roundabout ways (e.g. 'gclient revert').
660 if hasattr(options, 'with_branch_heads') and options.with_branch_heads:
661 clone_cmd.extend(['--config', 'remote.origin.fetch=+refs/branch-heads/*:'
662 'refs/remotes/branch-heads/*'])
658 clone_cmd.extend([url, self.checkout_path]) 663 clone_cmd.extend([url, self.checkout_path])
659 664
660 # If the parent directory does not exist, Git clone on Windows will not 665 # If the parent directory does not exist, Git clone on Windows will not
661 # create it, so we need to do it manually. 666 # create it, so we need to do it manually.
662 parent_dir = os.path.dirname(self.checkout_path) 667 parent_dir = os.path.dirname(self.checkout_path)
663 if not os.path.exists(parent_dir): 668 if not os.path.exists(parent_dir):
664 gclient_utils.safe_makedirs(parent_dir) 669 gclient_utils.safe_makedirs(parent_dir)
665 670
666 percent_re = re.compile('.* ([0-9]{1,2})% .*') 671 percent_re = re.compile('.* ([0-9]{1,2})% .*')
667 def _GitFilter(line): 672 def _GitFilter(line):
668 # git uses an escape sequence to clear the line; elide it. 673 # git uses an escape sequence to clear the line; elide it.
669 esc = line.find(unichr(033)) 674 esc = line.find(unichr(033))
670 if esc > -1: 675 if esc > -1:
671 line = line[:esc] 676 line = line[:esc]
672 match = percent_re.match(line) 677 match = percent_re.match(line)
673 if not match or not int(match.group(1)) % 10: 678 if not match or not int(match.group(1)) % 10:
674 print '%s' % line 679 print '%s' % line
675 680
676 for _ in range(3): 681 for _ in range(3):
677 try: 682 try:
678 self._Run(clone_cmd, options, cwd=self._root_dir, filter_fn=_GitFilter, 683 self._Run(clone_cmd, options, cwd=self._root_dir, filter_fn=_GitFilter,
679 print_stdout=False) 684 print_stdout=False)
685 # Update the "branch-heads" remote-tracking branches, since clone
686 # doesn't automatically fetch those, and we might need it to checkout a
687 # specific revision below.
688 if (hasattr(options, 'with_branch_heads') and
689 options.with_branch_heads):
690 fetch_cmd = ['fetch', 'origin']
691 if options.verbose:
692 fetch_cmd.append('--verbose')
693 self._Run(fetch_cmd, options)
680 break 694 break
681 except subprocess2.CalledProcessError, e: 695 except subprocess2.CalledProcessError, e:
682 # Too bad we don't have access to the actual output yet. 696 # Too bad we don't have access to the actual output yet.
683 # We should check for "transfer closed with NNN bytes remaining to 697 # We should check for "transfer closed with NNN bytes remaining to
684 # read". In the meantime, just make sure .git exists. 698 # read". In the meantime, just make sure .git exists.
685 if (e.returncode == 128 and 699 if (e.returncode == 128 and
686 os.path.exists(os.path.join(self.checkout_path, '.git'))): 700 os.path.exists(os.path.join(self.checkout_path, '.git'))):
687 print(str(e)) 701 print(str(e))
688 print('Retrying...') 702 print('Retrying...')
689 continue 703 continue
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 new_command.append('--force') 1239 new_command.append('--force')
1226 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1240 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1227 new_command.extend(('--accept', 'theirs-conflict')) 1241 new_command.extend(('--accept', 'theirs-conflict'))
1228 elif options.manually_grab_svn_rev: 1242 elif options.manually_grab_svn_rev:
1229 new_command.append('--force') 1243 new_command.append('--force')
1230 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1244 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1231 new_command.extend(('--accept', 'postpone')) 1245 new_command.extend(('--accept', 'postpone'))
1232 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1246 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1233 new_command.extend(('--accept', 'postpone')) 1247 new_command.extend(('--accept', 'postpone'))
1234 return new_command 1248 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