26
26
return tests.test_suite()
29
def _defines_to_dict(defines):
30
"""Convert a list of definition strings to a dictionary."""
34
for define in defines:
35
kv = define.split('=', 1)
37
result[define.strip()] = 1
39
result[kv[0].strip()] = kv[1].strip()
29
43
class cmd_fast_import(Command):
30
44
"""Backend for fast Bazaar data importers.
62
76
takes_options = ['verbose',
63
77
RegistryOption.from_kwargs('method',
64
78
'The way to process the data.',
65
title='Processing Method', value_switches=True, enum_switch=False,
66
generic="Import the data into any format (default)",
67
info="Display information only - don't import it",
79
title='Processing Method',
80
value_switches=True, enum_switch=False,
81
safe="Import the data into any format (default).",
82
info="Display information only - don't import it.",
84
ListOption('params', short_name='P', type=str,
85
help="Define processing specific parameters.",
70
88
aliases = ['fastimport']
71
def run(self, verbose=False, method='generic'):
89
def run(self, verbose=False, method='safe', params=None):
73
91
from bzrlib import bzrdir
94
params = _defines_to_dict(params)
76
95
if method == 'info':
77
96
from bzrlib.plugins.fastimport.processors import info_processor
78
proc = info_processor.InfoProcessor()
97
proc = info_processor.InfoProcessor(params=params)
80
99
from bzrlib.plugins.fastimport.processors import generic_processor
81
100
control, relpath = bzrdir.BzrDir.open_containing('.')
82
proc = generic_processor.GenericProcessor(control)
101
proc = generic_processor.GenericProcessor(control, params=params)
84
103
# Note: might need to pass the parser to the processor so that the
85
104
# processor can be it's error reporting with source context