Bug 1324382 - Update mach to download clang-format 4.0 r=gps
authorSylvestre Ledru <sledru@mozilla.com>
Mon, 19 Dec 2016 15:28:16 +0100
changeset 374179 ac71e73d904d69cf77c264333694a5b5e07e2159
parent 374178 0a552cd5a5a3063acf1c13d0a71f49fcd5d06807
child 374180 c4fa2b29abe7220545789fa2706601338cbe90aa
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1324382
milestone53.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 1324382 - Update mach to download clang-format 4.0 r=gps MozReview-Commit-ID: INeMSbEloA3
tools/mach_commands.py
--- a/tools/mach_commands.py
+++ b/tools/mach_commands.py
@@ -226,22 +226,21 @@ class FormatProvider(MachCommandBase):
     @Command('clang-format', category='misc',
         description='Run clang-format on current changes')
     @CommandArgument('--show', '-s', action = 'store_true',
         help = 'Show diff output on instead of applying changes')
     def clang_format(self, show=False):
         import urllib2
 
         plat = platform.system()
-        fmt = plat.lower() + "/clang-format-3.5"
-        fmt_diff = "clang-format-diff-3.5"
+        fmt = plat.lower() + "/clang-format-4.0"
+        fmt_diff = "clang-format-diff-4.0"
 
-        # We are currently using a modified version of clang-format hosted on people.mozilla.org.
-        # This is a temporary work around until we upstream the necessary changes and we can use
-        # a system version of clang-format. See bug 961541.
+        # We are currently using an unmodified snapshot of upstream clang-format.
+        # This is a temporary work around until clang 4.0 has been released with our changes.
         if plat == "Windows":
             fmt += ".exe"
         else:
             arch = os.uname()[4]
             if (plat != "Linux" and plat != "Darwin") or arch != 'x86_64':
                 print("Unsupported platform " + plat + "/" + arch +
                       ". Supported platforms are Windows/*, Linux/x86_64 and Darwin/x86_64")
                 return 1
@@ -262,17 +261,17 @@ class FormatProvider(MachCommandBase):
 
         from subprocess import Popen, PIPE
 
         if os.path.exists(".hg"):
             diff_process = Popen(["hg", "diff", "-U0", "-r", "tip^",
                                   "--include", "glob:**.c", "--include", "glob:**.cpp", "--include", "glob:**.h",
                                   "--exclude", "listfile:.clang-format-ignore"], stdout=PIPE)
         else:
-            git_process = Popen(["git", "diff", "-U0", "HEAD^"], stdout=PIPE)
+            git_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD^"], stdout=PIPE)
             try:
                 diff_process = Popen(["filterdiff", "--include=*.h", "--include=*.cpp",
                                       "--exclude-from-file=.clang-format-ignore"],
                                      stdin=git_process.stdout, stdout=PIPE)
             except OSError as e:
                 if e.errno == errno.ENOENT:
                     print("Can't find filterdiff. Please install patchutils.")
                 else:
@@ -282,19 +281,20 @@ class FormatProvider(MachCommandBase):
 
         args = [sys.executable, clang_format_diff, "-p1"]
         if not show:
            args.append("-i")
         cf_process = Popen(args, stdin=diff_process.stdout)
         return cf_process.communicate()[0]
 
     def locate_or_fetch(self, root):
+        import urllib2
         target = os.path.join(self._mach_context.state_dir, os.path.basename(root))
         if not os.path.exists(target):
-            site = "https://people.mozilla.org/~ajones/clang-format/"
+            site = "https://people.mozilla.org/~sledru/clang-format/"
             if self.prompt and raw_input("Download clang-format executables from {0} (yN)? ".format(site)).lower() != 'y':
                 print("Download aborted.")
                 return 1
             self.prompt = False
 
             u = site + root
             print("Downloading {0} to {1}".format(u, target))
             data = urllib2.urlopen(url=u).read()