--- 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.