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
:
27 # TODO: Test on windows
32 def __init__(self
, repo_root
, url_base
):
33 self
.root
= os
.path
.abspath(repo_root
)
34 self
.git
= Git
.get_func(repo_root
)
37 def get_func(repo_root
):
39 full_cmd
= ["git", cmd
] + list(args
)
40 return subprocess
.check_output(full_cmd
, cwd
=repo_root
)
41 # TODO: Test on Windows.
45 def is_git_repo(repo_root
):
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
:
54 # TODO: Test on windows