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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 options.revision) | 913 options.revision) |
914 self._Run(command, options, cwd=self._root_dir) | 914 self._Run(command, options, cwd=self._root_dir) |
915 | 915 |
916 def revert(self, options, args, file_list): | 916 def revert(self, options, args, file_list): |
917 """Reverts local modifications. Subversion specific. | 917 """Reverts local modifications. Subversion specific. |
918 | 918 |
919 All reverted files will be appended to file_list, even if Subversion | 919 All reverted files will be appended to file_list, even if Subversion |
920 doesn't know about them. | 920 doesn't know about them. |
921 """ | 921 """ |
922 if not os.path.isdir(self.checkout_path): | 922 if not os.path.isdir(self.checkout_path): |
| 923 if os.path.exists(self.checkout_path): |
| 924 gclient_utils.rmtree(self.checkout_path) |
923 # svn revert won't work if the directory doesn't exist. It needs to | 925 # svn revert won't work if the directory doesn't exist. It needs to |
924 # checkout instead. | 926 # checkout instead. |
925 print('\n_____ %s is missing, synching instead' % self.relpath) | 927 print('\n_____ %s is missing, synching instead' % self.relpath) |
926 # Don't reuse the args. | 928 # Don't reuse the args. |
927 return self.update(options, [], file_list) | 929 return self.update(options, [], file_list) |
928 | 930 |
| 931 if not os.path.isdir(os.path.join(self.checkout_path, '.svn')): |
| 932 if os.path.isdir(os.path.join(self.checkout_path, '.git')): |
| 933 print('________ found .git directory; skipping %s' % self.relpath) |
| 934 return |
| 935 if os.path.isdir(os.path.join(self.checkout_path, '.hg')): |
| 936 print('________ found .hg directory; skipping %s' % self.relpath) |
| 937 return |
| 938 if not options.force: |
| 939 raise gclient_utils.Error('Invalid checkout path, aborting') |
| 940 print( |
| 941 '\n_____ %s is not a valid svn checkout, synching instead' % |
| 942 self.relpath) |
| 943 gclient_utils.rmtree(self.checkout_path) |
| 944 # Don't reuse the args. |
| 945 return self.update(options, [], file_list) |
| 946 |
929 def printcb(file_status): | 947 def printcb(file_status): |
930 file_list.append(file_status[1]) | 948 file_list.append(file_status[1]) |
931 if logging.getLogger().isEnabledFor(logging.INFO): | 949 if logging.getLogger().isEnabledFor(logging.INFO): |
932 logging.info('%s%s' % (file_status[0], file_status[1])) | 950 logging.info('%s%s' % (file_status[0], file_status[1])) |
933 else: | 951 else: |
934 print(os.path.join(self.checkout_path, file_status[1])) | 952 print(os.path.join(self.checkout_path, file_status[1])) |
935 scm.SVN.Revert(self.checkout_path, callback=printcb) | 953 scm.SVN.Revert(self.checkout_path, callback=printcb) |
936 | 954 |
937 try: | 955 try: |
938 # svn revert is so broken we don't even use it. Using | 956 # svn revert is so broken we don't even use it. Using |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 | 1010 |
993 This method returns a new list to be used as a command.""" | 1011 This method returns a new list to be used as a command.""" |
994 new_command = command[:] | 1012 new_command = command[:] |
995 if revision: | 1013 if revision: |
996 new_command.extend(['--revision', str(revision).strip()]) | 1014 new_command.extend(['--revision', str(revision).strip()]) |
997 # --force was added to 'svn update' in svn 1.5. | 1015 # --force was added to 'svn update' in svn 1.5. |
998 if ((options.force or options.manually_grab_svn_rev) and | 1016 if ((options.force or options.manually_grab_svn_rev) and |
999 scm.SVN.AssertVersion("1.5")[0]): | 1017 scm.SVN.AssertVersion("1.5")[0]): |
1000 new_command.append('--force') | 1018 new_command.append('--force') |
1001 return new_command | 1019 return new_command |
OLD | NEW |