convert: simplify git.similarity parsing
authorSiddharth Agarwal <sid0@fb.com>
Tue, 23 Sep 2014 14:40:32 -0700
changeset 22511 b1ec65b3ba31
parent 22510 911f5a6579d1
child 22512 6b6da715cb96
convert: simplify git.similarity parsing
hgext/convert/git.py
tests/test-convert-git.t
--- 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