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

Side by Side Diff: gclient_scm.py

Issue 7942007: GTTF: Make gclient recover gracefully from an interrupted checkout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 # Get the existing scm url and the revision number of the current checkout. 774 # Get the existing scm url and the revision number of the current checkout.
775 try: 775 try:
776 from_info = scm.SVN.CaptureInfo(os.path.join(self.checkout_path, '.')) 776 from_info = scm.SVN.CaptureInfo(os.path.join(self.checkout_path, '.'))
777 except (gclient_utils.Error, subprocess2.CalledProcessError): 777 except (gclient_utils.Error, subprocess2.CalledProcessError):
778 raise gclient_utils.Error( 778 raise gclient_utils.Error(
779 ('Can\'t update/checkout %s if an unversioned directory is present. ' 779 ('Can\'t update/checkout %s if an unversioned directory is present. '
780 'Delete the directory and try again.') % self.checkout_path) 780 'Delete the directory and try again.') % self.checkout_path)
781 781
782 # Look for locked directories. 782 # Look for locked directories.
783 dir_info = scm.SVN.CaptureStatus(os.path.join(self.checkout_path, '.')) 783 dir_info = scm.SVN.CaptureStatus(os.path.join(self.checkout_path, '.'))
784 for d in dir_info: 784 if any(d[0][2] == 'L' for d in dir_info):
785 if d[0][2] == 'L': 785 try:
786 self._Run(['cleanup', d[1]], options) 786 self._Run(['cleanup', self.checkout_path], options)
787 except subprocess2.CalledProcessError, e:
788 # Get the status again, svn cleanup may have cleaned up at least
789 # something.
790 dir_info = scm.SVN.CaptureStatus(os.path.join(self.checkout_path, '.'))
791
792 # Try to fix the failures by removing troublesome files.
793 for d in dir_info:
794 if d[0][2] == 'L':
795 if d[0][0] == '!' and options.force:
796 print 'Removing troublesome path %s' % d[1]
797 gclient_utils.rmtree(d[1])
798 else:
799 print 'Not removing troublesome path %s automatically.' % d[1]
800 if d[0][0] == '!':
801 print 'You can pass --force to enable automatic removal.'
802 raise e
787 803
788 # Retrieve the current HEAD version because svn is slow at null updates. 804 # Retrieve the current HEAD version because svn is slow at null updates.
789 if options.manually_grab_svn_rev and not revision: 805 if options.manually_grab_svn_rev and not revision:
790 from_info_live = scm.SVN.CaptureInfo(from_info['URL']) 806 from_info_live = scm.SVN.CaptureInfo(from_info['URL'])
791 revision = str(from_info_live['Revision']) 807 revision = str(from_info_live['Revision'])
792 rev_str = ' at %s' % revision 808 rev_str = ' at %s' % revision
793 809
794 if from_info['URL'] != base_url: 810 if from_info['URL'] != base_url:
795 # The repository url changed, need to switch. 811 # The repository url changed, need to switch.
796 try: 812 try:
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 972
957 This method returns a new list to be used as a command.""" 973 This method returns a new list to be used as a command."""
958 new_command = command[:] 974 new_command = command[:]
959 if revision: 975 if revision:
960 new_command.extend(['--revision', str(revision).strip()]) 976 new_command.extend(['--revision', str(revision).strip()])
961 # --force was added to 'svn update' in svn 1.5. 977 # --force was added to 'svn update' in svn 1.5.
962 if ((options.force or options.manually_grab_svn_rev) and 978 if ((options.force or options.manually_grab_svn_rev) and
963 scm.SVN.AssertVersion("1.5")[0]): 979 scm.SVN.AssertVersion("1.5")[0]):
964 new_command.append('--force') 980 new_command.append('--force')
965 return new_command 981 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