| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright 2008 Google Inc. All Rights Reserved. | 3 # Copyright 2008 Google Inc. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 ] | 65 ] |
| 66 """ | 66 """ |
| 67 | 67 |
| 68 __author__ = "darinf@gmail.com (Darin Fisher)" | 68 __author__ = "darinf@gmail.com (Darin Fisher)" |
| 69 __version__ = "0.3.3" | 69 __version__ = "0.3.3" |
| 70 | 70 |
| 71 import errno | 71 import errno |
| 72 import logging | 72 import logging |
| 73 import optparse | 73 import optparse |
| 74 import os | 74 import os |
| 75 import pprint |
| 75 import re | 76 import re |
| 76 import stat | 77 import stat |
| 77 import sys | 78 import sys |
| 78 import urlparse | 79 import urlparse |
| 79 import urllib | 80 import urllib |
| 80 | 81 |
| 81 import gclient_scm | 82 import gclient_scm |
| 82 import gclient_utils | 83 import gclient_utils |
| 83 from gclient_utils import Error, FileRead, FileWrite | 84 from gclient_utils import Error, FileRead, FileWrite |
| 84 | 85 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 }) | 368 }) |
| 368 | 369 |
| 369 def _SaveEntries(self, entries): | 370 def _SaveEntries(self, entries): |
| 370 """Creates a .gclient_entries file to record the list of unique checkouts. | 371 """Creates a .gclient_entries file to record the list of unique checkouts. |
| 371 | 372 |
| 372 The .gclient_entries file lives in the same directory as .gclient. | 373 The .gclient_entries file lives in the same directory as .gclient. |
| 373 | 374 |
| 374 Args: | 375 Args: |
| 375 entries: A sequence of solution names. | 376 entries: A sequence of solution names. |
| 376 """ | 377 """ |
| 377 text = "entries = [\n" | 378 text = "entries = \\\n" + pprint.pformat(entries, 2) + '\n' |
| 378 for entry in entries: | 379 file_path = os.path.join(self._root_dir, self._options.entries_filename) |
| 379 text += " \"%s\",\n" % entry | 380 FileWrite(file_path, text) |
| 380 text += "]\n" | |
| 381 FileWrite(os.path.join(self._root_dir, self._options.entries_filename), | |
| 382 text) | |
| 383 | 381 |
| 384 def _ReadEntries(self): | 382 def _ReadEntries(self): |
| 385 """Read the .gclient_entries file for the given client. | 383 """Read the .gclient_entries file for the given client. |
| 386 | 384 |
| 387 Args: | 385 Args: |
| 388 client: The client for which the entries file should be read. | 386 client: The client for which the entries file should be read. |
| 389 | 387 |
| 390 Returns: | 388 Returns: |
| 391 A sequence of solution names, which will be empty if there is the | 389 A sequence of solution names, which will be empty if there is the |
| 392 entries file hasn't been created yet. | 390 entries file hasn't been created yet. |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 # Notify the user if there is an orphaned entry in their working copy. | 739 # Notify the user if there is an orphaned entry in their working copy. |
| 742 # Only delete the directory if there are no changes in it, and | 740 # Only delete the directory if there are no changes in it, and |
| 743 # delete_unversioned_trees is set to true. | 741 # delete_unversioned_trees is set to true. |
| 744 prev_entries = self._ReadEntries() | 742 prev_entries = self._ReadEntries() |
| 745 for entry in prev_entries: | 743 for entry in prev_entries: |
| 746 # Fix path separator on Windows. | 744 # Fix path separator on Windows. |
| 747 entry_fixed = entry.replace('/', os.path.sep) | 745 entry_fixed = entry.replace('/', os.path.sep) |
| 748 e_dir = os.path.join(self._root_dir, entry_fixed) | 746 e_dir = os.path.join(self._root_dir, entry_fixed) |
| 749 # Use entry and not entry_fixed there. | 747 # Use entry and not entry_fixed there. |
| 750 if entry not in entries and os.path.exists(e_dir): | 748 if entry not in entries and os.path.exists(e_dir): |
| 751 if not self._options.delete_unversioned_trees or \ | 749 file_list = [] |
| 752 gclient_scm.CaptureSVNStatus(e_dir): | 750 scm = gclient_scm.CreateSCM(prev_entries[entry], self._root_dir, |
| 751 entry_fixed) |
| 752 scm.status(self._options, [], file_list) |
| 753 if not self._options.delete_unversioned_trees or file_list: |
| 753 # There are modified files in this entry. Keep warning until | 754 # There are modified files in this entry. Keep warning until |
| 754 # removed. | 755 # removed. |
| 755 entries[entry] = None | |
| 756 print(("\nWARNING: \"%s\" is no longer part of this client. " | 756 print(("\nWARNING: \"%s\" is no longer part of this client. " |
| 757 "It is recommended that you manually remove it.\n") % | 757 "It is recommended that you manually remove it.\n") % |
| 758 entry_fixed) | 758 entry_fixed) |
| 759 else: | 759 else: |
| 760 # Delete the entry | 760 # Delete the entry |
| 761 print("\n________ deleting \'%s\' " + | 761 print("\n________ deleting \'%s\' " + |
| 762 "in \'%s\'") % (entry_fixed, self._root_dir) | 762 "in \'%s\'") % (entry_fixed, self._root_dir) |
| 763 gclient_utils.RemoveDirectory(e_dir) | 763 gclient_utils.RemoveDirectory(e_dir) |
| 764 # record the current list of entries for next time | 764 # record the current list of entries for next time |
| 765 self._SaveEntries(entries) | 765 self._SaveEntries(entries) |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 | 1183 |
| 1184 if "__main__" == __name__: | 1184 if "__main__" == __name__: |
| 1185 try: | 1185 try: |
| 1186 result = Main(sys.argv) | 1186 result = Main(sys.argv) |
| 1187 except Error, e: | 1187 except Error, e: |
| 1188 print >> sys.stderr, "Error: %s" % str(e) | 1188 print >> sys.stderr, "Error: %s" % str(e) |
| 1189 result = 1 | 1189 result = 1 |
| 1190 sys.exit(result) | 1190 sys.exit(result) |
| 1191 | 1191 |
| 1192 # vim: ts=2:sw=2:tw=80:et: | 1192 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |