OLD | NEW |
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 from __future__ import print_function | 7 from __future__ import print_function |
8 | 8 |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 if os.path.exists(os.path.join(self.checkout_path, '.svn')): | 1189 if os.path.exists(os.path.join(self.checkout_path, '.svn')): |
1190 return self.Svnversion() | 1190 return self.Svnversion() |
1191 return | 1191 return |
1192 | 1192 |
1193 if 'URL' not in from_info: | 1193 if 'URL' not in from_info: |
1194 raise gclient_utils.Error( | 1194 raise gclient_utils.Error( |
1195 ('gclient is confused. Couldn\'t get the url for %s.\n' | 1195 ('gclient is confused. Couldn\'t get the url for %s.\n' |
1196 'Try using @unmanaged.\n%s') % ( | 1196 'Try using @unmanaged.\n%s') % ( |
1197 self.checkout_path, from_info)) | 1197 self.checkout_path, from_info)) |
1198 | 1198 |
1199 # Look for locked directories. | 1199 try: |
1200 dir_info = scm.SVN.CaptureStatus( | 1200 self._Run(['cleanup', self.checkout_path], options) |
1201 None, os.path.join(self.checkout_path, '.')) | 1201 except subprocess2.CalledProcessError, e: |
1202 if any(d[0][2] == 'L' for d in dir_info): | 1202 # Look for locked directories. |
1203 try: | 1203 dir_info = scm.SVN.CaptureStatus( |
1204 self._Run(['cleanup', self.checkout_path], options) | 1204 None, os.path.join(self.checkout_path, '.')) |
1205 except subprocess2.CalledProcessError, e: | 1205 if any(d[0][2] == 'L' for d in dir_info): |
1206 # Get the status again, svn cleanup may have cleaned up at least | |
1207 # something. | |
1208 dir_info = scm.SVN.CaptureStatus( | |
1209 None, os.path.join(self.checkout_path, '.')) | |
1210 | |
1211 # Try to fix the failures by removing troublesome files. | 1206 # Try to fix the failures by removing troublesome files. |
1212 for d in dir_info: | 1207 for d in dir_info: |
1213 if d[0][2] == 'L': | 1208 if d[0][2] == 'L': |
1214 if d[0][0] == '!' and options.force: | 1209 if d[0][0] == '!' and options.force: |
1215 # We don't pass any files/directories to CaptureStatus and set | 1210 # We don't pass any files/directories to CaptureStatus and set |
1216 # cwd=self.checkout_path, so we should get relative paths here. | 1211 # cwd=self.checkout_path, so we should get relative paths here. |
1217 assert not os.path.isabs(d[1]) | 1212 assert not os.path.isabs(d[1]) |
1218 path_to_remove = os.path.normpath( | 1213 path_to_remove = os.path.normpath( |
1219 os.path.join(self.checkout_path, d[1])) | 1214 os.path.join(self.checkout_path, d[1])) |
1220 self.Print('Removing troublesome path %s' % path_to_remove) | 1215 self.Print('Removing troublesome path %s' % path_to_remove) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 return | 1348 return |
1354 if not options.force: | 1349 if not options.force: |
1355 raise gclient_utils.Error('Invalid checkout path, aborting') | 1350 raise gclient_utils.Error('Invalid checkout path, aborting') |
1356 self.Print( | 1351 self.Print( |
1357 '\n_____ %s is not a valid svn checkout, synching instead' % | 1352 '\n_____ %s is not a valid svn checkout, synching instead' % |
1358 self.relpath) | 1353 self.relpath) |
1359 gclient_utils.rmtree(self.checkout_path) | 1354 gclient_utils.rmtree(self.checkout_path) |
1360 # Don't reuse the args. | 1355 # Don't reuse the args. |
1361 return self.update(options, [], file_list) | 1356 return self.update(options, [], file_list) |
1362 | 1357 |
| 1358 self._Run(['cleanup', self.checkout_path], options) |
| 1359 |
1363 def printcb(file_status): | 1360 def printcb(file_status): |
1364 if file_list is not None: | 1361 if file_list is not None: |
1365 file_list.append(file_status[1]) | 1362 file_list.append(file_status[1]) |
1366 if logging.getLogger().isEnabledFor(logging.INFO): | 1363 if logging.getLogger().isEnabledFor(logging.INFO): |
1367 logging.info('%s%s' % (file_status[0], file_status[1])) | 1364 logging.info('%s%s' % (file_status[0], file_status[1])) |
1368 else: | 1365 else: |
1369 self.Print(os.path.join(self.checkout_path, file_status[1])) | 1366 self.Print(os.path.join(self.checkout_path, file_status[1])) |
1370 scm.SVN.Revert(self.checkout_path, callback=printcb) | 1367 scm.SVN.Revert(self.checkout_path, callback=printcb) |
1371 | 1368 |
1372 # Revert() may delete the directory altogether. | 1369 # Revert() may delete the directory altogether. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 new_command.append('--force') | 1458 new_command.append('--force') |
1462 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1459 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1463 new_command.extend(('--accept', 'theirs-conflict')) | 1460 new_command.extend(('--accept', 'theirs-conflict')) |
1464 elif options.manually_grab_svn_rev: | 1461 elif options.manually_grab_svn_rev: |
1465 new_command.append('--force') | 1462 new_command.append('--force') |
1466 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1463 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1467 new_command.extend(('--accept', 'postpone')) | 1464 new_command.extend(('--accept', 'postpone')) |
1468 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1465 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1469 new_command.extend(('--accept', 'postpone')) | 1466 new_command.extend(('--accept', 'postpone')) |
1470 return new_command | 1467 return new_command |
OLD | NEW |