Patchwork [1,of,2] convert: simplify git.similarity parsing

login
register
mail settings
Submitter Siddharth Agarwal
Date Sept. 23, 2014, 9:47 p.m.
Message ID <08dc4b2c31c0452927ce.1411508842@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/5932/
State Accepted
Headers show

Comments

Siddharth Agarwal - Sept. 23, 2014, 9:47 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1411508432 25200
#      Tue Sep 23 14:40:32 2014 -0700
# Node ID 08dc4b2c31c0452927ce637e32f814406a639344
# Parent  e6e7ef68c879b55c1b2c0ebe00d8cbdbc929dbed
convert: simplify git.similarity parsing

Patch

diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -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:
diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -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