Patchwork D1096: releasenotes: make the import of fuzzywuzzy optional

login
register
mail settings
Submitter phabricator
Date Oct. 15, 2017, 3:14 p.m.
Message ID <differential-rev-PHID-DREV-prrwkrsxoolp7kvjs235-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/24953/
State Superseded
Headers show

Comments

phabricator - Oct. 15, 2017, 3:14 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If fuzzywuzzy is note present, we will not be having the capability to merge
  existing releasenotes with the new releasenotes on the similarity basis.
  The merging will still work good for exact same releasenotes entries.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Oct. 16, 2017, 1:05 p.m.
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> releasenotes.py:222
> +    try:
> +        import fuzzywuzzy.fuzz as fuzz
> +    except ImportError:

Needs to evaluate the fuzz module to get around the demandimport.

e.g.

  try:
      from fuzzywuzzy import fuzz
      fuzz.token_set_ratio
  except ImportError

> releasenotes.py:224
> +    except ImportError:
> +        return False
>      merge = True

Perhaps it should return True.

Any maybe it should show warning, status or debug message?

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
phabricator - Oct. 16, 2017, 2:18 p.m.
pulkit added inline comments.

INLINE COMMENTS

> yuja wrote in releasenotes.py:224
> Perhaps it should return True.
> 
> Any maybe it should show warning, status or debug message?

Yes it should return True and I think the doc of this function is wrong. Nice catch.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
phabricator - Oct. 16, 2017, 2:24 p.m.
pulkit added inline comments.

INLINE COMMENTS

> yuja wrote in releasenotes.py:224
> Perhaps it should return True.
> 
> Any maybe it should show warning, status or debug message?

Also, whatever message we will use here, warning, status or debug, it will be repeated a lot of times as the function is called a lot of times. This extension need some cleanup. :(

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -218,7 +218,10 @@ 
     """
     Returns true when note fragment can be merged to existing notes.
     """
-    import fuzzywuzzy.fuzz as fuzz
+    try:
+        import fuzzywuzzy.fuzz as fuzz
+    except ImportError:
+        return False
     merge = True
     for bullet in existingnotes:
         score = fuzz.token_set_ratio(incoming_str, bullet)