Chromium Code Reviews| Index: gclient.py |
| diff --git a/gclient.py b/gclient.py |
| index c3e295c42e1dca0fff893a61352cfa7deee4fe36..e17238d11b6c278e0c750ba8dd99a522ee4a5d8b 100755 |
| --- a/gclient.py |
| +++ b/gclient.py |
| @@ -641,6 +641,36 @@ 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) |
| + 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 |
| + if not should_delete: |
| + if sys.__stdout__.isatty(): |
| + usr_input = None |
| + print ('%s does not contain a checkout of %s. Do you want to ' |
| + 'delete it before attempting to update?' % (dest_dir, |
| + url)) |
| + while usr_input not in ('y', 'n'): |
| + print 'Please type "y" or "n".' |
| + usr_input = raw_input() |
|
iannucci
2013/11/14 07:38:15
raw_input() takes a prompt, which would be a bit b
borenet
2013/11/14 18:31:21
Done.
|
| + should_delete = (usr_input == 'y') |
| + else: |
| + logging.warning('%s does not contain a checkout of %s. Not ' |
| + 'attempting to remove automatically. Re-run ' |
| + 'with "--force" to automatically remove ' |
| + 'conflicting checkouts.' % (dest_dir, url)) |
| + 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) |
| + |
|
borenet
2013/11/13 19:12:24
I'd like to point out that this causes some strang
iannucci
2013/11/14 07:38:15
I'm inclined to just abort if we didn't end up del
borenet
2013/11/14 18:31:21
Sounds fine to me, but I think it might also be ok
iannucci
2013/11/14 18:45:25
Yeah, I agree, the thing is that the gclient solut
borenet
2013/11/15 13:46:48
SGTM. Changed to raise Error if the directory isn
|
| self._got_revision = self._used_scm.RunCommand(command, options, args, |
| file_list) |
| if file_list: |