OLD | NEW |
---|---|
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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 to_info['Repository Root'], | 907 to_info['Repository Root'], |
908 self.relpath] | 908 self.relpath] |
909 self._Run(command, options, cwd=self._root_dir) | 909 self._Run(command, options, cwd=self._root_dir) |
910 from_info['URL'] = from_info['URL'].replace( | 910 from_info['URL'] = from_info['URL'].replace( |
911 from_info['Repository Root'], | 911 from_info['Repository Root'], |
912 to_info['Repository Root']) | 912 to_info['Repository Root']) |
913 else: | 913 else: |
914 if not options.force and not options.reset: | 914 if not options.force and not options.reset: |
915 # Look for local modifications but ignore unversioned files. | 915 # Look for local modifications but ignore unversioned files. |
916 for status in scm.SVN.CaptureStatus(None, self.checkout_path): | 916 for status in scm.SVN.CaptureStatus(None, self.checkout_path): |
917 if status[0] != '?': | 917 if status[0][0] != '?': |
918 raise gclient_utils.Error( | 918 raise gclient_utils.Error( |
919 ('Can\'t switch the checkout to %s; UUID don\'t match and ' | 919 ('Can\'t switch the checkout to %s; UUID don\'t match and ' |
920 'there is local changes in %s. Delete the directory and ' | 920 'there is local changes in %s. Delete the directory and ' |
921 'try again.') % (url, self.checkout_path)) | 921 'try again.') % (url, self.checkout_path)) |
922 # Ok delete it. | 922 # Ok delete it. |
923 print('\n_____ switching %s to a new checkout' % self.relpath) | 923 print('\n_____ switching %s to a new checkout' % self.relpath) |
924 gclient_utils.RemoveDirectory(self.checkout_path) | 924 gclient_utils.RemoveDirectory(self.checkout_path) |
925 # We need to checkout. | 925 # We need to checkout. |
926 command = ['checkout', url, self.checkout_path] | 926 command = ['checkout', url, self.checkout_path] |
927 command = self._AddAdditionalUpdateFlags(command, options, revision) | 927 command = self._AddAdditionalUpdateFlags(command, options, revision) |
928 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 928 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
929 return | 929 return |
930 | 930 |
931 # If the provided url has a revision number that matches the revision | 931 # If the provided url has a revision number that matches the revision |
932 # number of the existing directory, then we don't need to bother updating. | 932 # number of the existing directory, then we don't need to bother updating. |
933 if not options.force and str(from_info['Revision']) == revision: | 933 if not options.force and str(from_info['Revision']) == revision: |
934 if options.verbose or not forced_revision: | 934 if options.verbose or not forced_revision: |
935 print('\n_____ %s%s' % (self.relpath, rev_str)) | 935 print('\n_____ %s%s' % (self.relpath, rev_str)) |
936 return | 936 return |
937 | 937 |
938 command = ['update', self.checkout_path] | 938 command = ['update', self.checkout_path] |
939 command = self._AddAdditionalUpdateFlags(command, options, revision) | 939 command = self._AddAdditionalUpdateFlags(command, options, revision) |
940 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 940 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
941 | 941 |
942 # If --force is specified, remove directories which have been removed from | |
943 # the repository but which may still exist in the working copy. | |
944 if options.force: | |
M-A Ruel
2012/02/10 01:43:55
I'd prefer to start with:
if options.force and opt
| |
945 # Note that we don't check to see if the directory is ignored, as when | |
946 # moving a directory from the main repository to deps/, we'd like to be | |
947 # able to set svn:ignore in the same change. | |
948 for status in scm.SVN.CaptureStatus(file_list, self.checkout_path, False): | |
949 path = os.path.join(self.checkout_path, status[1]) | |
950 if status[0][0] == '?' and os.path.isdir(path): | |
951 print('\n_____ removing unversioned directory %s' % status[1]) | |
952 gclient_utils.RemoveDirectory(path) | |
953 | |
942 def updatesingle(self, options, args, file_list): | 954 def updatesingle(self, options, args, file_list): |
943 filename = args.pop() | 955 filename = args.pop() |
944 if scm.SVN.AssertVersion("1.5")[0]: | 956 if scm.SVN.AssertVersion("1.5")[0]: |
945 if not os.path.exists(os.path.join(self.checkout_path, '.svn')): | 957 if not os.path.exists(os.path.join(self.checkout_path, '.svn')): |
946 # Create an empty checkout and then update the one file we want. Future | 958 # Create an empty checkout and then update the one file we want. Future |
947 # operations will only apply to the one file we checked out. | 959 # operations will only apply to the one file we checked out. |
948 command = ["checkout", "--depth", "empty", self.url, self.checkout_path] | 960 command = ["checkout", "--depth", "empty", self.url, self.checkout_path] |
949 self._Run(command, options, cwd=self._root_dir) | 961 self._Run(command, options, cwd=self._root_dir) |
950 if os.path.exists(os.path.join(self.checkout_path, filename)): | 962 if os.path.exists(os.path.join(self.checkout_path, filename)): |
951 os.remove(os.path.join(self.checkout_path, filename)) | 963 os.remove(os.path.join(self.checkout_path, filename)) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1093 new_command.append('--force') | 1105 new_command.append('--force') |
1094 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1106 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1095 new_command.extend(('--accept', 'theirs-conflict')) | 1107 new_command.extend(('--accept', 'theirs-conflict')) |
1096 elif options.manually_grab_svn_rev: | 1108 elif options.manually_grab_svn_rev: |
1097 new_command.append('--force') | 1109 new_command.append('--force') |
1098 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1110 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1099 new_command.extend(('--accept', 'postpone')) | 1111 new_command.extend(('--accept', 'postpone')) |
1100 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1112 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1101 new_command.extend(('--accept', 'postpone')) | 1113 new_command.extend(('--accept', 'postpone')) |
1102 return new_command | 1114 return new_command |
OLD | NEW |