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