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