Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: gclient_scm.py

Issue 9348054: If --force is specified when updating, remove unversioned directories (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: If both -f and -D are specified when updating, remove all untracked directories Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gclient.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
===================================================================
--- gclient_scm.py (revision 121978)
+++ gclient_scm.py (working copy)
@@ -442,6 +442,20 @@
if verbose:
print('Checked out revision %s' % self.revinfo(options, (), None))
+ # If --force and --delete_unversioned_trees are specified, remove any
+ # untracked directories.
+ if options.force and options.delete_unversioned_trees:
+ # 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'],
+ self.checkout_path)
+ for path in (p for p in paths.splitlines() if p.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 +928,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] != '?':
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 +953,15 @@
command = self._AddAdditionalUpdateFlags(command, options, revision)
self._RunAndGetFileList(command, options, file_list, self._root_dir)
+ # If --force and --delete_unversioned_trees are specified, remove any
+ # untracked files and directories.
+ if options.force and options.delete_unversioned_trees:
+ for status in scm.SVN.CaptureStatus(None, self.checkout_path):
+ path = os.path.join(self.checkout_path, status[1])
+ if (status[0][0] == '?' and os.path.isdir(path)):
+ print('\n_____ removing unversioned directory %s' % status[1])
+ gclient_utils.RemoveDirectory(os.path.join(path))
+
def updatesingle(self, options, args, file_list):
filename = args.pop()
if scm.SVN.AssertVersion("1.5")[0]:
« no previous file with comments | « gclient.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698