Chromium Code Reviews| Index: gclient.py |
| diff --git a/gclient.py b/gclient.py |
| index d1b5a8733859fb76b7cc28e825b941f19ad8ab01..507913db56d2e1a32f8134380058af56f002a132 100755 |
| --- a/gclient.py |
| +++ b/gclient.py |
| @@ -668,6 +668,53 @@ 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(): |
| + """This function determines whether the new behavior of deleting |
|
M-A Ruel
2014/01/13 17:31:39
"""Determines ..
borenet
2014/01/13 18:17:57
Done.
|
| + checkouts which conflict with those in DEPS should be enabled. It |
|
M-A Ruel
2014/01/13 17:31:39
Empty line between one liner summary and detailed
borenet
2014/01/13 18:17:57
Done.
|
| + enables the new functionality on a small set of bots initially.""" |
| + # TODO(borenet): Remove this hack as soon as we've verified that it |
| + # doesn't cause the bots to break. |
| + import socket |
|
M-A Ruel
2014/01/13 17:31:39
I'd prefer the import at the top of the file. Even
borenet
2014/01/13 18:17:57
Done.
|
| + return (socket.gethostname() in ('vm859-m1', 'build1-m1', 'vm630-m1') |
| + and os.environ.get('CHROME_HEADLESS')) |
|
M-A Ruel
2014/01/13 17:31:39
You should inverse the check. Checking for os.envi
borenet
2014/01/13 18:17:57
Done.
|
| + |
| + def should_delete_conflicting_checkout(options): |
| + """Determine whether a checkout which conflicts with the DEPS entry |
|
M-A Ruel
2014/01/13 17:31:39
imperactive
|
| + should be deleted. Returns True if running with --force or when |
|
M-A Ruel
2014/01/13 17:31:39
empty line
|
| + running on a bot. Otherwise, prompts for deletion.""" |
| + should_delete = options.force or os.environ.get('CHROME_HEADLESS') |
|
M-A Ruel
2014/01/13 17:31:39
Do not use an environment variable to determine th
|
| + if sys.__stdout__.isatty() and not should_delete: |
| + 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') |
| + return should_delete |
| + |
| + # 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()): |
|
M-A Ruel
2014/01/13 17:31:39
() are not needed
borenet
2014/01/13 18:17:57
Done.
|
| + 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 should_delete_conflicting_checkout(options): |
| + 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: |