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

Side by Side Diff: gclient_scm.py

Issue 11366239: Remove more unversioned directories. (Closed) Base URL: https://git.chromium.org/chromium/tools/depot_tools.git@master
Patch Set: Use subprocess instead of scm module. Created 8 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
« no previous file with comments | « no previous file | tests/gclient_smoketest.py » ('j') | 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 # Reconstruct the url. 922 # Reconstruct the url.
923 url = '%s@%s' % (url, revision) 923 url = '%s@%s' % (url, revision)
924 rev_str = ' at %s' % revision 924 rev_str = ' at %s' % revision
925 else: 925 else:
926 managed = False 926 managed = False
927 revision = None 927 revision = None
928 else: 928 else:
929 forced_revision = False 929 forced_revision = False
930 rev_str = '' 930 rev_str = ''
931 931
932 if not os.path.exists(self.checkout_path): 932 # Get the existing scm url and the revision number of the current checkout.
933 exists = os.path.exists(self.checkout_path)
934 if exists and managed:
935 try:
936 from_info = scm.SVN.CaptureLocalInfo(
937 [], os.path.join(self.checkout_path, '.'))
938 except (gclient_utils.Error, subprocess2.CalledProcessError):
939 if options.reset and options.delete_unversioned_trees:
940 print 'Removing troublesome path %s' % self.checkout_path
941 gclient_utils.rmtree(self.checkout_path)
Peter Mayo 2012/11/14 22:30:25 How does this report errors (e.g. owned by root su
M-A Ruel 2012/11/14 23:17:32 That will throw, IMHO it's not a big deal to not c
Peter Mayo 2012/11/15 01:37:10 It's not a big deal to me either, it's just a way
942 exists = False
943 else:
944 msg = ('Can\'t update/checkout %s if an unversioned directory is '
945 'present. Delete the directory and try again.')
946 raise gclient_utils.Error(msg % self.checkout_path)
947
948 if not exists:
933 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) 949 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path))
934 # We need to checkout. 950 # We need to checkout.
935 command = ['checkout', url, self.checkout_path] 951 command = ['checkout', url, self.checkout_path]
936 command = self._AddAdditionalUpdateFlags(command, options, revision) 952 command = self._AddAdditionalUpdateFlags(command, options, revision)
937 self._RunAndGetFileList(command, options, file_list, self._root_dir) 953 self._RunAndGetFileList(command, options, file_list, self._root_dir)
938 return 954 return
939 955
940 if not managed: 956 if not managed:
941 print ('________ unmanaged solution; skipping %s' % self.relpath) 957 print ('________ unmanaged solution; skipping %s' % self.relpath)
942 return 958 return
943 959
944 # Get the existing scm url and the revision number of the current checkout.
945 try:
946 from_info = scm.SVN.CaptureLocalInfo(
947 [], os.path.join(self.checkout_path, '.'))
948 except (gclient_utils.Error, subprocess2.CalledProcessError):
949 raise gclient_utils.Error(
950 ('Can\'t update/checkout %s if an unversioned directory is present. '
951 'Delete the directory and try again.') % self.checkout_path)
952
953 if 'URL' not in from_info: 960 if 'URL' not in from_info:
954 raise gclient_utils.Error( 961 raise gclient_utils.Error(
955 ('gclient is confused. Couldn\'t get the url for %s.\n' 962 ('gclient is confused. Couldn\'t get the url for %s.\n'
956 'Try using @unmanaged.\n%s') % ( 963 'Try using @unmanaged.\n%s') % (
957 self.checkout_path, from_info)) 964 self.checkout_path, from_info))
958 965
959 # Look for locked directories. 966 # Look for locked directories.
960 dir_info = scm.SVN.CaptureStatus( 967 dir_info = scm.SVN.CaptureStatus(
961 None, os.path.join(self.checkout_path, '.')) 968 None, os.path.join(self.checkout_path, '.'))
962 if any(d[0][2] == 'L' for d in dir_info): 969 if any(d[0][2] == 'L' for d in dir_info):
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 new_command.append('--force') 1215 new_command.append('--force')
1209 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1216 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1210 new_command.extend(('--accept', 'theirs-conflict')) 1217 new_command.extend(('--accept', 'theirs-conflict'))
1211 elif options.manually_grab_svn_rev: 1218 elif options.manually_grab_svn_rev:
1212 new_command.append('--force') 1219 new_command.append('--force')
1213 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1220 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1214 new_command.extend(('--accept', 'postpone')) 1221 new_command.extend(('--accept', 'postpone'))
1215 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1222 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1216 new_command.extend(('--accept', 'postpone')) 1223 new_command.extend(('--accept', 'postpone'))
1217 return new_command 1224 return new_command
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698