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

Unified Diff: gclient.py

Issue 133073015: Re-reland r245404 ("If the destination directory doesn't contain the desired repo, delete it") (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Clean up check_output call, print hostname on bots Created 6 years, 10 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 | gclient_scm.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient.py
diff --git a/gclient.py b/gclient.py
index e2491cef1d39b1a80e6c6fcb3ae25fab676696bc..f68b01ebf2f8acec9a9e6616a39b9bd56f098cdf 100755
--- a/gclient.py
+++ b/gclient.py
@@ -87,6 +87,7 @@ import platform
import posixpath
import pprint
import re
+import socket
import sys
import time
import urllib
@@ -668,6 +669,43 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
command, options, parsed_url, self.parent.name, revision_overrides)
self._used_scm = gclient_scm.CreateSCM(
parsed_url, self.root.root_dir, self.name)
+
+ def enable_deletion_of_conflicting_checkouts():
+ """Determines whether to enable new checkout deletion behavior.
+
+ Initially, enables the experimental functionality on a small set of
+ bots.
+ """
+ # TODO(borenet): Remove this hack as soon as we've verified that it
+ # doesn't cause the bots to break.
+ if not os.environ.get('CHROME_HEADLESS'):
+ return False
+ hostname = socket.gethostname()
+ logging.warning('Hostname of this machine: %s' % hostname)
+ return hostname in ('vm859-m1', 'build1-m1', 'vm630-m1')
+
+ # When updating, determine whether the destination directory contains a
+ # checkout of the desired repository. If not, avoid conflicts by
+ # deleting the directory before running the update.
+ if command == 'update' and enable_deletion_of_conflicting_checkouts():
+ logging.warning('Experimental deletion of mismatching checkouts '
+ 'enabled.')
+ actual_remote_url = self._used_scm.GetRemoteURL(options)
+ url, _ = gclient_utils.SplitUrlRevision(parsed_url)
+ url = url.rstrip('/')
+ dest_dir = os.path.join(self.root.root_dir, self.name)
+ if os.path.isdir(dest_dir) and actual_remote_url != url:
+ if options.force:
+ logging.warning('%s does not contain a checkout of %s. Removing '
+ ' %s' % (dest_dir, url, dest_dir))
+ gclient_utils.rmtree(dest_dir)
+ else:
+ raise gclient_utils.Error('%s does not contain a checkout of %s '
+ '(found %s instead). Please fix the '
+ 'solution manually or run with --force '
+ 'to delete automatically.' % (
+ dest_dir, url, actual_remote_url))
+
self._got_revision = self._used_scm.RunCommand(command, options, args,
file_list)
if file_list:
« 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