Chromium Code Reviews| Index: gclient.py |
| diff --git a/gclient.py b/gclient.py |
| index d1b5a8733859fb76b7cc28e825b941f19ad8ab01..9af52928cbaffd64a1199229b591e90ad2ffb1fc 100755 |
| --- a/gclient.py |
| +++ b/gclient.py |
| @@ -668,6 +668,41 @@ 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) |
| + |
| + # 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. |
| + # TODO(borenet): Only enabling this on a few bots at first. |
| + import socket |
| + if (command == 'update' and |
| + socket.gethostname() in ('vm859-m1', 'build1-m1', 'vm630-m1') and |
|
M-A Ruel
2014/01/10 16:41:47
Extract this in a function. I highly dislike this,
borenet
2014/01/10 19:27:23
Done. When this is submitted, I will submit a try
|
| + os.environ.get('CHROME_HEADLESS')): |
| + 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: |
| + should_delete = options.force or os.environ.get('CHROME_HEADLESS') |
| + if sys.__stdout__.isatty() and not should_delete: |
|
M-A Ruel
2014/01/10 16:41:47
Move the check/prompt into a function.
This should
borenet
2014/01/10 19:27:23
Done. The prompt is not displayed with --force.
M-A Ruel
2014/01/13 17:31:38
Yes, I prefer failing to prompting.
Prompting the
borenet
2014/01/13 18:17:57
Done.
|
| + usr_input = '' |
| + while usr_input not in ('y', 'n'): |
| + usr_input = raw_input('%s does not contain a checkout of %s. ' |
| + 'Do you want to delete the directory? ' |
| + 'If not, the update will be canceled ' |
| + '(y/n): ' % (dest_dir, url)).lower() |
| + should_delete = (usr_input == 'y') |
| + if should_delete: |
| + 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. ' |
| + 'Please fix the solution manually or ' |
| + 'run with --force to delete ' |
| + 'automatically.' % (dest_dir, url)) |
| + |
| self._got_revision = self._used_scm.RunCommand(command, options, args, |
| file_list) |
| if file_list: |