durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Without this, I can't seem to build a working rpm for my fedora machine.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/git/__init__.py

CHANGE DETAILS

diff --git a/hgext/git/__init__.py b/hgext/git/__init__.py
--- a/hgext/git/__init__.py
+++ b/hgext/git/__init__.py
@@ -8,8 +8,6 @@
 
 import os
 
-import pygit2
-
 from mercurial.i18n import _
 
 from mercurial import (
@@ -22,12 +20,21 @@
     util,
 )
 
-from . import (
-    dirstate,
-    gitlog,
-    gitutil,
-    index,
-)
+# gendoc.py ends up causing all extensions to be imported, so we need
+# to hide attempts to load pygit2 from it so that it can finish
+# generating documentation.
+try:
+    import pygit2
+except ImportError:
+    pygit2 = None
+
+if pygit2 is not None:
+    from . import (
+        dirstate,
+        gitlog,
+        gitutil,
+        index,
+    )
 
 
 # TODO: extract an interface for this in core
@@ -250,6 +257,7 @@
 
 
 def extsetup(ui):
+    assert pygit2 is not None, 'git extension requires pygit2'
     extensions.wrapfunction(localrepo, b'makestore', _makestore)
     extensions.wrapfunction(localrepo, b'makefilestorage', _makefilestorage)
     # Inject --git flag for `hg init`



To: durin42, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to