forked from mirrors/gecko-dev
Most HG commands use subprocesses, even if a context manager (and therefore an hglib client) has been created. There are only two commands that make use of the client, but they *only* work inside a context manager. I don't think there are any technical reason these two commands *need* to use the context manager. This patch merges the HgRepository._run_in_client function with HgRepository._run(). If a client exists, that will be used, otherwise a subprocess will be used. Differential Revision: https://phabricator.services.mozilla.com/D1809 --HG-- extra : moz-landing-system : lando
30 lines
865 B
Python
30 lines
865 B
Python
# 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/.
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import mozunit
|
|
|
|
from mozversioncontrol import get_repository_object
|
|
|
|
|
|
def test_context_manager(repo):
|
|
is_git = repo.vcs == 'git'
|
|
cmd = ['show', '--no-patch'] if is_git else ['tip']
|
|
|
|
vcs = get_repository_object(repo.strpath)
|
|
output_subprocess = vcs._run(*cmd)
|
|
assert is_git or vcs._client.server is None
|
|
assert "Initial commit" in output_subprocess
|
|
|
|
with vcs:
|
|
assert is_git or vcs._client.server is not None
|
|
output_client = vcs._run(*cmd)
|
|
|
|
assert is_git or vcs._client.server is None
|
|
assert output_subprocess == output_client
|
|
|
|
|
|
if __name__ == '__main__':
|
|
mozunit.main()
|