107
105
class cmd_fast_import(Command):
108
106
"""Backend for fast Bazaar data importers.
110
This command reads a mixed command/data stream and
111
creates branches in the current repository accordingly.
112
The usual recipe is::
114
bzr fast-import project.fi
108
This command reads a mixed command/data stream and creates
109
branches in a Bazaar repository accordingly. The preferred
112
bzr fast-import project.fi project.bzr
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.
116
117
To specify standard input as the input stream, use a
117
source name of '-' (instead of project.fi). Numerous commands
118
are provided for generating a fast-import stream to use as input.
119
These include fast-export-from-svn, fast-export-from-git,
120
fast-export-from-hg and fast-export-from-darcs.
122
If you wish to write a custom exporter for your project, see
123
http://bazaar-vcs.org/BzrFastImport for the detailed protocol
124
specification. In many cases, exporters can be written quite
125
quickly using whatever scripting/programming language you like.
127
If run inside a branch using a shared repository, then
128
the current branch is made the trunk and other branches,
129
if any, are created in sister directories. If run inside
130
a standalone tree, the current branch is also made the
131
trunk, but warnings are output about other branches found.
133
Git reference names are mapped to bzr branch names as follows:
118
source name of '-' (instead of project.fi).
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.
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
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.
138
:Branch mapping rules:
140
Git reference names are mapped to Bazaar branch names as follows:
135
* refs/heads/foo is mapped to foo
136
* refs/remotes/origin/foo is mapped to foo.remote
137
* refs/tags/foo is mapped to foo.tag
138
* */master is mapped to trunk, trunk.remote, etc.
139
* */trunk is mapped to git-trunk, git-trunk.remote, etc.
142
At checkpoints and on completion, the commit-id -> revision-id
143
map is saved to a file called 'fastimport-id-map' in the control
144
directory for the repository (e.g. .bzr/repository). If the import
145
is interrupted or unexpectedly crashes, it can be started again
146
and this file will be used to skip over already loaded revisions.
147
As long as subsequent exports from the original source begin
148
with exactly the same revisions, you can use this feature to
149
maintain a mirror of a repository managed by a foreign tool.
150
If and when Bazaar is used to manage the repository, this file
151
can be safely deleted.
153
Note: A slightly more complex recipe is required when importing large
154
projects via exporters that reuse blob data across commits, namely::
158
bzr fast-import-info -v xxx.fi > xxx.cfg
159
bzr fast-import xxx.fi --info xxx.cfg
161
In this scenario, the xxx.cfg file generated by the first pass
162
holds caching hints that the second pass uses to lower memory
163
usage. Development is planned so that this recipe becomes obsolete
164
in the future, i.e. so that the simple recipe always works.
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.
148
:Branch creation rules:
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
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.
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.
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.
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.
174
:Reducing memory usage:
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.
182
bzr fast-import-info -v xxx.fi > xxx.cfg
183
bzr fast-import xxx.fi --info xxx.cfg xxx.bzr
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.
190
:Restarting an import:
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.