Bug 1439727 - Purge untracked files in python/ and third_party/python/; r=nalexander
authorGregory Szorc <gps@mozilla.com>
Wed, 07 Mar 2018 15:06:21 -0800
changeset 407026 31dc1d9be83d2cc7bc6b86b17f071b865b732e54
parent 407025 85a7612e5ac9a52620785e3ca45756211fa4963b
child 407027 1231cfa429da4047ce895adea82e93e3dee81d05
push id60797
push usergszorc@mozilla.com
push dateWed, 07 Mar 2018 23:08:27 +0000
treeherderautoland@1231cfa429da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1439727
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439727 - Purge untracked files in python/ and third_party/python/; r=nalexander `mach clobber python` currently purges Python files with known extensions globally. The python/ and third_party/python/ directories may also contain random ignored/untracked files. Let's purge those as well. Note: if someone has untracked but not ignored files, this will delete them. This is possibly unwanted. But people shouldn't have untracked but not ignored files sitting around in VCS. We don't run this command by default, so I think it is safe to be aggressive in our purging of these untracked files. MozReview-Commit-ID: 8ql8QR6lP6j
python/mozbuild/mozbuild/mach_commands.py
--- 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: