Bug 1387035 - Update clang-format methods to use mozversioncontrol for hg/git detection r=gps
authorXavier ALT <dex@phoenix-ind.net>
Tue, 15 Aug 2017 23:23:30 +0200
changeset 375277 0828f347805f
parent 375276 bc093920843d
child 375278 87e969d3da2b
push id49005
push usersledru@mozilla.com
push dateThu, 17 Aug 2017 06:35:28 +0000
treeherderautoland@0828f347805f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1387035
milestone57.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 1387035 - Update clang-format methods to use mozversioncontrol for hg/git detection r=gps MozReview-Commit-ID: IZTPYtTxuKu
tools/mach_commands.py
--- a/tools/mach_commands.py
+++ b/tools/mach_commands.py
@@ -12,16 +12,17 @@ import errno
 
 from mach.decorators import (
     CommandArgument,
     CommandProvider,
     Command,
 )
 
 from mozbuild.base import MachCommandBase, MozbuildObject
+import mozversioncontrol
 
 
 @CommandProvider
 class SearchProvider(object):
     @Command('dxr', category='misc',
              description='Search for something in DXR.')
     @CommandArgument('term', nargs='+', help='Term(s) to search for.')
     def dxr(self, term):
@@ -256,17 +257,17 @@ class FormatProvider(MachCommandBase):
             os.rename(temp, target)
         return target
 
     def run_clang_format_diff(self, clang_format_diff, show):
         # Run clang-format on the diff
         # Note that this will potentially miss a lot things
         from subprocess import Popen, PIPE
 
-        if os.path.exists(".hg"):
+        if isinstance(self.repository, mozversioncontrol.HgRepository):
             diff_process = Popen(["hg", "diff", "-U0", "-r", ".^",
                                   "--include", "glob:**.c", "--include", "glob:**.cpp",
                                   "--include", "glob:**.h",
                                   "--exclude", "listfile:.clang-format-ignore"], stdout=PIPE)
         else:
 	    diff_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD","--","*.c","*.cpp","*.h"], stdout=PIPE)
         args = [sys.executable, clang_format_diff, "-p1"]
         if not show:
@@ -318,17 +319,17 @@ class FormatProvider(MachCommandBase):
             return
 
         args += path_list
 
         # Run clang-format
         cf_process = Popen(args)
         if show:
             # show the diff
-            if os.path.exists(".hg"):
+            if isinstance(self.repository, mozversioncontrol.HgRepository):
                 cf_process = Popen(["hg", "diff"] + path_list)
             else:
                 cf_process = Popen(["git", "diff"] + path_list)
         return cf_process.communicate()[0]
 
 
 def mozregression_import():
     # Lazy loading of mozregression.