Patchwork [07,of,12] debuginstall: check C extensions only if they are loadable per policy

login
register
mail settings
Submitter Yuya Nishihara
Date May 7, 2017, 1:45 a.m.
Message ID <e94661437708d6bb3440.1494121548@mimosa>
Download mbox | patch
Permalink /patch/20505/
State Accepted
Headers show

Comments

Yuya Nishihara - May 7, 2017, 1:45 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1493217052 -32400
#      Wed Apr 26 23:30:52 2017 +0900
# Node ID e94661437708d6bb34403b6a4139e2c41157ab34
# Parent  04d511906826eaa7f1c51c9b250dc6cbc290ebeb
debuginstall: check C extensions only if they are loadable per policy

This check is useless in pure installation and I want to make it directly
import C extension modules.

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1020,19 +1020,20 @@  def debuginstall(ui, **opts):
     fm.write('hgmodules', _("checking installed modules (%s)...\n"),
              os.path.dirname(pycompat.fsencode(__file__)))
 
-    err = None
-    try:
-        from . import (
-            base85,
-            bdiff,
-            mpatch,
-            osutil,
-        )
-        dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
-    except Exception as inst:
-        err = inst
-        problems += 1
-    fm.condwrite(err, 'extensionserror', " %s\n", err)
+    if policy.policy in ('c', 'allow'):
+        err = None
+        try:
+            from . import (
+                base85,
+                bdiff,
+                mpatch,
+                osutil,
+            )
+            dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
+        except Exception as inst:
+            err = inst
+            problems += 1
+        fm.condwrite(err, 'extensionserror', " %s\n", err)
 
     compengines = util.compengines._engines.values()
     fm.write('compengines', _('checking registered compression engines (%s)\n'),
diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -34,7 +34,7 @@  hg debuginstall JSON
     "editornotfound": false,
     "encoding": "ascii",
     "encodingerror": null,
-    "extensionserror": null,
+    "extensionserror": null, (no-pure !)
     "hgmodulepolicy": "*", (glob)
     "hgmodules": "*mercurial", (glob)
     "hgver": "*", (glob)