1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 class Mercurial(object):
10 def __init__(self
, repo_root
):
11 self
.root
= os
.path
.abspath(repo_root
)
12 self
.hg
= Mercurial
.get_func(repo_root
)
15 def get_func(repo_root
):
17 full_cmd
= ["hg", cmd
] + list(args
)
18 return subprocess
.check_output(full_cmd
, cwd
=repo_root
)
19 # TODO: Test on Windows.
24 def is_hg_repo(repo_root
):
26 with
open(os
.devnull
, "w") as devnull
:
27 subprocess
.check_call(
28 ["hg", "root"], cwd
=repo_root
, stdout
=devnull
, stderr
=devnull
30 except subprocess
.CalledProcessError
:
34 # TODO: Test on windows
39 def __init__(self
, repo_root
, url_base
):
40 self
.root
= os
.path
.abspath(repo_root
)
41 self
.git
= Git
.get_func(repo_root
)
44 def get_func(repo_root
):
46 full_cmd
= ["git", cmd
] + list(args
)
47 return subprocess
.check_output(full_cmd
, cwd
=repo_root
)
48 # TODO: Test on Windows.
53 def is_git_repo(repo_root
):
55 with
open(os
.devnull
, "w") as devnull
:
56 subprocess
.check_call(
57 ["git", "rev-parse", "--show-cdup"],
62 except subprocess
.CalledProcessError
:
66 # TODO: Test on windows