From 359bb6435f3d9107c62d8a462f0c057c3f5675ed Mon Sep 17 00:00:00 2001 From: "borenet@google.com" Date: Tue, 13 May 2014 17:28:19 +0000 Subject: [PATCH] gclient: fix --delete_unversioned_trees bug This occurs for svn checkouts when the DEPS change from: third_party/skia/gyp third_party/skia/include third_party/skia/src to: third_party/skia First, gclient deletes/moves third_party/skia to make room for the new checkout. When finished, it notices that the three subdirectories under skia are now "unversioned" according to .gclient_entries, even though they are part of Skia repo. On the bots, this causes them to be deleted. There is a check to determine whether the thought-to-be unversioned directories are actually subdirectories of another checkout, but it doesn't work in the svn case because the check assumes that, if they are subdirectories of another checkout, it must be an svn checkout. scm.GetCheckoutRoot() returns None because it can't find an svn checkout containing those subdirectories. None is not in gclient_entries, so the directories get deleted. BUG= Review URL: https://codereview.chromium.org/275103009 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@270133 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gclient.py b/gclient.py index 6147447da..3ac66e763 100755 --- a/gclient.py +++ b/gclient.py @@ -1314,7 +1314,21 @@ want to set 'managed': False in .gclient. prev_url, self.root_dir, entry_fixed, self.outbuf) # Check to see if this directory is now part of a higher-up checkout. - if scm.GetCheckoutRoot() in full_entries: + # The directory might be part of a git OR svn checkout. + scm_root = None + for scm_class in (gclient_scm.scm.GIT, gclient_scm.scm.SVN): + try: + scm_root = scm_class.GetCheckoutRoot(scm.checkout_path) + except subprocess2.CalledProcessError: + pass + if scm_root: + break + else: + logging.warning('Could not find checkout root for %s. Unable to ' + 'determine whether it is part of a higher-level ' + 'checkout, so not removing.' % entry) + continue + if scm_root in full_entries: logging.info('%s is part of a higher level checkout, not ' 'removing.', scm.GetCheckoutRoot()) continue