# HG changeset patch # User Bryan O'Sullivan # Date 1185482213 25200 # Node ID c7623d2b2a6657d46fcb3ce388d755ace43f0285 # Parent 06329efa722dd7a5764a51688e95e68acb64b432 convert: get rid of ugly use of hasattr diff --git a/hgext/convert/__init__.py b/hgext/convert/__init__.py --- a/hgext/convert/__init__.py +++ b/hgext/convert/__init__.py @@ -22,11 +22,9 @@ converters = [convert_cvs, convert_git, 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 @@ def convertsink(ui, path): 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)