diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/harness/wptrunner/vcs.py | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/harness/wptrunner/vcs.py')
-rw-r--r-- | testing/web-platform/harness/wptrunner/vcs.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/web-platform/harness/wptrunner/vcs.py b/testing/web-platform/harness/wptrunner/vcs.py new file mode 100644 index 000000000..6dfb9d592 --- /dev/null +++ b/testing/web-platform/harness/wptrunner/vcs.py @@ -0,0 +1,53 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import subprocess +from functools import partial + +from mozlog import get_default_logger + +logger = None + +def vcs(bin_name): + def inner(command, *args, **kwargs): + global logger + + if logger is None: + logger = get_default_logger("vcs") + + repo = kwargs.pop("repo", None) + log_error = kwargs.pop("log_error", True) + if kwargs: + raise TypeError, kwargs + + args = list(args) + + proc_kwargs = {} + if repo is not None: + proc_kwargs["cwd"] = repo + + command_line = [bin_name, command] + args + logger.debug(" ".join(command_line)) + try: + return subprocess.check_output(command_line, stderr=subprocess.STDOUT, **proc_kwargs) + except subprocess.CalledProcessError as e: + if log_error: + logger.error(e.output) + raise + return inner + +git = vcs("git") +hg = vcs("hg") + + +def bind_to_repo(vcs_func, repo): + return partial(vcs_func, repo=repo) + + +def is_git_root(path): + try: + rv = git("rev-parse", "--show-cdup", repo=path) + except subprocess.CalledProcessError: + return False + return rv == "\n" |