| OLD | NEW |
| 1 # Copyright 2009 Google Inc. All Rights Reserved. | 1 # Copyright 2009 Google Inc. All Rights Reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 # See the License for the specific language governing permissions and | 12 # See the License for the specific language governing permissions and |
| 13 # limitations under the License. | 13 # limitations under the License. |
| 14 | 14 |
| 15 | 15 |
| 16 import logging |
| 16 import os | 17 import os |
| 17 import re | 18 import re |
| 18 import subprocess | 19 import subprocess |
| 19 import sys | 20 import sys |
| 20 import xml.dom.minidom | 21 import xml.dom.minidom |
| 21 | 22 |
| 22 import gclient_utils | 23 import gclient_utils |
| 23 | 24 |
| 24 SVN_COMMAND = "svn" | 25 SVN_COMMAND = "svn" |
| 25 | 26 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 doesn't know about them. | 212 doesn't know about them. |
| 212 """ | 213 """ |
| 213 path = os.path.join(self._root_dir, self.relpath) | 214 path = os.path.join(self._root_dir, self.relpath) |
| 214 if not os.path.isdir(path): | 215 if not os.path.isdir(path): |
| 215 # svn revert won't work if the directory doesn't exist. It needs to | 216 # svn revert won't work if the directory doesn't exist. It needs to |
| 216 # checkout instead. | 217 # checkout instead. |
| 217 print("\n_____ %s is missing, synching instead" % self.relpath) | 218 print("\n_____ %s is missing, synching instead" % self.relpath) |
| 218 # Don't reuse the args. | 219 # Don't reuse the args. |
| 219 return self.update(options, [], file_list) | 220 return self.update(options, [], file_list) |
| 220 | 221 |
| 221 files = CaptureSVNStatus(path) | |
| 222 # Batch the command. | 222 # Batch the command. |
| 223 files_to_revert = [] | 223 files_to_revert = [] |
| 224 for file in files: | 224 for file in CaptureSVNStatus(path): |
| 225 file_path = os.path.join(path, file[1]) | 225 file_path = os.path.join(path, file[1]) |
| 226 if file_path[0][0] == 'X': |
| 227 # Ignore externals. |
| 228 continue |
| 229 |
| 226 print(file_path) | 230 print(file_path) |
| 227 # Unversioned file or unexpected unversioned file. | 231 # Unversioned file, unexpected unversioned files, switched directories |
| 228 if file[0][0] in ('?', '~'): | 232 # or conflicted trees. |
| 229 # Remove extraneous file. Also remove unexpected unversioned | 233 if file[0][0] in ('?', '~') or file[0][4] == 'S' or file[0][6] == 'C': |
| 230 # directories. svn won't touch them but we want to delete these. | 234 # Remove then since svn revert won't touch them. |
| 231 file_list.append(file_path) | |
| 232 try: | 235 try: |
| 236 # TODO(maruel): Look if it is a file or a directory. |
| 237 logging.info('os.remove(%s)' % file_path) |
| 233 os.remove(file_path) | 238 os.remove(file_path) |
| 234 except EnvironmentError: | 239 except EnvironmentError: |
| 240 logging.info('gclient_utils.RemoveDirectory(%s)' % file_path) |
| 235 gclient_utils.RemoveDirectory(file_path) | 241 gclient_utils.RemoveDirectory(file_path) |
| 236 | 242 |
| 237 if file[0][0] != '?': | 243 if file[0][0] != '?': |
| 238 # For any other status, svn revert will work. | 244 # For any other status, svn revert will work. |
| 239 file_list.append(file_path) | 245 file_list.append(file_path) |
| 240 files_to_revert.append(file[1]) | 246 files_to_revert.append(file[1]) |
| 241 | 247 |
| 242 # Revert them all at once. | 248 # Revert them all at once. |
| 243 if files_to_revert: | 249 if files_to_revert: |
| 244 accumulated_paths = [] | 250 accumulated_paths = [] |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 xml_props_status) | 574 xml_props_status) |
| 569 # Col 2 | 575 # Col 2 |
| 570 if wc_status[0].getAttribute('wc-locked') == 'true': | 576 if wc_status[0].getAttribute('wc-locked') == 'true': |
| 571 statuses[2] = 'L' | 577 statuses[2] = 'L' |
| 572 # Col 3 | 578 # Col 3 |
| 573 if wc_status[0].getAttribute('copied') == 'true': | 579 if wc_status[0].getAttribute('copied') == 'true': |
| 574 statuses[3] = '+' | 580 statuses[3] = '+' |
| 575 item = (''.join(statuses), file) | 581 item = (''.join(statuses), file) |
| 576 results.append(item) | 582 results.append(item) |
| 577 return results | 583 return results |
| OLD | NEW |