comparison hgext/convert/__init__.py @ 4759:95cbb6b74790

convert: activate subversion engine Fail gracefully if the subversion python bindings are not installed. Support --rev option to convert as well as URL@rev.
author Brendan Cully <brendan@kublai.com>
date Sun, 01 Jul 2007 20:30:04 -0700
parents b6a1f2c46c6c
children 169fe1e6104c
comparison
equal deleted inserted replaced
4758:b6a1f2c46c6c 4759:95cbb6b74790
7 7
8 from common import NoRepo, converter_source, converter_sink 8 from common import NoRepo, converter_source, converter_sink
9 from cvs import convert_cvs 9 from cvs import convert_cvs
10 from git import convert_git 10 from git import convert_git
11 from hg import convert_mercurial 11 from hg import convert_mercurial
12 from subversion import convert_svn
12 13
13 import os, shutil 14 import os, shutil
14 from mercurial import hg, ui, util, commands 15 from mercurial import hg, ui, util, commands
15 16
16 commands.norepo += " convert" 17 commands.norepo += " convert"
17 18
18 converters = [convert_cvs, convert_git, convert_mercurial] 19 converters = [convert_cvs, convert_git, convert_svn, convert_mercurial]
19 20
20 def convertsource(ui, path, rev=None): 21 def convertsource(ui, path, rev=None):
21 for c in converters: 22 for c in converters:
22 try: 23 if not hasattr(c, 'getcommit'):
23 converter = c(ui, path, rev=rev) 24 continue
24 if not isinstance(converter, converter_source): 25 try:
25 raise util.Abort('%s: cannot read from this repository type' % path) 26 return c(ui, path, rev=rev)
26 return converter
27 except NoRepo: 27 except NoRepo:
28 pass 28 pass
29 raise util.Abort('%s: unknown repository type' % path) 29 raise util.Abort('%s: unknown repository type' % path)
30 30
31 def convertsink(ui, path): 31 def convertsink(ui, path):
32 if not os.path.isdir(path): 32 if not os.path.isdir(path):
33 raise util.Abort("%s: not a directory" % path) 33 raise util.Abort("%s: not a directory" % path)
34 for c in converters: 34 for c in converters:
35 try: 35 if not hasattr(c, 'putcommit'):
36 converter = c(ui, path) 36 continue
37 if not isinstance(converter, converter_sink): 37 try:
38 raise util.Abort('%s: cannot write to this repository type' % path) 38 return c(ui, path)
39 return converter
40 except NoRepo: 39 except NoRepo:
41 pass 40 pass
42 raise util.Abort('%s: unknown repository type' % path) 41 raise util.Abort('%s: unknown repository type' % path)
43 42
44 class convert(object): 43 class convert(object):