Patchwork D8267: hghave: add a check for pygit2

login
register
mail settings
Submitter phabricator
Date March 9, 2020, 10:46 p.m.
Message ID <5c0d9c1d60f6a0499ab2a7ee9cf415a8@localhost.localdomain>
Download mbox | patch
Permalink /patch/45645/
State Not Applicable
Headers show

Comments

phabricator - March 9, 2020, 10:46 p.m.
Closed by commit rHG2e464925f662: hghave: add a check for pygit2 (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8267?vs=20644&id=20647

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8267/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8267

AFFECTED FILES
  tests/hghave.py
  tests/test-git-interop.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers, mharbison72
Cc: mercurial-devel

Patch

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -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
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -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():