Bug 983633 - Error if filterdiff is required; r=gps
authorAnthony Jones <ajones@mozilla.com>
Fri, 21 Mar 2014 17:43:28 +1300
changeset 174699 3ddf88afb0a2468d0df7f1cb0db3075e94124c9e
parent 174698 322885ddb693cbe66c2d1acf2e3c4c6b0bb336f9
child 174700 9fe84f49b0ea239847ee085f9689949de50ae107
push id41331
push userajones@mozilla.com
push dateFri, 21 Mar 2014 04:43:35 +0000
treeherdermozilla-inbound@3ddf88afb0a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs983633
milestone31.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 983633 - Error if filterdiff is required; r=gps
tools/mach_commands.py
--- a/tools/mach_commands.py
+++ b/tools/mach_commands.py
@@ -4,16 +4,17 @@
 
 from __future__ import unicode_literals
 
 import sys
 import os
 import stat
 import platform
 import urllib2
+import errno
 
 from mach.decorators import (
     CommandArgument,
     CommandProvider,
     Command,
 )
 
 from mozbuild.base import MachCommandBase
@@ -356,19 +357,27 @@ 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)
-            diff_process = Popen(["filterdiff", "--include=*.h", "--include=*.cpp",
-                                  "--exclude-from-file=.clang-format-ignore"],
-                                 stdin=git_process.stdout, 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:
+                    print("OSError {0}: {1}".format(e.code, e.reason))
+                return 1
+
 
         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):