Chromium Code Reviews| Index: gclient_scm.py |
| =================================================================== |
| --- gclient_scm.py (revision 120967) |
| +++ gclient_scm.py (working copy) |
| @@ -442,6 +442,22 @@ |
| if verbose: |
| print('Checked out revision %s' % self.revinfo(options, (), None)) |
| + # If --force is specified, remove any untracked directories. |
| + if options.force: |
| + # GIT.CaptureStatus() uses 'dit diff' to compare to a specific SHA1 (the |
| + # merge-base by default), so doesn't include untracked files. So we use |
| + # 'git ls-files --directory --others --exclude-standard' here directly. |
| + paths = scm.GIT.Capture( |
| + ['ls-files', '--directory', '--others', '--exclude-standard'], |
|
M-A Ruel
2012/02/08 14:43:46
Note that this will be overzealous if .gitignore i
Steve Block
2012/02/09 17:55:04
I think that in this case, we want to delete untra
|
| + self.checkout_path) |
| + if paths: |
| + for path in paths.splitlines(): |
| + if path.endswith('/'): |
| + print('\n_____ removing unversioned directory %s' % path) |
| + gclient_utils.RemoveDirectory(os.path.join(self.checkout_path, |
| + path)) |
| + |
| + |
| def revert(self, options, args, file_list): |
| """Reverts local modifications. |
| @@ -914,7 +930,7 @@ |
| if not options.force and not options.reset: |
| # Look for local modifications but ignore unversioned files. |
| for status in scm.SVN.CaptureStatus(None, self.checkout_path): |
| - if status[0] != '?': |
| + if status[0][0] != '?': |
|
M-A Ruel
2012/02/08 14:43:46
Eh, that was bad.
|
| raise gclient_utils.Error( |
| ('Can\'t switch the checkout to %s; UUID don\'t match and ' |
| 'there is local changes in %s. Delete the directory and ' |
| @@ -939,6 +955,15 @@ |
| command = self._AddAdditionalUpdateFlags(command, options, revision) |
| self._RunAndGetFileList(command, options, file_list, self._root_dir) |
| + # If --force is specified, remove any untracked files and directories. |
|
M-A Ruel
2012/02/08 14:43:46
You are basically doing a revert only for director
Steve Block
2012/02/09 17:55:04
I considered this approach, but it seems less robu
|
| + if options.force: |
| + for status in scm.SVN.CaptureStatus(None, self.checkout_path): |
| + if (status[0][0] == '?' |
| + and os.path.isdir(os.path.join(self.checkout_path, status[1]))): |
| + print('\n_____ removing unversioned directory %s' % status[1]) |
| + gclient_utils.RemoveDirectory(os.path.join(self.checkout_path, |
| + status[1])) |
| + |
| def updatesingle(self, options, args, file_list): |
| filename = args.pop() |
| if scm.SVN.AssertVersion("1.5")[0]: |