/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
1
# Copyright (C) 2008 Canonical Ltd
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
0.64.81 by Ian Clatworthy
'bzr help fastimport' now provides useful help
17
r"""FastImport Plugin
18
=================
19
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
20
The fastimport plugin provides stream-based importing and exporting of
21
data into and out of Bazaar. As well as enabling interchange between
0.64.81 by Ian Clatworthy
'bzr help fastimport' now provides useful help
22
multiple VCS tools, fastimport/export can be useful for complex branch
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
23
operations, e.g. partitioning off part of a code base in order to Open
0.64.81 by Ian Clatworthy
'bzr help fastimport' now provides useful help
24
Source it.
25
26
The normal import recipe is::
27
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
28
  bzr fast-export-from-xxx SOURCE project.fi
0.95.2 by Ian Clatworthy
update help
29
  bzr fast-import project.fi project.bzr
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
30
31
If fast-export-from-xxx doesn't exist yet for the tool you're importing
32
from, the alternative recipe is::
33
34
  front-end > project.fi
0.95.2 by Ian Clatworthy
update help
35
  bzr fast-import project.fi project.fi
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
36
37
The list of known front-ends and their status is documented on
38
http://bazaar-vcs.org/BzrFastImport/FrontEnds. The fast-export-from-xxx
39
commands provide simplified access to these so that the majority of users
40
can generate a fast-import dump file without needing to study up on all
41
the options - and the best combination of them to use - for the front-end
42
relevant to them. In some cases, a fast-export-from-xxx wrapper will require
43
that certain dependencies are installed so it checks for these before
44
starting. A wrapper may also provide a limited set of options. See the
45
online help for the individual commands for details::
46
0.64.205 by Ian Clatworthy
added fast-export-to-cvs
47
  bzr help fast-export-from-cvs
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
48
  bzr help fast-export-from-darcs
49
  bzr help fast-export-from-hg
50
  bzr help fast-export-from-git
0.64.205 by Ian Clatworthy
added fast-export-to-cvs
51
  bzr help fast-export-from-mnt
0.94.1 by Matt McClure
Adds a fast-export-from-p4 command.
52
  bzr help fast-export-from-p4
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
53
  bzr help fast-export-from-svn
54
55
Once a fast-import dump file is created, it can be imported into a
56
Bazaar repository using the fast-import command. If required, you can
57
manipulate the stream first using the fast-import-filter command.
58
This is useful for creating a repository with just part of a project
59
or for removing large old binaries (say) from history that are no longer
60
valuable to retain. For further details on importing, manipulating and
61
reporting on fast-import streams, see the online help for the commands::
0.64.81 by Ian Clatworthy
'bzr help fastimport' now provides useful help
62
63
  bzr help fast-import
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
64
  bzr help fast-import-filter
0.64.81 by Ian Clatworthy
'bzr help fastimport' now provides useful help
65
  bzr help fast-import-info
0.64.111 by Ian Clatworthy
rename fast-import-filter to fast-import-query
66
  bzr help fast-import-query
0.64.81 by Ian Clatworthy
'bzr help fastimport' now provides useful help
67
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
68
Finally, you may wish to generate a fast-import dump file from a Bazaar
69
repository. The fast-export command is provided for that purpose.
70
0.64.81 by Ian Clatworthy
'bzr help fastimport' now provides useful help
71
To report bugs or publish enhancements, visit the bzr-fastimport project
72
page on Launchpad, https://launchpad.net/bzr-fastimport.
73
"""
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
74
0.64.185 by Ian Clatworthy
Open 0.9 development
75
version_info = (0, 9, 0, 'dev', 0)
0.64.126 by Ian Clatworthy
ensure version appears in bzr plugins output (Alexander Belchenko)
76
0.95.1 by Ian Clatworthy
Create a repository implicitly if one doesn't already exist
77
from bzrlib import bzrdir
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
78
from bzrlib.commands import Command, register_command
0.64.171 by Ian Clatworthy
use inv deltas by default for all formats now: --classic to get old algorithm for packs
79
from bzrlib.option import Option, ListOption, RegistryOption
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
80
81
82
def test_suite():
83
    import tests
84
    return tests.test_suite()
85
86
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
87
def _run(source, processor_factory, control, params, verbose):
88
    """Create and run a processor.
89
    
90
    :param source: a filename or '-' for standard input
91
    :param processor_factory: a callable for creating a processor
92
    :param control: the BzrDir of the destination or None if no
93
      destination is expected
94
    """
95
    import parser
96
    if source == '-':
97
        import sys
0.84.2 by Ian Clatworthy
make sure fast-export uses a binary stream on Windows
98
        stream = helpers.binary_stream(sys.stdin)
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
99
    else:
0.65.6 by James Westby
Open the input in binary mode, as suggested by Paul Moore.
100
        stream = open(source, "rb")
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
101
    proc = processor_factory(control, params=params, verbose=verbose)
102
    p = parser.ImportParser(stream, verbose=verbose)
103
    return proc.process(p.iter_commands)
0.64.8 by Ian Clatworthy
custom parameters for processors
104
105
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
106
class cmd_fast_import(Command):
107
    """Backend for fast Bazaar data importers.
108
0.95.2 by Ian Clatworthy
update help
109
    This command reads a mixed command/data stream and creates
110
    branches in a Bazaar repository accordingly. The preferred
111
    recipe is::
112
113
      bzr fast-import project.fi project.bzr
114
115
    Numerous commands are provided for generating a fast-import file
116
    to use as input. These are named fast-export-from-xxx where xxx
117
    is one of cvs, darcs, git, hg, mnt, p4 or svn.
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
118
    To specify standard input as the input stream, use a
0.95.2 by Ian Clatworthy
update help
119
    source name of '-' (instead of project.fi).
120
    
121
    project.bzr will be created if it doesn't exist. If it exists
122
    already, it should be empty or be an existing Bazaar repository
123
    or branch. If not specified, the current directory is assumed.
124
 
125
    fast-import will intelligently select the format to use when
126
    creating a repository or branch. If you are running Bazaar 1.17
127
    up to Bazaar 2.0, the default format for Bazaar 2.x ("2a") is used.
128
    Otherwise, the current default format ("pack-0.92" for Bazaar 1.x)
129
    is used. If you wish to specify a custom format, use the --format
130
    option.
131
132
     .. note::
133
     
134
        To maintain backwards compatibility, fast-import lets you
135
        create the target repository or standalone branch yourself.
136
        It is recommended though that you let fast-import create
137
        these for you instead.
138
139
    :Branch mapping rules:
140
141
     Git reference names are mapped to Bazaar branch names as follows:
0.82.1 by Ian Clatworthy
nicer and round-trippable mapping of git ref names to bzr branch names
142
      
0.95.2 by Ian Clatworthy
update help
143
     * refs/heads/foo is mapped to foo
144
     * refs/remotes/origin/foo is mapped to foo.remote
145
     * refs/tags/foo is mapped to foo.tag
146
     * */master is mapped to trunk, trunk.remote, etc.
147
     * */trunk is mapped to git-trunk, git-trunk.remote, etc.
148
149
    :Branch creation rules:
150
151
     When a shared repository is created or found at the destination,
152
     branches are created inside it. In the simple case of a single
153
     branch (refs/heads/master) inside the input file, the branch is
154
     project.bzr/trunk.
155
156
     When a standalone branch is found at the destination, the trunk
157
     is imported there and warnings are output about any other branches
158
     found in the input file.
159
160
     When a branch in a shared repository is found at the destination,
161
     that branch is made the trunk and other branches, if any, are
162
     created in sister directories.
163
0.95.3 by Ian Clatworthy
Update the working tree for trunk implicitly
164
    :Working tree updates:
165
166
     The working tree is generated for the trunk branch. If multiple
167
     branches are created, a message is output on completion explaining
168
     how to create the working trees for other branches.
169
0.95.2 by Ian Clatworthy
update help
170
    :Custom exporters:
171
172
     The fast-export-from-xxx commands typically call more advanced
173
     xxx-fast-export scripts. You are welcome to use the advanced
174
     scripts if you prefer.
175
176
     If you wish to write a custom exporter for your project, see
177
     http://bazaar-vcs.org/BzrFastImport for the detailed protocol
178
     specification. In many cases, exporters can be written quite
179
     quickly using whatever scripting/programming language you like.
180
181
    :Reducing memory usage:
182
183
     A slightly more complex recipe is required when importing large
184
     projects via exporters (like fast-export-from-git and
185
     git-fast-export) that reuse blob data across commits.
186
     The recipe is::
187
188
       front-end > xxx.fi
189
       bzr fast-import-info -v xxx.fi > xxx.cfg
190
       bzr fast-import xxx.fi --info xxx.cfg xxx.bzr
191
192
     In this scenario, the xxx.cfg file generated by the first pass
193
     holds caching hints that the second pass uses to lower memory
194
     usage. Development is planned so that this recipe becomes obsolete
195
     in the future, i.e. so that the simple recipe always works.
196
197
    :Restarting an import:
198
199
     At checkpoints and on completion, the commit-id -> revision-id
200
     map is saved to a file called 'fastimport-id-map' in the control
201
     directory for the repository (e.g. .bzr/repository). If the import
202
     is interrupted or unexpectedly crashes, it can be started again
203
     and this file will be used to skip over already loaded revisions.
204
     As long as subsequent exports from the original source begin
205
     with exactly the same revisions, you can use this feature to
206
     maintain a mirror of a repository managed by a foreign tool.
207
     If and when Bazaar is used to manage the repository, this file
208
     can be safely deleted.
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
209
0.64.201 by Ian Clatworthy
tweak help formatting
210
    :Examples:
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
211
0.64.201 by Ian Clatworthy
tweak help formatting
212
     Import a Subversion repository into Bazaar::
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
213
214
       bzr fast-export-from-svn /svn/repo/path project.fi
0.95.3 by Ian Clatworthy
Update the working tree for trunk implicitly
215
       bzr fast-import project.fi project.bzr
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
216
0.95.2 by Ian Clatworthy
update help
217
     Import a CVS repository into Bazaar::
218
219
       bzr fast-export-from-cvs /cvs/repo/path project.fi
0.95.3 by Ian Clatworthy
Update the working tree for trunk implicitly
220
       bzr fast-import project.fi project.bzr
0.95.2 by Ian Clatworthy
update help
221
0.64.201 by Ian Clatworthy
tweak help formatting
222
     Import a Git repository into Bazaar::
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
223
224
       bzr fast-export-from-git /git/repo/path project.fi
0.95.3 by Ian Clatworthy
Update the working tree for trunk implicitly
225
       bzr fast-import project.fi project.bzr
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
226
0.64.201 by Ian Clatworthy
tweak help formatting
227
     Import a Mercurial repository into Bazaar::
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
228
229
       bzr fast-export-from-hg /hg/repo/path project.fi
0.95.3 by Ian Clatworthy
Update the working tree for trunk implicitly
230
       bzr fast-import project.fi project.bzr
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
231
0.64.201 by Ian Clatworthy
tweak help formatting
232
     Import a Darcs repository into Bazaar::
0.93.12 by Ian Clatworthy
NEWS item and doco tweaks
233
234
       bzr fast-export-from-darcs /darcs/repo/path project.fi
0.95.3 by Ian Clatworthy
Update the working tree for trunk implicitly
235
       bzr fast-import project.fi project.bzr
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
236
    """
0.64.120 by Ian Clatworthy
unhide fast-import and fast-import-info commands
237
    hidden = False
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
238
    _see_also = ['fast-export', 'fast-import-filter', 'fast-import-info']
0.95.1 by Ian Clatworthy
Create a repository implicitly if one doesn't already exist
239
    takes_args = ['source', 'destination?']
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
240
    takes_options = ['verbose',
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
241
                    Option('info', type=str,
242
                        help="Path to file containing caching hints.",
243
                        ),
244
                    Option('trees',
0.95.3 by Ian Clatworthy
Update the working tree for trunk implicitly
245
                        help="Update all working trees, not just trunk's.",
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
246
                        ),
247
                    Option('count', type=int,
248
                        help="Import this many revisions then exit.",
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
249
                        ),
0.64.170 by Ian Clatworthy
add autopack option to fast-import
250
                    Option('checkpoint', type=int,
251
                        help="Checkpoint automatically every N revisions."
252
                             " The default is 10000.",
253
                        ),
254
                    Option('autopack', type=int,
255
                        help="Pack every N checkpoints. The default is 4.",
256
                        ),
0.64.44 by Ian Clatworthy
smart caching of serialised inventories
257
                    Option('inv-cache', type=int,
258
                        help="Number of inventories to cache.",
259
                        ),
0.64.171 by Ian Clatworthy
use inv deltas by default for all formats now: --classic to get old algorithm for packs
260
                    RegistryOption.from_kwargs('mode',
261
                        'The import algorithm to use.',
262
                        title='Import Algorithm',
263
                        default='Use the preferred algorithm (inventory deltas).',
264
                        classic="Use the original algorithm (mutable inventories).",
265
                        experimental="Enable experimental features.",
266
                        value_switches=True, enum_switch=False,
0.64.47 by Ian Clatworthy
add option for enabling experimental stuff
267
                        ),
0.68.7 by Pieter de Bie
Add importing and exporting of marks to bzr-fastimport
268
                    Option('import-marks', type=str,
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
269
                        help="Import marks from file."
270
                        ),
0.68.7 by Pieter de Bie
Add importing and exporting of marks to bzr-fastimport
271
                    Option('export-marks', type=str,
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
272
                        help="Export marks to file."
273
                        ),
0.95.1 by Ian Clatworthy
Create a repository implicitly if one doesn't already exist
274
                    RegistryOption('format',
275
                            help='Specify a format for the created repository. See'
276
                                 ' "bzr help formats" for details.',
277
                            lazy_registry=('bzrlib.bzrdir', 'format_registry'),
278
                            converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
279
                            value_switches=False, title='Repository format'),
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
280
                     ]
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
281
    aliases = []
0.95.1 by Ian Clatworthy
Create a repository implicitly if one doesn't already exist
282
    def run(self, source, destination='.', verbose=False, info=None,
283
        trees=False, count=-1, checkpoint=10000, autopack=4, inv_cache=-1,
284
        mode=None, import_marks=None, export_marks=None, format=None):
