# HG changeset patch # User Thomas Arendsen Hein # Date 1185090318 -7200 # Node ID cf67b5f3743d827c70f3d26da2b010f30d647522 # Parent 4106dde15aed344dc2730e90ca153acf4c3f9365# Parent 8d982aef0be135cb780fa03e9b32cb92e9b371f6 merge with crew-stable diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -53,7 +53,10 @@ def addremove(ui, repo, *pats, **opts): between 0 (disabled) and 100 (files must be identical) as its parameter. Detecting renamed files this way can be expensive. """ - sim = float(opts.get('similarity') or 0) + try: + sim = float(opts.get('similarity') or 0) + except ValueError: + raise util.Abort(_('similarity must be a number')) if sim < 0 or sim > 100: raise util.Abort(_('similarity must be between 0 and 100')) return cmdutil.addremove(repo, pats, opts, similarity=sim/100.) diff --git a/tests/test-addremove-similar b/tests/test-addremove-similar --- a/tests/test-addremove-similar +++ b/tests/test-addremove-similar @@ -41,3 +41,9 @@ hg addremove -s50 hg commit -m B +echo % should all fail +hg addremove -s foo +hg addremove -s -1 +hg addremove -s 1e6 + +true diff --git a/tests/test-addremove-similar.out b/tests/test-addremove-similar.out --- a/tests/test-addremove-similar.out +++ b/tests/test-addremove-similar.out @@ -14,3 +14,7 @@ adding small-file removing large-file removing tiny-file recording removal of tiny-file as rename to small-file (82% similar) +% should all fail +abort: similarity must be a number +abort: similarity must be between 0 and 100 +abort: similarity must be between 0 and 100