D6123: similar: add condition to avoid Zerodivisonerror in function _score() (issue6099)
akshjain.jain74 (Akshit Jain)
phabricator at mercurial-scm.org
Wed Mar 13 16:17:14 EDT 2019
akshjain.jain74 updated this revision to Diff 14487.
akshjain.jain74 retitled this revision from "ZeroDivisionError: Add condition to avoid Zerodivisonerror due to float number (issue6099)" to "similar: add condition to avoid Zerodivisonerror in function _score() (issue6099)".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6123?vs=14482&id=14487
REVISION DETAIL
https://phab.mercurial-scm.org/D6123
AFFECTED FILES
mercurial/similar.py
CHANGE DETAILS
diff --git a/mercurial/similar.py b/mercurial/similar.py
--- a/mercurial/similar.py
+++ b/mercurial/similar.py
@@ -63,7 +63,10 @@
equal += len(line)
lengths = len(text) + len(orig)
- return equal * 2.0 / lengths
+ if lengths != 0:
+ return equal * 2.0 / lengths
+ else:
+ return 0
def score(fctx1, fctx2):
return _score(fctx1, _ctxdata(fctx2))
To: akshjain.jain74, durin42, #hg-reviewers
Cc: av6, pulkit, mercurial-devel
More information about the Mercurial-devel
mailing list