Mercurial > hg
comparison hgext/convert/__init__.py @ 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 | 4ebc8693ce72 |
children | ef338e34a906 |
comparison
equal
deleted
inserted
replaced
5017:06329efa722d | 5018:c7623d2b2a66 |
---|---|
20 converters = [convert_cvs, convert_git, convert_svn, mercurial_source, | 20 converters = [convert_cvs, convert_git, convert_svn, mercurial_source, |
21 mercurial_sink] | 21 mercurial_sink] |
22 | 22 |
23 def convertsource(ui, path, **opts): | 23 def convertsource(ui, path, **opts): |
24 for c in converters: | 24 for c in converters: |
25 if not hasattr(c, 'getcommit'): | |
26 continue | |
27 try: | 25 try: |
28 return c(ui, path, **opts) | 26 return c.getcommit and c(ui, path, **opts) |
29 except NoRepo: | 27 except (AttributeError, NoRepo): |
30 pass | 28 pass |
31 raise util.Abort('%s: unknown repository type' % path) | 29 raise util.Abort('%s: unknown repository type' % path) |
32 | 30 |
33 def convertsink(ui, path): | 31 def convertsink(ui, path): |
34 if not os.path.isdir(path): | 32 if not os.path.isdir(path): |
35 raise util.Abort("%s: not a directory" % path) | 33 raise util.Abort("%s: not a directory" % path) |
36 for c in converters: | 34 for c in converters: |
37 if not hasattr(c, 'putcommit'): | |
38 continue | |
39 try: | 35 try: |
40 return c(ui, path) | 36 return c.putcommit and c(ui, path) |
41 except NoRepo: | 37 except (AttributeError, NoRepo): |
42 pass | 38 pass |
43 raise util.Abort('%s: unknown repository type' % path) | 39 raise util.Abort('%s: unknown repository type' % path) |
44 | 40 |
45 class convert(object): | 41 class convert(object): |
46 def __init__(self, ui, source, dest, revmapfile, filemapper, opts): | 42 def __init__(self, ui, source, dest, revmapfile, filemapper, opts): |