Bug 1649619 [wpt PR 24402] - [PaintTiming] Let videos trigger FCP, a=testonly
[gecko.git] / testing / web-platform / vcs.py
blobc81ac8d719156b7359fb7ed1dba7479999e45686
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 except OSError:
26 return False
27 # TODO: Test on windows
28 return True
31 class Git(object):
32 def __init__(self, repo_root, url_base):
33 self.root = os.path.abspath(repo_root)
34 self.git = Git.get_func(repo_root)
36 @staticmethod
37 def get_func(repo_root):
38 def git(cmd, *args):
39 full_cmd = ["git", cmd] + list(args)
40 return subprocess.check_output(full_cmd, cwd=repo_root)
41 # TODO: Test on Windows.
42 return git
44 @staticmethod
45 def is_git_repo(repo_root):
46 try:
47 with open(os.devnull, 'w') as devnull:
48 subprocess.check_call(["git", "rev-parse", "--show-cdup"], cwd=repo_root,
49 stdout=devnull, stderr=devnull)
50 except subprocess.CalledProcessError:
51 return False
52 except OSError:
53 return False
54 # TODO: Test on windows
55 return True