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 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 # GIT.CaptureStatus() uses 'dit diff' to compare to a specific SHA1 (the | 519 # GIT.CaptureStatus() uses 'dit diff' to compare to a specific SHA1 (the |
520 # merge-base by default), so doesn't include untracked files. So we use | 520 # merge-base by default), so doesn't include untracked files. So we use |
521 # 'git ls-files --directory --others --exclude-standard' here directly. | 521 # 'git ls-files --directory --others --exclude-standard' here directly. |
522 paths = scm.GIT.Capture( | 522 paths = scm.GIT.Capture( |
523 ['ls-files', '--directory', '--others', '--exclude-standard'], | 523 ['ls-files', '--directory', '--others', '--exclude-standard'], |
524 self.checkout_path) | 524 self.checkout_path) |
525 for path in (p for p in paths.splitlines() if p.endswith('/')): | 525 for path in (p for p in paths.splitlines() if p.endswith('/')): |
526 full_path = os.path.join(self.checkout_path, path) | 526 full_path = os.path.join(self.checkout_path, path) |
527 if not os.path.islink(full_path): | 527 if not os.path.islink(full_path): |
528 print('\n_____ removing unversioned directory %s' % path) | 528 print('\n_____ removing unversioned directory %s' % path) |
529 gclient_utils.RemoveDirectory(full_path) | 529 gclient_utils.rmtree(full_path) |
530 | 530 |
531 | 531 |
532 def revert(self, options, args, file_list): | 532 def revert(self, options, args, file_list): |
533 """Reverts local modifications. | 533 """Reverts local modifications. |
534 | 534 |
535 All reverted files will be appended to file_list. | 535 All reverted files will be appended to file_list. |
536 """ | 536 """ |
537 if not os.path.isdir(self.checkout_path): | 537 if not os.path.isdir(self.checkout_path): |
538 # revert won't work if the directory doesn't exist. It needs to | 538 # revert won't work if the directory doesn't exist. It needs to |
539 # checkout instead. | 539 # checkout instead. |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 if not options.force and not options.reset: | 1073 if not options.force and not options.reset: |
1074 # Look for local modifications but ignore unversioned files. | 1074 # Look for local modifications but ignore unversioned files. |
1075 for status in scm.SVN.CaptureStatus(None, self.checkout_path): | 1075 for status in scm.SVN.CaptureStatus(None, self.checkout_path): |
1076 if status[0][0] != '?': | 1076 if status[0][0] != '?': |
1077 raise gclient_utils.Error( | 1077 raise gclient_utils.Error( |
1078 ('Can\'t switch the checkout to %s; UUID don\'t match and ' | 1078 ('Can\'t switch the checkout to %s; UUID don\'t match and ' |
1079 'there is local changes in %s. Delete the directory and ' | 1079 'there is local changes in %s. Delete the directory and ' |
1080 'try again.') % (url, self.checkout_path)) | 1080 'try again.') % (url, self.checkout_path)) |
1081 # Ok delete it. | 1081 # Ok delete it. |
1082 print('\n_____ switching %s to a new checkout' % self.relpath) | 1082 print('\n_____ switching %s to a new checkout' % self.relpath) |
1083 gclient_utils.RemoveDirectory(self.checkout_path) | 1083 gclient_utils.rmtree(self.checkout_path) |
1084 # We need to checkout. | 1084 # We need to checkout. |
1085 command = ['checkout', url, self.checkout_path] | 1085 command = ['checkout', url, self.checkout_path] |
1086 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1086 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1087 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1087 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1088 return | 1088 return |
1089 | 1089 |
1090 # If the provided url has a revision number that matches the revision | 1090 # If the provided url has a revision number that matches the revision |
1091 # number of the existing directory, then we don't need to bother updating. | 1091 # number of the existing directory, then we don't need to bother updating. |
1092 if not options.force and str(from_info['Revision']) == revision: | 1092 if not options.force and str(from_info['Revision']) == revision: |
1093 if options.verbose or not forced_revision: | 1093 if options.verbose or not forced_revision: |
1094 print('\n_____ %s%s' % (self.relpath, rev_str)) | 1094 print('\n_____ %s%s' % (self.relpath, rev_str)) |
1095 else: | 1095 else: |
1096 command = ['update', self.checkout_path] | 1096 command = ['update', self.checkout_path] |
1097 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1097 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1098 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1098 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1099 | 1099 |
1100 # If --reset and --delete_unversioned_trees are specified, remove any | 1100 # If --reset and --delete_unversioned_trees are specified, remove any |
1101 # untracked files and directories. | 1101 # untracked files and directories. |
1102 if options.reset and options.delete_unversioned_trees: | 1102 if options.reset and options.delete_unversioned_trees: |
1103 for status in scm.SVN.CaptureStatus(None, self.checkout_path): | 1103 for status in scm.SVN.CaptureStatus(None, self.checkout_path): |
1104 full_path = os.path.join(self.checkout_path, status[1]) | 1104 full_path = os.path.join(self.checkout_path, status[1]) |
1105 if (status[0][0] == '?' | 1105 if (status[0][0] == '?' |
1106 and os.path.isdir(full_path) | 1106 and os.path.isdir(full_path) |
1107 and not os.path.islink(full_path)): | 1107 and not os.path.islink(full_path)): |
1108 print('\n_____ removing unversioned directory %s' % status[1]) | 1108 print('\n_____ removing unversioned directory %s' % status[1]) |
1109 gclient_utils.RemoveDirectory(full_path) | 1109 gclient_utils.rmtree(full_path) |
1110 | 1110 |
1111 def updatesingle(self, options, args, file_list): | 1111 def updatesingle(self, options, args, file_list): |
1112 filename = args.pop() | 1112 filename = args.pop() |
1113 if scm.SVN.AssertVersion("1.5")[0]: | 1113 if scm.SVN.AssertVersion("1.5")[0]: |
1114 if not os.path.exists(os.path.join(self.checkout_path, '.svn')): | 1114 if not os.path.exists(os.path.join(self.checkout_path, '.svn')): |
1115 # Create an empty checkout and then update the one file we want. Future | 1115 # Create an empty checkout and then update the one file we want. Future |
1116 # operations will only apply to the one file we checked out. | 1116 # operations will only apply to the one file we checked out. |
1117 command = ["checkout", "--depth", "empty", self.url, self.checkout_path] | 1117 command = ["checkout", "--depth", "empty", self.url, self.checkout_path] |
1118 self._Run(command, options, cwd=self._root_dir) | 1118 self._Run(command, options, cwd=self._root_dir) |
1119 if os.path.exists(os.path.join(self.checkout_path, filename)): | 1119 if os.path.exists(os.path.join(self.checkout_path, filename)): |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 new_command.append('--force') | 1262 new_command.append('--force') |
1263 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1263 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1264 new_command.extend(('--accept', 'theirs-conflict')) | 1264 new_command.extend(('--accept', 'theirs-conflict')) |
1265 elif options.manually_grab_svn_rev: | 1265 elif options.manually_grab_svn_rev: |
1266 new_command.append('--force') | 1266 new_command.append('--force') |
1267 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1267 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1268 new_command.extend(('--accept', 'postpone')) | 1268 new_command.extend(('--accept', 'postpone')) |
1269 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1269 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1270 new_command.extend(('--accept', 'postpone')) | 1270 new_command.extend(('--accept', 'postpone')) |
1271 return new_command | 1271 return new_command |
OLD | NEW |