This is an archive of the discontinued Mercurial Phabricator instance.

highlight: hide pygments import error at import time
AbandonedPublic

Authored by quark on Oct 19 2017, 5:46 PM.

Details

Reviewers
yuja
Group Reviewers
hg-reviewers
Summary

Commands like hg help has a side effect of loading every extension. If
pygments is not installed, loading the highlight could fail immediately
with chg or HGDEMANDIMPORT=disable.

This patch special handles the ImportError so import highlight from hgext
does not raise an exception if pygments is missing. That makes the following
tests pass with --chg and without pygments:

  • test-i18n.t
  • test-help.t
  • test-bad-extension.t
  • test-convert-bzr-directories.t
  • test-run-tests.t
  • test-extdiff.t

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

quark created this revision.Oct 19 2017, 5:46 PM
quark edited the summary of this revision. (Show Details)Oct 19 2017, 5:48 PM
yuja requested changes to this revision.Oct 20 2017, 9:08 AM
yuja added a subscriber: yuja.

Not work because hgext.highlight is a package module and hgext.highlight.highlight
is initialized to None.

I'll send another patch that will hopefully fix these test failures.

This revision now requires changes to proceed.Oct 20 2017, 9:08 AM
quark abandoned this revision.Oct 20 2017, 2:12 PM