/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Ian Clatworthy
  • Date: 2009-08-17 01:44:34 UTC
  • mto: (0.64.207 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090817014434-6jfk6vcw7pljkx8d
Create a repository implicitly if one doesn't already exist

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
 
76
76
version_info = (0, 9, 0, 'dev', 0)
77
77
 
 
78
from bzrlib import bzrdir
78
79
from bzrlib.commands import Command, register_command
79
80
from bzrlib.option import Option, ListOption, RegistryOption
80
81
 
186
187
    """
187
188
    hidden = False
188
189
    _see_also = ['fast-export', 'fast-import-filter', 'fast-import-info']
189
 
    takes_args = ['source']
 
190
    takes_args = ['source', 'destination?']
190
191
    takes_options = ['verbose',
191
192
                    Option('info', type=str,
192
193
                        help="Path to file containing caching hints.",
221
222
                    Option('export-marks', type=str,
222
223
                        help="Export marks to file."
223
224
                        ),
 
225
                    RegistryOption('format',
 
226
                            help='Specify a format for the created repository. See'
 
227
                                 ' "bzr help formats" for details.',
 
228
                            lazy_registry=('bzrlib.bzrdir', 'format_registry'),
 
229
                            converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
 
230
                            value_switches=False, title='Repository format'),
224
231
                     ]
225
232
    aliases = []
226
 
    def run(self, source, verbose=False, info=None, trees=False,
227
 
        count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
228
 
        mode=None, import_marks=None, export_marks=None):
229
 
        from bzrlib import bzrdir
 
233
    def run(self, source, destination='.', verbose=False, info=None,
 
234
        trees=False, count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
 
235
        mode=None, import_marks=None, export_marks=None, format=None):
230
236
        from bzrlib.errors import BzrCommandError, NotBranchError
231
237
        from bzrlib.plugins.fastimport.processors import generic_processor
 
238
        from bzrlib.plugins.fastimport.helpers import (
 
239
            open_destination_directory,
 
240
            )
232
241
        if mode is None:
233
242
            mode = 'default'
234
 
        try:
235
 
            control, relpath = bzrdir.BzrDir.open_containing('.')
236
 
        except NotBranchError:
237
 
            raise BzrCommandError("current directory has no .bzr"
238
 
                " directory - use bzr init-repo or bzr init to initialize"
239
 
                " before using bzr fast-import")
240
243
        params = {
241
244
            'info': info,
242
245
            'trees': trees,
248
251
            'import-marks': import_marks,
249
252
            'export-marks': export_marks,
250
253
            }
 
254
        # If no format is given and the user is running a release
 
255
        # leading up to 2.0, select 2a for them. Otherwise, use
 
256
        # the default format.
 
257
        if format is None:
 
258
            import bzrlib
 
259
            bzr_version = bzrlib.version_info[0:2]
 
260
            if bzr_version in [(1,17), (1,18), (2,0)]:
 
261
                format = bzrdir.format_registry.make_bzrdir('2a')
 
262
        control = open_destination_directory(destination, format=format)
251
263
        return _run(source, generic_processor.GenericProcessor, control,
252
264
            params, verbose)
253
265