0.64.135 by Ian Clatworthy
improve error message when .bzr directory not found
285
        from bzrlib.errors import BzrCommandError, NotBranchError
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
286
        from bzrlib.plugins.fastimport.processors import generic_processor
0.95.1 by Ian Clatworthy
Create a repository implicitly if one doesn't already exist
287
        from bzrlib.plugins.fastimport.helpers import (
288
            open_destination_directory,
289
            )
0.64.171 by Ian Clatworthy
use inv deltas by default for all formats now: --classic to get old algorithm for packs
290
        if mode is None:
291
            mode = 'default'
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
292
        params = {
293
            'info': info,
294
            'trees': trees,
0.64.170 by Ian Clatworthy
add autopack option to fast-import
295
            'count': count,
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
296
            'checkpoint': checkpoint,
0.64.170 by Ian Clatworthy
add autopack option to fast-import
297
            'autopack': autopack,
0.64.44 by Ian Clatworthy
smart caching of serialised inventories
298
            'inv-cache': inv_cache,
0.64.171 by Ian Clatworthy
use inv deltas by default for all formats now: --classic to get old algorithm for packs
299
            'mode': mode,
0.68.7 by Pieter de Bie
Add importing and exporting of marks to bzr-fastimport
300
            'import-marks': import_marks,
301
            'export-marks': export_marks,
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
302
            }
0.95.1 by Ian Clatworthy
Create a repository implicitly if one doesn't already exist
303
        # If no format is given and the user is running a release
304
        # leading up to 2.0, select 2a for them. Otherwise, use
305
        # the default format.
306
        if format is None:
307
            import bzrlib
308
            bzr_version = bzrlib.version_info[0:2]
309
            if bzr_version in [(1,17), (1,18), (2,0)]:
310
                format = bzrdir.format_registry.make_bzrdir('2a')
311
        control = open_destination_directory(destination, format=format)
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
312
        return _run(source, generic_processor.GenericProcessor, control,
313
            params, verbose)
314
315
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
316
class cmd_fast_import_filter(Command):
317
    """Filter a fast-import stream to include/exclude files & directories.
318
319
    This command is useful for splitting a subdirectory or bunch of
320
    files out from a project to create a new project complete with history
321
    for just those files. It can also be used to create a new project
322
    repository that removes all references to files that should not have
323
    been committed, e.g. security-related information (like passwords),
324
    commercially sensitive material, files with an incompatible license or
325
    large binary files like CD images.
326
327
    When filtering out a subdirectory (or file), the new stream uses the
328
    subdirectory (or subdirectory containing the file) as the root. As
329
    fast-import doesn't know in advance whether a path is a file or
330
    directory in the stream, you need to specify a trailing '/' on
331
    directories passed to the --includes option. If multiple files or
332
    directories are given, the new root is the deepest common directory.
333
334
    To specify standard input as the input stream, use a source
335
    name of '-'.
336
337
    Note: If a path has been renamed, take care to specify the *original*
338
    path name, not the final name that it ends up with.
339
0.64.201 by Ian Clatworthy
tweak help formatting
340
    :Examples:
341
342
     Create a new project from a library (note the trailing / on the
343
     directory name of the library)::
344
345
       front-end | bzr fast-import-filter -i lib/xxx/ > xxx.fi
0.95.2 by Ian Clatworthy
update help
346
       bzr fast-import xxx.fi mylibrary.bzr
0.64.201 by Ian Clatworthy
tweak help formatting
347
       (lib/xxx/foo is now foo)
348
349
     Create a new repository without a sensitive file::
350
351
       front-end | bzr fast-import-filter -x missile-codes.txt > clean.fi
0.95.2 by Ian Clatworthy
update help
352
       bzr fast-import clean.fi clean.bzr
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
353
    """
354
    hidden = False
355
    _see_also = ['fast-import']
356
    takes_args = ['source']
357
    takes_options = ['verbose',
0.77.5 by Ian Clatworthy
add _paths to option & params names as other types of filtering may be added later
358
                    ListOption('include_paths', short_name='i', type=str,
359
                        help="Only include commits affecting these paths."
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
360
                             " Directories should have a trailing /."
361
                        ),
0.77.5 by Ian Clatworthy
add _paths to option & params names as other types of filtering may be added later
362
                    ListOption('exclude_paths', short_name='x', type=str,
363
                        help="Exclude these paths from commits."
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
364
                        ),
365
                     ]
366
    aliases = []
0.77.17 by Alexander Belchenko
fast-import-filter should produce binary output.
367
    encoding_type = 'exact'
0.77.5 by Ian Clatworthy
add _paths to option & params names as other types of filtering may be added later
368
    def run(self, source, verbose=False, include_paths=None,
369
        exclude_paths=None):
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
370
        from bzrlib.plugins.fastimport.processors import filter_processor
371
        params = {
0.77.5 by Ian Clatworthy
add _paths to option & params names as other types of filtering may be added later
372
            'include_paths': include_paths,
373
            'exclude_paths': exclude_paths,
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
374
            }
375
        return _run(source, filter_processor.FilterProcessor, None, params,
376
            verbose)
377
378
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
379
class cmd_fast_import_info(Command):
380
    """Output information about a fast-import stream.
381
382
    This command reads a fast-import stream and outputs
383
    statistics and interesting properties about what it finds.
384
    When run in verbose mode, the information is output as a
385
    configuration file that can be passed to fast-import to
386
    assist it in intelligently caching objects.
387
388
    To specify standard input as the input stream, use a source
389
    name of '-'.
390
0.64.201 by Ian Clatworthy
tweak help formatting
391
    :Examples:
392
393
     Display statistics about the import stream produced by front-end::
394
395
      front-end | bzr fast-import-info -
396
397
     Create a hints file for running fast-import on a large repository::
398
399
       front-end | bzr fast-import-info -v - > front-end.cfg
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
400
    """
0.64.120 by Ian Clatworthy
unhide fast-import and fast-import-info commands
401
    hidden = False
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
402
    _see_also = ['fast-import']
403
    takes_args = ['source']
404
    takes_options = ['verbose']
405
    aliases = []
406
    def run(self, source, verbose=False):
407
        from bzrlib.plugins.fastimport.processors import info_processor
408
        return _run(source, info_processor.InfoProcessor, None, {}, verbose)
409
410
0.64.111 by Ian Clatworthy
rename fast-import-filter to fast-import-query
411
class cmd_fast_import_query(Command):
412
    """Query a fast-import stream displaying selected commands.
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
413
414
    To specify standard input as the input stream, use a source
415
    name of '-'. To specify the commands to display, use the -C
416
    option one or more times. To specify just some fields for
417
    a command, use the syntax::
418
419
      command=field1,...
420
421
    By default, the nominated fields for the nominated commands
422
    are displayed tab separated. To see the information in
423
    a name:value format, use verbose mode.
424
425
    Note: Binary fields (e.g. data for blobs) are masked out
426
    so it is generally safe to view the output in a terminal.
427
0.64.201 by Ian Clatworthy
tweak help formatting
428
    :Examples:
429
430
    Show all the fields of the reset and tag commands::
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
431
432
      front-end > xxx.fi
0.64.111 by Ian Clatworthy
rename fast-import-filter to fast-import-query
433
      bzr fast-import-query xxx.fi -Creset -Ctag
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
434
0.64.201 by Ian Clatworthy
tweak help formatting
435
    Show the mark and merge fields of the commit commands::
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
436
0.64.111 by Ian Clatworthy
rename fast-import-filter to fast-import-query
437
      bzr fast-import-query xxx.fi -Ccommit=mark,merge
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
438
    """
439
    hidden = True
0.64.120 by Ian Clatworthy
unhide fast-import and fast-import-info commands
440
    _see_also = ['fast-import', 'fast-import-filter']
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
441
    takes_args = ['source']
442
    takes_options = ['verbose',
443
                    ListOption('commands', short_name='C', type=str,
444
                        help="Display fields for these commands."
445
                        ),
446
                     ]
447
    aliases = []
448
    def run(self, source, verbose=False, commands=None):
0.64.111 by Ian Clatworthy
rename fast-import-filter to fast-import-query
449
        from bzrlib.plugins.fastimport.processors import query_processor
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
450
        from bzrlib.plugins.fastimport import helpers
451
        params = helpers.defines_to_dict(commands)
0.64.111 by Ian Clatworthy
rename fast-import-filter to fast-import-query
452
        return _run(source, query_processor.QueryProcessor, None, params,
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
453
            verbose)
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
454
455
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
456
class cmd_fast_export(Command):
457
    """Generate a fast-import stream from a Bazaar branch.
458
459
    This program generates a stream from a bzr branch in the format required by
460
    git-fast-import(1). It preserves merges correctly, even merged branches with
461
    no common history (`bzr merge -r 0..-1`).
462
0.64.201 by Ian Clatworthy
tweak help formatting
463
    :Examples:
464
465
     To import several unmerged but related branches into the same repository,
466
     use the --{export,import}-marks options, and specify a name for the git
467
     branch like this::
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
468
    
0.64.201 by Ian Clatworthy
tweak help formatting
469
      bzr fast-export --export-marks=marks.bzr project.dev |
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
470
              GIT_DIR=project/.git git-fast-import --export-marks=marks.git
471
0.64.201 by Ian Clatworthy
tweak help formatting
472
      bzr fast-export --import-marks=marks.bzr -b other project.other |
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
473
              GIT_DIR=project/.git git-fast-import --import-marks=marks.git
0.79.10 by Ian Clatworthy
documentation clean-ups
474
0.64.201 by Ian Clatworthy
tweak help formatting
475
     If you get a "Missing space after source" error from git-fast-import,
476
     see the top of the commands.py module for a work-around.
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
477
    """
