Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 by the list of matching files. | 59 by the list of matching files. |
| 60 | 60 |
| 61 Example: | 61 Example: |
| 62 hooks = [ | 62 hooks = [ |
| 63 { "pattern": "\\.(gif|jpe?g|pr0n|png)$", | 63 { "pattern": "\\.(gif|jpe?g|pr0n|png)$", |
| 64 "action": ["python", "image_indexer.py", "--all"]}, | 64 "action": ["python", "image_indexer.py", "--all"]}, |
| 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.4" |
| 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 pprint |
| 76 import re | 76 import re |
| 77 import sys | 77 import sys |
| 78 import urlparse | 78 import urlparse |
| 79 import urllib | 79 import urllib |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 # 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 |
| 741 # delete_unversioned_trees is set to true. | 741 # delete_unversioned_trees is set to true. |
| 742 prev_entries = self._ReadEntries() | 742 prev_entries = self._ReadEntries() |
| 743 for entry in prev_entries: | 743 for entry in prev_entries: |
| 744 # Fix path separator on Windows. | 744 # Fix path separator on Windows. |
| 745 entry_fixed = entry.replace('/', os.path.sep) | 745 entry_fixed = entry.replace('/', os.path.sep) |
| 746 e_dir = os.path.join(self._root_dir, entry_fixed) | 746 e_dir = os.path.join(self._root_dir, entry_fixed) |
| 747 # Use entry and not entry_fixed there. | 747 # Use entry and not entry_fixed there. |
| 748 if entry not in entries and os.path.exists(e_dir): | 748 if entry not in entries and os.path.exists(e_dir): |
| 749 modified_files = False | 749 modified_files = False |
| 750 if isinstance(prev_entries,list): | 750 if isinstance(prev_entries, list): |
| 751 # old .gclient_entries format was list, now dict | 751 # old .gclient_entries format was list, now dict |
| 752 modified_files = gclient_scm.CaptureSVNStatus(e_dir) | 752 modified_files = gclient_scm.scm.SVN.CaptureStatus(e_dir) |
|
Dirk Pranke
2009/11/13 22:42:54
why don't you just import scm directly?
M-A Ruel
2009/11/14 01:15:00
gclient should never reference a SCM directly. It
| |
| 753 else: | 753 else: |
| 754 file_list = [] | 754 file_list = [] |
| 755 scm = gclient_scm.CreateSCM(prev_entries[entry], self._root_dir, | 755 scm = gclient_scm.CreateSCM(prev_entries[entry], self._root_dir, |
| 756 entry_fixed) | 756 entry_fixed) |
| 757 scm.status(self._options, [], file_list) | 757 scm.status(self._options, [], file_list) |
| 758 modified_files = file_list != [] | 758 modified_files = file_list != [] |
| 759 if not self._options.delete_unversioned_trees or modified_files: | 759 if not self._options.delete_unversioned_trees or modified_files: |
| 760 # There are modified files in this entry. Keep warning until | 760 # There are modified files in this entry. Keep warning until |
| 761 # removed. | 761 # removed. |
| 762 print(("\nWARNING: \"%s\" is no longer part of this client. " | 762 print(("\nWARNING: \"%s\" is no longer part of this client. " |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 823 return (url, revision) | 823 return (url, revision) |
| 824 | 824 |
| 825 # Run on the base solutions first. | 825 # Run on the base solutions first. |
| 826 for solution in solutions: | 826 for solution in solutions: |
| 827 name = solution["name"] | 827 name = solution["name"] |
| 828 if name in entries: | 828 if name in entries: |
| 829 raise gclient_utils.Error("solution %s specified more than once" % name) | 829 raise gclient_utils.Error("solution %s specified more than once" % name) |
| 830 (url, rev) = GetURLAndRev(name, solution["url"]) | 830 (url, rev) = GetURLAndRev(name, solution["url"]) |
| 831 entries[name] = "%s@%s" % (url, rev) | 831 entries[name] = "%s@%s" % (url, rev) |
| 832 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) | 832 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) |
| 833 entries_deps_content[name] = gclient_scm.CaptureSVN( | 833 entries_deps_content[name] = gclient_scm.scm.SVN.Capture( |
| 834 ["cat", | 834 ["cat", |
| 835 "%s/%s@%s" % (url, | 835 "%s/%s@%s" % (url, |
| 836 self._options.deps_file, | 836 self._options.deps_file, |
| 837 rev)], | 837 rev)], |
| 838 os.getcwd()) | 838 os.getcwd()) |
| 839 | 839 |
| 840 # Process the dependencies next (sort alphanumerically to ensure that | 840 # Process the dependencies next (sort alphanumerically to ensure that |
| 841 # containing directories get populated first and for readability) | 841 # containing directories get populated first and for readability) |
| 842 deps = self._ParseAllDeps(entries, entries_deps_content) | 842 deps = self._ParseAllDeps(entries, entries_deps_content) |
| 843 deps_to_process = deps.keys() | 843 deps_to_process = deps.keys() |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1180 | 1180 |
| 1181 if "__main__" == __name__: | 1181 if "__main__" == __name__: |
| 1182 try: | 1182 try: |
| 1183 result = Main(sys.argv) | 1183 result = Main(sys.argv) |
| 1184 except gclient_utils.Error, e: | 1184 except gclient_utils.Error, e: |
| 1185 print >> sys.stderr, "Error: %s" % str(e) | 1185 print >> sys.stderr, "Error: %s" % str(e) |
| 1186 result = 1 | 1186 result = 1 |
| 1187 sys.exit(result) | 1187 sys.exit(result) |
| 1188 | 1188 |
| 1189 # vim: ts=2:sw=2:tw=80:et: | 1189 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |