--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -349,18 +349,22 @@ class Clobber(MachCommandBase):
things work again. This command can be used to perform that cleanup.
By default, this command removes most files in the current object
directory (where build output is stored). Some files (like Visual
Studio project files) are not removed by default. If you would like
to remove the object directory in its entirety, run with `--full`.
The `python` target will clean up various generated Python files from
- the source directory. Run this to remove .pyc files, compiled C
- extensions, etc.
+ the source directory and will remove untracked files from well-known
+ directories containing Python packages. Run this to remove .pyc files,
+ compiled C extensions, etc. Note: all files not tracked or ignored by
+ version control in well-known Python package directories will be
+ deleted. Run the `status` command of your VCS to see if any untracked
+ files you haven't committed yet will be deleted.
"""
invalid = set(what) - set(self.CLOBBER_CHOICES)
if invalid:
print('Unknown clobber target(s): {}'.format(', '.join(invalid)))
return 1
ret = 0
if 'objdir' in what:
@@ -373,21 +377,26 @@ class Clobber(MachCommandBase):
self.log(logging.ERROR, 'file_access_error', {'error': e},
"Could not clobber because a file was in use. If the "
"application is running, try closing it. {error}")
return 1
raise
if 'python' in what:
if conditions.is_hg(self):
- cmd = ['hg', 'purge', '--all', '-I', 'glob:**.py[cdo]']
+ cmd = ['hg', 'purge', '--all', '-I', 'glob:**.py[cdo]',
+ '-I', 'path:python/', '-I', 'path:third_party/python/']
elif conditions.is_git(self):
- cmd = ['git', 'clean', '-f', '-x', '*.py[cdo]']
+ cmd = ['git', 'clean', '-f', '-x', '*.py[cdo]', 'python/',
+ 'third_party/python/']
else:
- cmd = ['find', '.', '-type', 'f', '-name', '*.py[cdo]', '-delete']
+ # We don't know what is tracked/untracked if we don't have VCS.
+ # So we can't clean python/ and third_party/python/.
+ cmd = ['find', '.', '-type', 'f', '-name', '*.py[cdo]',
+ '-delete']
ret = subprocess.call(cmd, cwd=self.topsrcdir)
return ret
@property
def substs(self):
try:
return super(Clobber, self).substs
except BuildEnvironmentNotFoundException: