diff --git a/gclient.py b/gclient.py index f71eccc4c3..5b159edb04 100755 --- a/gclient.py +++ b/gclient.py @@ -1134,6 +1134,9 @@ solutions = [ # Only delete the directory if there are no changes in it, and # delete_unversioned_trees is set to true. entries = [i.name for i in self.root.subtree(False) if i.url] + full_entries = [os.path.join(self.root_dir, e.replace('/', os.path.sep)) + for e in entries] + for entry, prev_url in self._ReadEntries().iteritems(): if not prev_url: # entry must have been overridden via .gclient custom_deps @@ -1152,8 +1155,15 @@ solutions = [ if (entry not in entries and (not any(path.startswith(entry + '/') for path in entries)) and os.path.exists(e_dir)): - file_list = [] scm = gclient_scm.CreateSCM(prev_url, self.root_dir, entry_fixed) + + # Check to see if this directory is now part of a higher-up checkout. + if scm.GetCheckoutRoot() in full_entries: + logging.info('%s is part of a higher level checkout, not ' + 'removing.', scm.GetCheckoutRoot()) + continue + + file_list = [] scm.status(self._options, [], file_list) modified_files = file_list != [] if (not self._options.delete_unversioned_trees or diff --git a/gclient_scm.py b/gclient_scm.py index ba49f050c6..01dfd54675 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -173,6 +173,9 @@ class GitWrapper(SCMWrapper): except OSError: return False + def GetCheckoutRoot(self): + return scm.GIT.GetCheckoutRoot(self.checkout_path) + def GetRevisionDate(self, revision): """Returns the given revision's date in ISO-8601 format (which contains the time zone).""" @@ -920,6 +923,9 @@ class SVNWrapper(SCMWrapper): except OSError: return False + def GetCheckoutRoot(self): + return scm.SVN.GetCheckoutRoot(self.checkout_path) + def GetRevisionDate(self, revision): """Returns the given revision's date in ISO-8601 format (which contains the time zone).""" diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 5f5af69b6c..6cc7927d2f 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -102,6 +102,7 @@ class SVNWrapperTestCase(BaseTestCase): members = [ 'BinaryExists', 'FullUrlForRelativeUrl', + 'GetCheckoutRoot', 'GetRevisionDate', 'GetUsableRev', 'RunCommand', @@ -789,6 +790,7 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): members = [ 'BinaryExists', 'FullUrlForRelativeUrl', + 'GetCheckoutRoot', 'GetRevisionDate', 'GetUsableRev', 'RunCommand',