Commit 885a960b authored by xusydoc@chromium.org's avatar xusydoc@chromium.org

Don't delete directories that have been superseded by a broader checkout.

BUG=237388

Review URL: https://chromiumcodereview.appspot.com/14583004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@203384 0039d316-1c4b-4281-b951-d872f2087c98
parent 63a4d7fc
......@@ -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
......
......@@ -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)."""
......
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment