Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: gclient.py

Issue 14583004: Don't delete directories that have been superseded by a broader checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Rebase onto latest master. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gclient_scm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Meta checkout manager supporting both Subversion and GIT. 6 """Meta checkout manager supporting both Subversion and GIT.
7 7
8 Files 8 Files
9 .gclient : Current client configuration, written by 'config' command. 9 .gclient : Current client configuration, written by 'config' command.
10 Format is a Python script defining 'solutions', a list whose 10 Format is a Python script defining 'solutions', a list whose
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 # Once all the dependencies have been processed, it's now safe to run the 1127 # Once all the dependencies have been processed, it's now safe to run the
1128 # hooks. 1128 # hooks.
1129 if not self._options.nohooks: 1129 if not self._options.nohooks:
1130 self.RunHooksRecursively(self._options) 1130 self.RunHooksRecursively(self._options)
1131 1131
1132 if command == 'update': 1132 if command == 'update':
1133 # Notify the user if there is an orphaned entry in their working copy. 1133 # Notify the user if there is an orphaned entry in their working copy.
1134 # Only delete the directory if there are no changes in it, and 1134 # Only delete the directory if there are no changes in it, and
1135 # delete_unversioned_trees is set to true. 1135 # delete_unversioned_trees is set to true.
1136 entries = [i.name for i in self.root.subtree(False) if i.url] 1136 entries = [i.name for i in self.root.subtree(False) if i.url]
1137 full_entries = [os.path.join(self.root_dir, e.replace('/', os.path.sep))
1138 for e in entries]
1139
1137 for entry, prev_url in self._ReadEntries().iteritems(): 1140 for entry, prev_url in self._ReadEntries().iteritems():
1138 if not prev_url: 1141 if not prev_url:
1139 # entry must have been overridden via .gclient custom_deps 1142 # entry must have been overridden via .gclient custom_deps
1140 continue 1143 continue
1141 # Fix path separator on Windows. 1144 # Fix path separator on Windows.
1142 entry_fixed = entry.replace('/', os.path.sep) 1145 entry_fixed = entry.replace('/', os.path.sep)
1143 e_dir = os.path.join(self.root_dir, entry_fixed) 1146 e_dir = os.path.join(self.root_dir, entry_fixed)
1144 1147
1145 def _IsParentOfAny(parent, path_list): 1148 def _IsParentOfAny(parent, path_list):
1146 parent_plus_slash = parent + '/' 1149 parent_plus_slash = parent + '/'
1147 return any( 1150 return any(
1148 path[:len(parent_plus_slash)] == parent_plus_slash 1151 path[:len(parent_plus_slash)] == parent_plus_slash
1149 for path in path_list) 1152 for path in path_list)
1150 1153
1151 # Use entry and not entry_fixed there. 1154 # Use entry and not entry_fixed there.
1152 if (entry not in entries and 1155 if (entry not in entries and
1153 (not any(path.startswith(entry + '/') for path in entries)) and 1156 (not any(path.startswith(entry + '/') for path in entries)) and
1154 os.path.exists(e_dir)): 1157 os.path.exists(e_dir)):
1158 scm = gclient_scm.CreateSCM(prev_url, self.root_dir, entry_fixed)
1159
1160 # Check to see if this directory is now part of a higher-up checkout.
1161 if scm.GetCheckoutRoot() in full_entries:
1162 logging.info('%s is part of a higher level checkout, not '
1163 'removing.', scm.GetCheckoutRoot())
1164 continue
1165
1155 file_list = [] 1166 file_list = []
1156 scm = gclient_scm.CreateSCM(prev_url, self.root_dir, entry_fixed)
1157 scm.status(self._options, [], file_list) 1167 scm.status(self._options, [], file_list)
1158 modified_files = file_list != [] 1168 modified_files = file_list != []
1159 if (not self._options.delete_unversioned_trees or 1169 if (not self._options.delete_unversioned_trees or
1160 (modified_files and not self._options.force)): 1170 (modified_files and not self._options.force)):
1161 # There are modified files in this entry. Keep warning until 1171 # There are modified files in this entry. Keep warning until
1162 # removed. 1172 # removed.
1163 print(('\nWARNING: \'%s\' is no longer part of this client. ' 1173 print(('\nWARNING: \'%s\' is no longer part of this client. '
1164 'It is recommended that you manually remove it.\n') % 1174 'It is recommended that you manually remove it.\n') %
1165 entry_fixed) 1175 entry_fixed)
1166 else: 1176 else:
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1799 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1790 print >> sys.stderr, 'Error: %s' % str(e) 1800 print >> sys.stderr, 'Error: %s' % str(e)
1791 return 1 1801 return 1
1792 1802
1793 1803
1794 if '__main__' == __name__: 1804 if '__main__' == __name__:
1795 fix_encoding.fix_encoding() 1805 fix_encoding.fix_encoding()
1796 sys.exit(Main(sys.argv[1:])) 1806 sys.exit(Main(sys.argv[1:]))
1797 1807
1798 # vim: ts=2:sw=2:tw=80:et: 1808 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | gclient_scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698