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

Unified Diff: gclient_scm.py

Issue 225403015: gclient: Actually move or delete mismatched checkouts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Only delete directory on the bots, otherwise just move it, even with --force Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | tests/gclient_scm_test.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index e17702c5475c36114e783381c6d1be550187a02d..0cf2d313bb4ec3cbc6d7006b909d733a47398c99 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -6,6 +6,7 @@
from __future__ import print_function
+import errno
import logging
import os
import posixpath
@@ -20,6 +21,7 @@ import download_from_google_storage
import gclient_utils
import git_cache
import scm
+import shutil
import subprocess2
@@ -196,21 +198,36 @@ class SCMWrapper(object):
# valid git or svn checkout.
return False
- # TODO(borenet): Remove this once SCMWrapper._DeleteOrMove is enabled.
- # pylint: disable=R0201
def _DeleteOrMove(self, force):
"""Delete the checkout directory or move it out of the way.
Args:
force: bool; if True, delete the directory. Otherwise, just move it.
"""
- gclient_utils.AddWarning('WARNING: Upcoming change in '
- 'https://codereview.chromium.org/225403015 would '
- 'cause %s to be deleted or moved to the side. '
- 'This is intended to ease changes to DEPS in the '
- 'future. If you are seeing this warning and '
- 'haven\'t changed the DEPS file, please contact '
- 'borenet@ immediately.' % self.checkout_path)
+ if force and os.environ.get('CHROME_HEADLESS') == '1':
+ self.Print('_____ Conflicting directory found in %s. Removing.'
+ % self.checkout_path)
+ gclient_utils.AddWarning('Conflicting directory %s deleted.'
+ % self.checkout_path)
+ gclient_utils.rmtree(self.checkout_path)
+ else:
+ bad_scm_dir = os.path.join(self._root_dir, '_bad_scm',
+ os.path.dirname(self.relpath))
+
+ try:
+ os.makedirs(bad_scm_dir)
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+
+ dest_path = tempfile.mkdtemp(
+ prefix=os.path.basename(self.relpath),
+ dir=bad_scm_dir)
+ self.Print('_____ Conflicting directory found in %s. Moving to %s.'
+ % (self.checkout_path, dest_path))
+ gclient_utils.AddWarning('Conflicting directory %s moved to %s.'
+ % (self.checkout_path, dest_path))
+ shutil.move(self.checkout_path, dest_path)
class GitWrapper(SCMWrapper):
@@ -1088,8 +1105,8 @@ class SVNWrapper(SCMWrapper):
'svn-remote.svn.url'],
cwd=self.checkout_path).rstrip()
if remote_url.rstrip('/') == base_url.rstrip('/'):
- print('\n_____ %s looks like a git-svn checkout. Skipping.'
- % self.relpath)
+ self.Print('\n_____ %s looks like a git-svn checkout. Skipping.'
+ % self.relpath)
return # TODO(borenet): Get the svn revision number?
# Get the existing scm url and the revision number of the current checkout.
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | tests/gclient_scm_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698