releasenotes: move import of fuzzywuzzy to import level
This will help us in determining easily that whether fuzzywuzzy is loaded or not
loaded in any of the function.
Differential Revision: https://phab.mercurial-scm.org/D1120
--- a/hgext/releasenotes.py Sun Oct 15 20:31:44 2017 +0530
+++ b/hgext/releasenotes.py Mon Oct 16 22:46:11 2017 +0530
@@ -33,6 +33,12 @@
cmdtable = {}
command = registrar.command(cmdtable)
+try:
+ import fuzzywuzzy.fuzz as fuzz
+ fuzz.token_set_ratio
+except ImportError:
+ fuzz = None
+
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
@@ -219,10 +225,8 @@
"""
Returns false when note fragment can be merged to existing notes.
"""
- try:
- import fuzzywuzzy.fuzz as fuzz
- fuzz.token_set_ratio
- except ImportError:
+ # fuzzywuzzy not present
+ if not fuzz:
return True
merge = True