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
)
10 def get_func(repo_root
):
12 full_cmd
= ["hg", cmd
] + list(args
)
13 return subprocess
.check_output(full_cmd
, cwd
=repo_root
)
14 # TODO: Test on Windows.
18 def is_hg_repo(repo_root
):
20 with
open(os
.devnull
, 'w') as devnull
:
21 subprocess
.check_call(["hg", "root"], cwd
=repo_root
, stdout
=devnull
,
23 except subprocess
.CalledProcessError
:
25 # TODO: Test on windows
30 def __init__(self
, repo_root
, url_base
):
31 self
.root
= os
.path
.abspath(repo_root
)
32 self
.git
= Git
.get_func(repo_root
)
35 def get_func(repo_root
):
37 full_cmd
= ["git", cmd
] + list(args
)
38 return subprocess
.check_output(full_cmd
, cwd
=repo_root
)
39 # TODO: Test on Windows.
43 def is_git_repo(repo_root
):
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
:
50 # TODO: Test on windows