0.79.10 by Ian Clatworthy
documentation clean-ups
478
    hidden = False
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
479
    _see_also = ['fast-import', 'fast-import-filter']
480
    takes_args = ['source']
0.64.173 by Ian Clatworthy
add -r option to fast-export
481
    takes_options = ['verbose', 'revision',
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
482
                    Option('git-branch', short_name='b', type=str,
483
                        argname='FILE',
484
                        help='Name of the git branch to create (default=master).'
485
                        ),
486
                    Option('checkpoint', type=int, argname='N',
0.64.173 by Ian Clatworthy
add -r option to fast-export
487
                        help="Checkpoint every N revisions (default=10000)."
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
488
                        ),
489
                    Option('marks', type=str, argname='FILE',
490
                        help="Import marks from and export marks to file."
491
                        ),
492
                    Option('import-marks', type=str, argname='FILE',
493
                        help="Import marks from file."
494
                        ),
495
                    Option('export-marks', type=str, argname='FILE',
496
                        help="Export marks to file."
497
                        ),
498
                     ]
499
    aliases = []
0.86.1 by Alexander Belchenko
fast-export should force binary sys.stdout on win32
500
    encoding_type = 'exact'
0.64.173 by Ian Clatworthy
add -r option to fast-export
501
    def run(self, source, verbose=False, git_branch="master", checkpoint=10000,
502
        marks=None, import_marks=None, export_marks=None, revision=None):
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
503
        from bzrlib.plugins.fastimport import bzr_exporter
504
505
        if marks:                                              
506
            import_marks = export_marks = marks
507
        exporter = bzr_exporter.BzrFastExporter(source,
508
            git_branch=git_branch, checkpoint=checkpoint,
0.64.173 by Ian Clatworthy
add -r option to fast-export
509
            import_marks_file=import_marks, export_marks_file=export_marks,
0.64.176 by Ian Clatworthy
faster export of revision range & improved diagnostics in fast-export
510
            revision=revision, verbose=verbose)
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
511
        return exporter.run()
512
513
0.64.205 by Ian Clatworthy
added fast-export-to-cvs
514
class cmd_fast_export_from_cvs(Command):
515
    """Generate a fast-import file from a CVS repository.
516
517
    Destination is a dump file, typically named xxx.fi where xxx is
518
    the name of the project. If '-' is given, standard output is used.
519
520
    cvs2svn 2.3 or later must be installed as its cvs2bzr script is used
521
    under the covers to do the export. (If cvs2bzr is not included in
522
    cvs2svn yet, grab the branch from
523
    https://code.launchpad.net/~ian-clatworthy/+junk/cvs2svn and use it.)
524
    
525
    The source must be the path on your filesystem to the part of the
526
    repository you wish to convert. i.e. either that path or a parent
527
    directory must contain a CVSROOT subdirectory. The path may point to
528
    either the top of a repository or to a path within it. In the latter
529
    case, only that project within the repository will be converted.
530
531
    .. note::
532
       Remote access to the repository is not sufficient - the path
533
       must point into a copy of the repository itself. See
534
       http://cvs2svn.tigris.org/faq.html#repoaccess for instructions
535
       on how to clone a remote CVS repository locally.
536
537
    By default, the trunk, branches and tags are all exported. If you
538
    only want the trunk, use the --trunk-only option.
539
540
    By default, filenames, log messages and author names are expected
541
    to be encoded in ascii. Use the --encoding option to specify an
542
    alternative. If multiple encodings are used, specify the option
543
    multiple times. For a list of valid encoding names, see
544
    http://docs.python.org/lib/standard-encodings.html.
545
546
    Windows users need to install GNU sort and use the --sort
547
    option to specify its location. GNU sort can be downloaded from
548
    http://unxutils.sourceforge.net/.
549
    """
550
    hidden = False
551
    _see_also = ['fast-import', 'fast-import-filter']
552
    takes_args = ['source', 'destination']
553
    takes_options = ['verbose',
554
                    Option('trunk-only',
555
                        help="Export just the trunk, ignoring tags and branches."
556
                        ),
557
                    ListOption('encoding', type=str, argname='CODEC',
558
                        help="Encoding used for filenames, commit messages "
559
                             "and author names if not ascii."
560
                        ),
561
                    Option('sort', type=str, argname='PATH',
562
                        help="GNU sort program location if not on the path."
563
                        ),
564
                    ]
565
    aliases = []
566
    encoding_type = 'exact'
567
    def run(self, source, destination, verbose=False, trunk_only=False,
568
        encoding=None, sort=None):
