Patchwork D6123: ZeroDivisionError: Add condition to avoid Zerodivisonerror due to float number (issue6099)

login
register
mail settings
Submitter phabricator
Date March 13, 2019, 5:34 p.m.
Message ID <db9711b5e4ad8c35f46217906a1d97aa@localhost.localdomain>
Download mbox | patch
Permalink /patch/39236/
State Not Applicable
Headers show

Comments

phabricator - March 13, 2019, 5:34 p.m.
akshjain.jain74 updated this revision to Diff 14482.
akshjain.jain74 retitled this revision from "Experimental features: Add condition to for float number (issue6099)" to "ZeroDivisionError: Add condition to avoid Zerodivisonerror due to float number (issue6099)".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6123?vs=14477&id=14482

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

AFFECTED FILES
  mercurial/similar.py

CHANGE DETAILS




To: akshjain.jain74, durin42, #hg-reviewers
Cc: av6, pulkit, mercurial-devel

Patch

diff --git a/mercurial/similar.py b/mercurial/similar.py
--- a/mercurial/similar.py
+++ b/mercurial/similar.py
@@ -63,7 +63,8 @@ 
             equal += len(line)
 
     lengths = len(text) + len(orig)
-    return equal * 2.0 / lengths
+    if lengths > 0:
+        return equal * 2.0 / lengths
 
 def score(fctx1, fctx2):
     return _score(fctx1, _ctxdata(fctx2))