# HG changeset patch # User Martin von Zweigbergk # Date 1583783601 25200 # Node ID 2e464925f6625769f8ebc4b3fd51729acc343728 # Parent 21893ff382cd9dfde34200492fe2ec3fe11031bf hghave: add a check for pygit2 This will make it easy to use availability of pygit2 as in conditions such as `#if pygit2` and `(pygit2 !)`. It also makes it a little clearer why the test case skipped (when that happens). Differential Revision: https://phab.mercurial-scm.org/D8267 diff -r 21893ff382cd -r 2e464925f662 tests/hghave.py --- a/tests/hghave.py Sat Mar 07 18:00:53 2020 -0500 +++ b/tests/hghave.py Mon Mar 09 12:53:21 2020 -0700 @@ -381,6 +381,17 @@ return (int(m.group(1)), int(m.group(2))) +@check("pygit2", "pygit2 Python library") +def has_git(): + try: + import pygit2 + + pygit2.Oid # silence unused import + return True + except ImportError: + return False + + # https://github.com/git-lfs/lfs-test-server @check("lfs-test-server", "git-lfs test server") def has_lfsserver(): diff -r 21893ff382cd -r 2e464925f662 tests/test-git-interop.t --- a/tests/test-git-interop.t Sat Mar 07 18:00:53 2020 -0500 +++ b/tests/test-git-interop.t Mon Mar 09 12:53:21 2020 -0700 @@ -1,5 +1,4 @@ -This test requires pygit2: - > $PYTHON -c 'import pygit2' || exit 80 +#require pygit2 Setup: > GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME