A common way to migrate version control data from one VCS to another is by using the fast-export / fast-import method—export the content of the source VCS by using fast-export, and import it into the target VCS using fast-import. The data format used by fast-export / fast-import is VCS-agnostic; in this way, it is possible to migrate from any VCS to any other, as long as they support this technique.
In this section, we explain how to export VCS data of other systems by using fast-export, and then how to import that using fast-import into Bazaar.
The plugin to import the version control data that was exported by using the fast-export method is named fastimport
, typically in a package named bzr-fastimport
. Confirm if it is already installed in your system by using bzr plugins
. If it is not in the list, see the Installing plugins section, and follow the steps to install it.
In addition to bzr-fastimport
, you also need to install the fastimport
Python package. Install it by using your operating system's package manager or pip
. A simple way to verify that both bzr-fastimport
and fastimport
are correctly installed is by running it with dummy source and destination parameters:
$ bzr fast-import x /tmp/x Creating destination repository ... Shared repository with trees (format: 2a) Location: shared repository: /tmp/x bzr: ERROR: [Errno 2] No such file or directory: u'x'
We get this far only if both the requirements are correctly installed.
The bzr-fastimport
plugin includes the utilities that you can use to export version control data from Subversion, Mercurial, and DARCS. These scripts are in the BZRLIB/plugins/fastimport/exporters
directory, where BZRLIB
is the path shown in the output of bzr version
. For example:
$ bzr version Bazaar (bzr) 2.5.0 Python interpreter: /usr/bin/python2.6 2.6.1 Python standard library: /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6 Platform: Darwin-10.8.0-i386-64bit bzrlib: /Library/Python/2.6/site-packages/bzrlib Bazaar configuration: /Users/janos/.bazaar Bazaar log file: /Users/janos/.bzr.log
In this case, the exporter scripts are in the directory /Library/Python/2.6/site-packages/bzrlib/plugins/fastimport/exporters
.
There exists exporters for other VCS too, such as Git, CVS, and Perforce that are not bundled with the plugin, but you can find them elsewhere. For a complete list and how to obtain these exporters, see the Bazaar wiki page:
http://wiki.bazaar.canonical.com/BzrFastImport/FrontEnds
Common in all exporters is that they dump version control data to standard output, which can be compressed and redirected to a file in order to import later into Bazaar.
A Subversion exporter script named svn-fast-export.py
is included with the bzr-fastimport
plugin. The script takes as parameter the filesystem path to a Subversion repository, and it exports version control data to standard output:
$ svn-fast-export.py /sandbox/svn-repo/ | gzip > /tmp/svn-repo.fi.gz
The script has several options to specify the trunk and branches; use the -h
or --help
flags for more details.
The Git exporter script is not included with the bzr-fastimport
plugin, as the functionality is part of Git 1.5.4 and later. You can export Git data by using the fast-export
command inside a Git working tree. For example:
$ (cd /sandbox/repo.git && git fast-export --all) | gzip > /tmp/repo.git.fi.gz
This example exports all the branches. For more options and details, use the -h
or --help
flags or refer to man git-fast-export
.
Bazaar has its own fast-import exporter too, the bzr fast-export
command, should you want to migrate from Bazaar to another system. The command works at the branch level, so if you want to export multiple branches, you have to run the command for each branch.
Let's create an example shared repository and fetch some sample branches to export:
$ bzr init-repo /sandbox/exporting --no-trees $ cd /sandbox/exporting $ bzr branch lp:~bzrbook/bzrbook-examples/exporting-trunk trunk $ bzr branch lp:~bzrbook/bzrbook-examples/exporting-anna anna
Let's export specific branches:
$ bzr fast-export -b master trunk /tmp/master.fi.gz 09:29:50 Calculating the revisions to include ... 09:29:50 Starting export of 4 revisions ... 09:29:50 Exported 4 revisions in 0:00:00 $ bzr fast-export -b anna anna /tmp/anna.fi.gz 09:36:18 Calculating the revisions to include ... 09:36:18 Starting export of 6 revisions ... 09:36:18 Exported 6 revisions in 0:00:00
In both the example branches, the -b
flag is used to specify the name of the branch, which will be used by fast-import
. The first parameter to fast-export
is the path to the branch to export, and the second is the path to the export file.
If the export filename ends with .gz
, Bazaar compresses the output. If the export filename is omitted or is -
, then Bazaar will write to the standard output instead of a file. This can be used to pipe to a foreign repository directly without intermediary export files.
If you would like to export VCS data from another system, see the following documentation pages. New exporters are added from time to time, especially for well-known and widely-used systems:
http://doc.bazaar.canonical.com/plugins/en/fastimport-plugin.html
Use bzr fast-import
to import fast-export files. For example:
$ bzr fast-import /tmp/repo.git.fi /sandbox/imported Creating destination repository ... Shared repository with trees (format: 2a) Location: shared repository: imported 10:02:07 Starting import of 8 commits ... 10:02:07 Updating branch information ... branch trunk now has 2 revisions and 0 tags branch anna now has 4 revisions and 0 tags branch jack now has 4 revisions and 0 tags 10:02:07 Updating the working tree for /sandbox/imported/trunk ... All changes applied successfully. 10:02:07 Imported 8 revisions, updating 3 branches and 1 tree in 0:00:00 To refresh the working tree for other branches, use 'bzr update' inside that branch.
This command creates a shared repository in the specified destination directory, and populates it with the imported branches. If a destination directory is not specified, Bazaar will try to create one in the current directory. If the current directory is already a shared repository, it will be re-used.
If a "trunk" branch can be identified, the command will populate the working directory for it. Other branches will have their working tree "out of date" with no files. As the hint in the output of bzr fast-import
says, use bzr update
to update the working trees you need. For example:
$ cd /sandbox/imported/anna/ $ bzr status working tree is out of date, run 'bzr update' $ bzr up +N README.md +N hello.pl +N hello.py +N hello.r +N hello.sh All changes applied successfully. Updated to revision 4 of branch /sandbox/imported/anna
The command is safe to re-run for the same fast-export file or after the export file is updated from the same source repository. Only the new revisions and branches will be imported; any locally deleted branches will be recreated.
The import process is safe to interrupt. In case of an interruption, simply re-run the command and the process will continue where it left off.
In general, fast-import files are plain text and more or less readable. You can use bzr fast-import-info
to get an informative summary of what is included in a fast-import file. This command works with plain and gzipped
fast export files.
The bzr fast-import-filter
command can be very useful to include or exclude specified files and directories. This can be useful, for example, to create a new repository from a subset of the files, or to remove sensitive data such as passwords that should not have been added to version control. Another common use of this command is to re-map user IDs. For more details, see bzr fast-import-filter --help
.
52.15.65.65