569
        from bzrlib.plugins.fastimport.exporters import fast_export_from
570
        custom = []
571
        if trunk_only:
572
            custom.append("--trunk-only")
573
        if encoding:
574
            for enc in encoding:
575
                custom.extend(['--encoding', enc])
576
        if sort:
577
            custom.extend(['--sort', sort])
578
        fast_export_from(source, destination, 'cvs', verbose, custom)
579
580
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
581
class cmd_fast_export_from_darcs(Command):
582
    """Generate a fast-import file from a Darcs repository.
583
0.64.202 by Ian Clatworthy
more help tweaks
584
    Destination is a dump file, typically named xxx.fi where xxx is
585
    the name of the project. If '-' is given, standard output is used.
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
586
587
    Darcs 2.2 or later must be installed as various subcommands are
588
    used to access the source repository. The source may be a network
589
    URL but using a local URL is recommended for performance reasons.
590
    """
591
    hidden = False
592
    _see_also = ['fast-import', 'fast-import-filter']
593
    takes_args = ['source', 'destination']
0.93.8 by Ian Clatworthy
add encoding option to fast-export-from-darcs
594
    takes_options = ['verbose',
595
                    Option('encoding', type=str, argname='CODEC',
596
                        help="Encoding used for commit messages if not utf-8."
597
                        ),
598
                    ]
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
599
    aliases = []
600
    encoding_type = 'exact'
0.93.8 by Ian Clatworthy
add encoding option to fast-export-from-darcs
601
    def run(self, source, destination, verbose=False, encoding=None):
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
602
        from bzrlib.plugins.fastimport.exporters import fast_export_from
0.93.8 by Ian Clatworthy
add encoding option to fast-export-from-darcs
603
        custom = None
604
        if encoding is not None:
605
            custom = ['--encoding', encoding]
606
        fast_export_from(source, destination, 'darcs', verbose, custom)
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
607
608
609
class cmd_fast_export_from_hg(Command):
610
    """Generate a fast-import file from a Mercurial repository.
611
0.64.202 by Ian Clatworthy
more help tweaks
612
    Destination is a dump file, typically named xxx.fi where xxx is
613
    the name of the project. If '-' is given, standard output is used.
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
614
615
    Mercurial 1.2 or later must be installed as its libraries are used
616
    to access the source repository. Given the APIs currently used,
617
    the source repository must be a local file, not a network URL.
618
    """
619
    hidden = False
620
    _see_also = ['fast-import', 'fast-import-filter']
621
    takes_args = ['source', 'destination']
622
    takes_options = ['verbose']
623
    aliases = []
624
    encoding_type = 'exact'
625
    def run(self, source, destination, verbose=False):
626
        from bzrlib.plugins.fastimport.exporters import fast_export_from
627
        fast_export_from(source, destination, 'hg', verbose)
628
629
630
class cmd_fast_export_from_git(Command):
631
    """Generate a fast-import file from a Git repository.
632
0.64.202 by Ian Clatworthy
more help tweaks
633
    Destination is a dump file, typically named xxx.fi where xxx is
634
    the name of the project. If '-' is given, standard output is used.
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
635
636
    Git 1.6 or later must be installed as the git fast-export
637
    subcommand is used under the covers to generate the stream.
0.93.3 by Ian Clatworthy
implement fast-export-from-git
638
    The source must be a local directory.
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
639
0.64.201 by Ian Clatworthy
tweak help formatting
640
    .. note::
641
    
642
       Earlier versions of Git may also work fine but are
643
       likely to receive less active support if problems arise.
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
644
    """
645
    hidden = False
646
    _see_also = ['fast-import', 'fast-import-filter']
647
    takes_args = ['source', 'destination']
648
    takes_options = ['verbose']
649
    aliases = []
650
    encoding_type = 'exact'
651
    def run(self, source, destination, verbose=False):
652
        from bzrlib.plugins.fastimport.exporters import fast_export_from
653
        fast_export_from(source, destination, 'git', verbose)
654
655
0.64.204 by Ian Clatworthy
added fast-export-from-mnt command
656
class cmd_fast_export_from_mnt(Command):
657
    """Generate a fast-import file from a Monotone repository.
658
659
    Destination is a dump file, typically named xxx.fi where xxx is
660
    the name of the project. If '-' is given, standard output is used.
661
662
    Monotone 0.43 or later must be installed as the mnt git_export
663
    subcommand is used under the covers to generate the stream.
664
    The source must be a local directory.
665
    """
666
    hidden = False
667
    _see_also = ['fast-import', 'fast-import-filter']
668
    takes_args = ['source', 'destination']
669
    takes_options = ['verbose']
670
    aliases = []
671
    encoding_type = 'exact'
672
    def run(self, source, destination, verbose=False):
673
        from bzrlib.plugins.fastimport.exporters import fast_export_from
