changeset 5018:c7623d2b2a66

convert: get rid of ugly use of hasattr
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 26 Jul 2007 13:36:53 -0700
parents 06329efa722d
children e6cc4d4f5a81
files hgext/convert/__init__.py
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/__init__.py	Thu Jul 26 13:34:36 2007 -0700
+++ b/hgext/convert/__init__.py	Thu Jul 26 13:36:53 2007 -0700
@@ -22,11 +22,9 @@
 
 def convertsource(ui, path, **opts):
     for c in converters:
-        if not hasattr(c, 'getcommit'):
-            continue
         try:
-            return c(ui, path, **opts)
-        except NoRepo:
+            return c.getcommit and c(ui, path, **opts)
+        except (AttributeError, NoRepo):
             pass
     raise util.Abort('%s: unknown repository type' % path)
 
@@ -34,11 +32,9 @@
     if not os.path.isdir(path):
         raise util.Abort("%s: not a directory" % path)
     for c in converters:
-        if not hasattr(c, 'putcommit'):
-            continue
         try:
-            return c(ui, path)
-        except NoRepo:
+            return c.putcommit and c(ui, path)
+        except (AttributeError, NoRepo):
             pass
     raise util.Abort('%s: unknown repository type' % path)