mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 14:58:03 +03:00
extensions: change error message to look non-fatal
Summary: The current error message looks like fatal while it is not. Make it clear that extension failures are not fatal. Reviewed By: markbt Differential Revision: D19166545 fbshipit-source-id: 7ce0231c90b0c5f50add15a12cb69b60b76dfcb1
This commit is contained in:
parent
e5de1683e4
commit
0c41aa6235
@ -356,7 +356,10 @@ def _runuisetup(name, ui):
|
||||
except Exception as inst:
|
||||
ui.traceback(force=True)
|
||||
msg = util.forcebytestr(inst)
|
||||
ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg))
|
||||
ui.warn(
|
||||
_("failed to set up extension %s: %s\n") % (name, msg),
|
||||
notice=_("warning"),
|
||||
)
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -379,7 +382,10 @@ def _runextsetup(name, ui):
|
||||
except Exception as inst:
|
||||
ui.traceback(force=True)
|
||||
msg = util.forcebytestr(inst)
|
||||
ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg))
|
||||
ui.warn(
|
||||
_("failed to set up extension %s: %s\n") % (name, msg),
|
||||
notice=_("warning"),
|
||||
)
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -415,13 +421,20 @@ def loadall(ui, whitelist=None):
|
||||
msg = util.forcebytestr(inst)
|
||||
if path:
|
||||
ui.warn(
|
||||
_("*** failed to import extension %s from %s: %s\n")
|
||||
% (name, path, msg)
|
||||
_(
|
||||
"extension %s is disabled because it cannot be imported from %s: %s\n"
|
||||
)
|
||||
% (name, path, msg),
|
||||
notice=_("warning"),
|
||||
)
|
||||
else:
|
||||
ui.warn(_("*** failed to import extension %s: %s\n") % (name, msg))
|
||||
ui.warn(
|
||||
_("extension %s is disabled because it cannot be imported: %s\n")
|
||||
% (name, msg),
|
||||
notice=_("warning"),
|
||||
)
|
||||
if isinstance(inst, error.Hint) and inst.hint:
|
||||
ui.warn(_("*** (%s)\n") % inst.hint)
|
||||
ui.warn(_("(%s)\n") % inst.hint)
|
||||
ui.traceback()
|
||||
# list of (objname, loadermod, loadername) tuple:
|
||||
# - objname is the name of an object in extension module,
|
||||
@ -878,7 +891,7 @@ def disabledcmd(ui, cmd):
|
||||
except (error.AmbiguousCommand, error.UnknownCommand):
|
||||
return
|
||||
except Exception:
|
||||
ui.warn(_("warning: error finding commands in %s\n") % path)
|
||||
ui.warn(_("error finding commands in %s\n") % path, notice=_("warning"))
|
||||
ui.traceback()
|
||||
return
|
||||
for c in aliases:
|
||||
|
@ -45,16 +45,16 @@ another bad extension
|
||||
> EOF
|
||||
|
||||
$ hg -q help help 2>&1 |grep extension
|
||||
*** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
|
||||
*** failed to import extension badext2: No module named badext2
|
||||
warning: extension badext is disabled because it cannot be imported from $TESTTMP/badext.py: bit bucket overflow
|
||||
warning: extension badext2 is disabled because it cannot be imported: No module named badext2
|
||||
|
||||
show traceback
|
||||
|
||||
$ hg -q help help --traceback 2>&1 | egrep ' extension|^Exception|Traceback|ImportError'
|
||||
*** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
|
||||
warning: extension badext is disabled because it cannot be imported from $TESTTMP/badext.py: bit bucket overflow
|
||||
Traceback (most recent call last):
|
||||
Exception: bit bucket overflow
|
||||
*** failed to import extension badext2: No module named badext2
|
||||
warning: extension badext2 is disabled because it cannot be imported: No module named badext2
|
||||
Traceback (most recent call last):
|
||||
ImportError: No module named badext2
|
||||
|
||||
@ -77,18 +77,18 @@ show traceback for ImportError of hgext.name if debug is set
|
||||
$ (hg -q help help --traceback --config ui.debug=True 2>&1) \
|
||||
> | grep -v '^ ' \
|
||||
> | egrep 'extension..[^p]|^Exception|Traceback|ImportError|not import'
|
||||
*** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
|
||||
warning: extension badext is disabled because it cannot be imported from $TESTTMP/badext.py: bit bucket overflow
|
||||
Traceback (most recent call last):
|
||||
Exception: bit bucket overflow
|
||||
*** failed to import extension badext2: No module named badext2
|
||||
warning: extension badext2 is disabled because it cannot be imported: No module named badext2
|
||||
Traceback (most recent call last):
|
||||
ImportError: No module named *badext2 (glob)
|
||||
|
||||
confirm that there's no crash when an extension's documentation is bad
|
||||
|
||||
$ hg help --keyword baddocext
|
||||
*** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
|
||||
*** failed to import extension badext2: No module named badext2
|
||||
warning: extension badext is disabled because it cannot be imported from $TESTTMP/badext.py: bit bucket overflow
|
||||
warning: extension badext2 is disabled because it cannot be imported: No module named badext2
|
||||
Topics:
|
||||
|
||||
extensions Using Additional Features
|
||||
|
@ -73,7 +73,7 @@ However, we can't prevent it from loading extensions and configs:
|
||||
> raise Exception('bad')
|
||||
> EOF
|
||||
$ hg log -b '--config=extensions.bad=bad.py' default
|
||||
*** failed to import extension bad from bad.py: bad
|
||||
warning: extension bad is disabled because it cannot be imported from bad.py: bad
|
||||
abort: option --config may not be abbreviated!
|
||||
[255]
|
||||
|
||||
|
@ -498,7 +498,7 @@ Even though the extension fails during uisetup, hg is still basically usable:
|
||||
File "$TESTTMP/baduisetup.py", line 2, in uisetup
|
||||
1/0
|
||||
ZeroDivisionError: integer division or modulo by zero
|
||||
*** failed to set up extension baduisetup: integer division or modulo by zero
|
||||
warning: failed to set up extension baduisetup: integer division or modulo by zero
|
||||
Mercurial Distributed SCM (version *) (glob)
|
||||
(see https://mercurial-scm.org for more information)
|
||||
|
||||
@ -1268,8 +1268,8 @@ Prohibit registration of commands that don't use @command (issue5137)
|
||||
> EOF
|
||||
|
||||
$ hg deprecatedcmd > /dev/null
|
||||
*** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
|
||||
*** (use @command decorator to register 'deprecatedcmd')
|
||||
warning: extension deprecatedcmd is disabled because it cannot be imported from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
|
||||
(use @command decorator to register 'deprecatedcmd')
|
||||
unknown command 'deprecatedcmd'
|
||||
(use 'hg help' to get help)
|
||||
[255]
|
||||
@ -1277,8 +1277,8 @@ Prohibit registration of commands that don't use @command (issue5137)
|
||||
the extension shouldn't be loaded at all so the mq works:
|
||||
|
||||
$ hg log -r null --config extensions.mq= > /dev/null
|
||||
*** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
|
||||
*** (use @command decorator to register 'deprecatedcmd')
|
||||
warning: extension deprecatedcmd is disabled because it cannot be imported from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
|
||||
(use @command decorator to register 'deprecatedcmd')
|
||||
|
||||
$ cd ..
|
||||
|
||||
@ -1338,8 +1338,8 @@ Prohibit the use of unicode strings as the default value of options
|
||||
> test_unicode_default_value = $TESTTMP/test_unicode_default_value.py
|
||||
> EOF
|
||||
$ hg -R $TESTTMP/opt-unicode-default dummy
|
||||
*** failed to import extension test_unicode_default_value from $TESTTMP/test_unicode_default_value.py: option 'dummy.opt' has a unicode default value
|
||||
*** (change the dummy.opt default value to a non-unicode string)
|
||||
warning: extension test_unicode_default_value is disabled because it cannot be imported from $TESTTMP/test_unicode_default_value.py: option 'dummy.opt' has a unicode default value
|
||||
(change the dummy.opt default value to a non-unicode string)
|
||||
unknown command 'dummy'
|
||||
(use 'hg help' to get help)
|
||||
[255]
|
||||
|
@ -166,12 +166,12 @@
|
||||
$ hg debugrebuilddirstate 2>&1 | grep 'multiple processors'
|
||||
# msg = "cannot register multiple processors on flag '0x8'."
|
||||
Abort: cannot register multiple processors on flag '0x8'.
|
||||
*** failed to set up extension duplicate: cannot register multiple processors on flag '0x8'.
|
||||
warning: failed to set up extension duplicate: cannot register multiple processors on flag '0x8'.
|
||||
$ hg st 2>&1 | egrep 'cannot register multiple processors|flagprocessorext'
|
||||
File "*/tests/flagprocessorext.py", line *, in extsetup (glob)
|
||||
# msg = "cannot register multiple processors on flag '0x8'."
|
||||
Abort: cannot register multiple processors on flag '0x8'.
|
||||
*** failed to set up extension duplicate: cannot register multiple processors on flag '0x8'.
|
||||
warning: failed to set up extension duplicate: cannot register multiple processors on flag '0x8'.
|
||||
File "*/tests/flagprocessorext.py", line *, in b64decode (glob)
|
||||
|
||||
$ cd ..
|
||||
|
@ -49,4 +49,4 @@ extension.
|
||||
- Run any command to test that the extension loading failed.
|
||||
|
||||
$ hg status
|
||||
* failed to import extension *: namespace priority must be specified (glob)
|
||||
warning: extension ext3 is disabled because it cannot be imported from $TESTTMP/ext3.py: namespace priority must be specified
|
||||
|
@ -1599,7 +1599,7 @@ loading it
|
||||
> EOF
|
||||
|
||||
$ hg debugrevspec "custom1()"
|
||||
*** failed to import extension custompredicate from $TESTTMP/custompredicate.py: intentional failure of loading extension
|
||||
warning: extension custompredicate is disabled because it cannot be imported from $TESTTMP/custompredicate.py: intentional failure of loading extension
|
||||
hg: parse error: unknown identifier: custom1
|
||||
[255]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user