D1120: releasenotes: move import of fuzzywuzzy to import level

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Tue Oct 17 10:16:38 EDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbc2caa4b4480: releasenotes: move import of fuzzywuzzy to import level (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1120?vs=2831&id=2914

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -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



To: pulkit, #hg-reviewers, yuja
Cc: mercurial-devel


More information about the Mercurial-devel mailing list