diff mercurial/scmutil.py @ 37306:6942c73f0733

addremove: pass command-level similarity value down to scmutil.addremove() Since we've changed to carry a similarity value by opts dict, it makes sense to leave a string '0'-'100' value unmodified.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 03 Apr 2018 22:24:50 +0900
parents 0194dac77c93
children e32dfff71529
line wrap: on
line diff
--- a/mercurial/scmutil.py	Tue Apr 03 13:37:57 2018 -0400
+++ b/mercurial/scmutil.py	Tue Apr 03 22:24:50 2018 +0900
@@ -754,7 +754,13 @@
         opts = {}
     m = matcher
     dry_run = opts.get('dry_run')
-    similarity = float(opts.get('similarity') or 0)
+    try:
+        similarity = float(opts.get('similarity') or 0)
+    except ValueError:
+        raise error.Abort(_('similarity must be a number'))
+    if similarity < 0 or similarity > 100:
+        raise error.Abort(_('similarity must be between 0 and 100'))
+    similarity /= 100.0
 
     ret = 0
     join = lambda f: os.path.join(prefix, f)