674
        fast_export_from(source, destination, 'mnt', verbose)
675
676
0.94.1 by Matt McClure
Adds a fast-export-from-p4 command.
677
class cmd_fast_export_from_p4(Command):
678
    """Generate a fast-import file from a Perforce repository.
679
680
    Source is a Perforce depot path, e.g., //depot/project
681
682
    Destination is a dump file, typically named xxx.fi where xxx is
683
    the name of the project. If '-' is given, standard output is used.
684
685
    bzrp4 must be installed as its p4_fast_export.py module is used under
686
    the covers to do the export.  bzrp4 can be downloaded from
687
    https://launchpad.net/bzrp4/.
688
    
689
    The P4PORT environment variable must be set, and you must be logged
690
    into the Perforce server.
691
692
    By default, only the HEAD changelist is exported.  To export all
693
    changelists, append '@all' to the source.  To export a revision range,
694
    append a comma-delimited pair of changelist numbers to the source,
695
    e.g., '100,200'.
696
    """
697
    hidden = False
698
    _see_also = ['fast-import', 'fast-import-filter']
699
    takes_args = ['source', 'destination']
700
    takes_options = []
701
    aliases = []
702
    encoding_type = 'exact'
703
    def run(self, source, destination, verbose=False):
704
        from bzrlib.plugins.fastimport.exporters import fast_export_from
705
        custom = []
706
        fast_export_from(source, destination, 'p4', verbose, custom)
707
708
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
709
class cmd_fast_export_from_svn(Command):
710
    """Generate a fast-import file from a Subversion repository.
711
0.64.202 by Ian Clatworthy
more help tweaks
712
    Destination is a dump file, typically named xxx.fi where xxx is
713
    the name of the project. If '-' is given, standard output is used.
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
714
715
    Python-Subversion (Python bindings to the Subversion APIs)
716
    1.4 or later must be installed as this library is used to
717
    access the source repository. The source may be a network URL
718
    but using a local URL is recommended for performance reasons.
719
    """
720
    hidden = False
721
    _see_also = ['fast-import', 'fast-import-filter']
722
    takes_args = ['source', 'destination']
0.93.11 by Ian Clatworthy
initial cut at fast-export-from-svn
723
    takes_options = ['verbose',
724
                    Option('trunk-path', type=str, argname="STR",
725
                        help="Path in repo to /trunk.\n"
726
                              "May be `regex:/cvs/(trunk)/proj1/(.*)` in "
727
                              "which case the first group is used as the "
728
                              "branch name and the second group is used "
729
                              "to match files.",
730
                        ),
731
                    Option('branches-path', type=str, argname="STR",
732
                        help="Path in repo to /branches."
733
                        ),
734
                    Option('tags-path', type=str, argname="STR",
735
                        help="Path in repo to /tags."
736
                        ),
737
                    ]
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
738
    aliases = []
739
    encoding_type = 'exact'
0.93.11 by Ian Clatworthy
initial cut at fast-export-from-svn
740
    def run(self, source, destination, verbose=False, trunk_path=None,
741
        branches_path=None, tags_path=None):
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
742
        from bzrlib.plugins.fastimport.exporters import fast_export_from
0.93.11 by Ian Clatworthy
initial cut at fast-export-from-svn
743
        custom = []
744
        if trunk_path is not None:
745
            custom.extend(['--trunk-path', trunk_path])
746
        if branches_path is not None:
747
            custom.extend(['--branches-path', branches_path])
748
        if tags_path is not None:
749
            custom.extend(['--tags-path', tags_path])
750
        fast_export_from(source, destination, 'svn', verbose, custom)
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
751
752
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
753
register_command(cmd_fast_import)
0.77.1 by Ian Clatworthy
initial cut at fast-import-filter
754
register_command(cmd_fast_import_filter)
0.64.38 by Ian Clatworthy
clean-up doc ready for initial release
755
register_command(cmd_fast_import_info)
0.64.111 by Ian Clatworthy
rename fast-import-filter to fast-import-query
756
register_command(cmd_fast_import_query)
0.79.1 by Ian Clatworthy
turn bzr-fast-export into a fast-export command
757
register_command(cmd_fast_export)
0.64.205 by Ian Clatworthy
added fast-export-to-cvs
758
register_command(cmd_fast_export_from_cvs)
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
759
register_command(cmd_fast_export_from_darcs)
760
register_command(cmd_fast_export_from_hg)
761
register_command(cmd_fast_export_from_git)
0.64.204 by Ian Clatworthy
added fast-export-from-mnt command
762
register_command(cmd_fast_export_from_mnt)
0.94.1 by Matt McClure
Adds a fast-export-from-p4 command.
763
register_command(cmd_fast_export_from_p4)
0.93.1 by Ian Clatworthy
initial cut at a simplified ui to xxx-fast-export
764
register_command(cmd_fast_export_from_svn)