hgext/releasenotes.py
changeset 34812 bc2caa4b4480
parent 34811 a542ad320adb
child 34813 288fad8c55f9
equal deleted inserted replaced
34811:a542ad320adb 34812:bc2caa4b4480
    30     util,
    30     util,
    31 )
    31 )
    32 
    32 
    33 cmdtable = {}
    33 cmdtable = {}
    34 command = registrar.command(cmdtable)
    34 command = registrar.command(cmdtable)
       
    35 
       
    36 try:
       
    37     import fuzzywuzzy.fuzz as fuzz
       
    38     fuzz.token_set_ratio
       
    39 except ImportError:
       
    40     fuzz = None
    35 
    41 
    36 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
    42 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
    37 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
    43 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
    38 # be specifying the version(s) of Mercurial they are tested with, or
    44 # be specifying the version(s) of Mercurial they are tested with, or
    39 # leave the attribute unspecified.
    45 # leave the attribute unspecified.
   217 
   223 
   218 def similaritycheck(incoming_str, existingnotes):
   224 def similaritycheck(incoming_str, existingnotes):
   219     """
   225     """
   220     Returns false when note fragment can be merged to existing notes.
   226     Returns false when note fragment can be merged to existing notes.
   221     """
   227     """
   222     try:
   228     # fuzzywuzzy not present
   223         import fuzzywuzzy.fuzz as fuzz
   229     if not fuzz:
   224         fuzz.token_set_ratio
       
   225     except ImportError:
       
   226         return True
   230         return True
   227 
   231 
   228     merge = True
   232     merge = True
   229     for bullet in existingnotes:
   233     for bullet in existingnotes:
   230         score = fuzz.token_set_ratio(incoming_str, bullet)
   234         score = fuzz.token_set_ratio(incoming_str, bullet)