Patchwork D8261: git: hack around import checker being confused about the provenance of pygit2

login
register
mail settings
Submitter phabricator
Date March 7, 2020, 9:45 p.m.
Message ID <differential-rev-PHID-DREV-p5ya7jtnwlks2vju5hgh-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45611/
State Superseded
Headers show

Comments

phabricator - March 7, 2020, 9:45 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/git/index.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - March 9, 2020, 8:54 a.m.
pulkit added inline comments.

INLINE COMMENTS

> index.py:19
> +try:
> +    import pygit2
> +except ImportError:

IIUC, we should access some attribute to trigger demandimport.

REPOSITORY
  rHG Mercurial

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

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

To: durin42, #hg-reviewers
Cc: pulkit, mercurial-devel

Patch

diff --git a/hgext/git/index.py b/hgext/git/index.py
--- a/hgext/git/index.py
+++ b/hgext/git/index.py
@@ -4,8 +4,6 @@ 
 import os
 import sqlite3
 
-import pygit2
-
 from mercurial.i18n import _
 
 from mercurial import (
@@ -15,6 +13,13 @@ 
     pycompat,
 )
 
+# This looks goofy, but it appeases test-check-imports which has funny
+# ideas about where this import belongs.
+try:
+    import pygit2
+except ImportError:
+    raise
+
 from . import gitutil