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