changeset 22511:b1ec65b3ba31

convert: simplify git.similarity parsing
author Siddharth Agarwal <sid0@fb.com>
date Tue, 23 Sep 2014 14:40:32 -0700
parents 911f5a6579d1
children 6b6da715cb96
files hgext/convert/git.py tests/test-convert-git.t
diffstat 2 files changed, 2 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/git.py	Wed Sep 24 20:11:36 2014 -0700
+++ b/hgext/convert/git.py	Tue Sep 23 14:40:32 2014 -0700
@@ -94,10 +94,7 @@
         if not os.path.exists(path + "/objects"):
             raise NoRepo(_("%s does not look like a Git repository") % path)
 
-        try:
-            similarity = int(ui.config('convert', 'git.similarity') or 0)
-        except ValueError:
-            raise util.Abort('convert.git.similarity must be a number')
+        similarity = ui.configint('convert', 'git.similarity', default=0)
         if similarity < 0 or similarity > 100:
             raise util.Abort(_('similarity must be between 0 and 100'))
         if similarity > 0:
--- a/tests/test-convert-git.t	Wed Sep 24 20:11:36 2014 -0700
+++ b/tests/test-convert-git.t	Tue Sep 23 14:40:32 2014 -0700
@@ -256,7 +256,7 @@
 
 input validation
   $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo
-  abort: convert.git.similarity must be a number
+  abort: convert.git.similarity is not an integer ('foo')
   [255]
   $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo
   abort: similarity must be between 0 and 100