Chromium Code Reviews| Index: gclient.py |
| diff --git a/gclient.py b/gclient.py |
| index c3e295c42e1dca0fff893a61352cfa7deee4fe36..90513807dd3b961a3f2f395297211fd9f2ed581c 100755 |
| --- a/gclient.py |
| +++ b/gclient.py |
| @@ -641,6 +641,34 @@ 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. |
| + if command == 'update': |
| + actual_remote_url = self._used_scm.GetRemoteURL(options) |
| + url, _ = gclient_utils.SplitUrlRevision(parsed_url) |
|
Isaac (away)
2013/12/09 21:45:59
make sure this has substitions applied and is norm
borenet
2013/12/10 18:48:27
I tried overriding googlecode_url in the .gclient
|
| + 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 |
|
Isaac (away)
2013/12/09 21:45:59
Let's also use if env contains 'CHROME_HEADLESS'
borenet
2013/12/10 18:48:27
Done.
|
| + 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') |
| + 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: |