Bug 1410938 - Split the clang-format calls into batches of 200 files r?gps draft
authorSylvestre Ledru <sledru@mozilla.com>
Mon, 23 Oct 2017 18:14:32 +0200
changeset 684801 b502c4ea23d9195e7983a69fb65e5b86bc4444e4
parent 683957 be1ba0ed52fb653699f8e92c3c528cec9a930022
child 684802 0bf2498be1649b8118989dd0a854db3de7a060a4
push id85736
push userbmo:sledru@mozilla.com
push dateMon, 23 Oct 2017 16:42:30 +0000
reviewersgps
bugs1410938
milestone58.0a1
Bug 1410938 - Split the clang-format calls into batches of 200 files r?gps MozReview-Commit-ID: 3cH295RBcv3
tools/mach_commands.py
--- a/tools/mach_commands.py
+++ b/tools/mach_commands.py
@@ -338,28 +338,35 @@ class FormatProvider(MachCommandBase):
 
         args = [clang_format, "-i"]
 
         path_list = self.generate_path_list(paths)
 
         if path_list == []:
             return
 
-        args += path_list
+        print("Processing %d file(s)..." % len(path_list))
+
+        batchsize = 200
 
-        # Run clang-format
-        cf_process = Popen(args)
+        for i in range(0, len(path_list), batchsize):
+            l = path_list[i: (i + batchsize)]
+            # Run clang-format on the list
+            cf_process = Popen(args + l)
+            # Wait until the process is over
+            cf_process.communicate()[0]
+
         if show:
             # show the diff
             if self.repository.name == 'hg':
-                cf_process = Popen(["hg", "diff"] + path_list)
+                cf_process = Popen(["hg", "diff"] + paths)
             else:
                 assert self.repository.name == 'git'
-                cf_process = Popen(["git", "diff"] + path_list)
-        return cf_process.communicate()[0]
+                cf_process = Popen(["git", "diff"] + paths)
+            cf_process.communicate()[0]
 
 
 def mozregression_import():
     # Lazy loading of mozregression.
     # Note that only the mach_interface module should be used from this file.
     try:
         import mozregression.mach_interface
     except ImportError: