Bug 1586807 - Make pseudoclass locking work with Fission. r=pbro
[gecko.git] / testing / web-platform / vcs.py
blob0f86c99c651dbc2ac91c7a71bba2c396a275673a
1 import os
2 import subprocess
4 class Mercurial(object):
5 def __init__(self, repo_root):
6 self.root = os.path.abspath(repo_root)
7 self.hg = Mercurial.get_func(repo_root)
9 @staticmethod
10 def get_func(repo_root):
11 def hg(cmd, *args):
12 full_cmd = ["hg", cmd] + list(args)
13 return subprocess.check_output(full_cmd, cwd=repo_root)
14 # TODO: Test on Windows.
15 return hg
17 @staticmethod
18 def is_hg_repo(repo_root):
19 try:
20 with open(os.devnull, 'w') as devnull:
21 subprocess.check_call(["hg", "root"], cwd=repo_root, stdout=devnull,
22 stderr=devnull)
23 except subprocess.CalledProcessError:
24 return False
25 # TODO: Test on windows
26 return True
29 class Git(object):
30 def __init__(self, repo_root, url_base):
31 self.root = os.path.abspath(repo_root)
32 self.git = Git.get_func(repo_root)
34 @staticmethod
35 def get_func(repo_root):
36 def git(cmd, *args):
37 full_cmd = ["git", cmd] + list(args)
38 return subprocess.check_output(full_cmd, cwd=repo_root)
39 # TODO: Test on Windows.
40 return git
42 @staticmethod
43 def is_git_repo(repo_root):
44 try:
45 with open(os.devnull, 'w') as devnull:
46 subprocess.check_call(["git", "rev-parse", "--show-cdup"], cwd=repo_root,
47 stdout=devnull, stderr=devnull)
48 except subprocess.CalledProcessError:
49 return False
50 # TODO: Test on windows
51 return True