It’s just data

DVCS Interoperability

Michael Greenly: Lucky for me it’s easy migrate from bzr to git using svn as an intermediary.

Based on the comment by Pietro, I should be able to do this directly now.

First, fetch a known bzr repository.

$ bzr get http://intertwingly.net/code/venus bzr-venus
Branched 118 revision(s).

Then initialize a git repository.

$ mkdir git-venus
$ cd git-venus
$ git init
Initialized empty Git repository in /home/rubys/tmp/git-venus/.git/
$ cd ..

Now attempt the push.

$ cd bzr-venus
$ bzr dpush ../git-venus
bzr: ERROR: exceptions.AssertionError: type was None                           

*** Bazaar has encountered an internal error.  This probably indicates a
    bug in Bazaar.  You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    attaching the crash file
        /home/rubys/.cache/crash/bzr-20100513190316-5624.crash
    and including a description of the problem.

    The crash file is plain text and you can inspect or edit it to remove
    private information.

Try Michael’s approach, using svn as an intermediary:

$ svnadmin create --fs-type fsfs svn-venus
$ cd bzr-venus
$ bzr push ../svn-venus
Initialising Subversion metadata cache in /home/rubys/.cache/bazaar/svn/0217a4d8-8507-45f3-96a1-39a8aa88a6d6.
bzr: ERROR: These branches have diverged.  See "bzr help diverged-branches" for more information.

Relevant version information:

$ bzr --version
Bazaar (bzr) 2.1.1
  Python interpreter: /usr/bin/python 2.6.5
  Python standard library: /usr/lib/python2.6
  Platform: Linux-2.6.32-22-generic-x86_64-with-Ubuntu-10.04-lucid
  bzrlib: /usr/lib/python2.6/dist-packages/bzrlib
  Bazaar configuration: /home/rubys/.bazaar
  Bazaar log file: /home/rubys/.bzr.log

Copyright 2005-2010 Canonical Ltd.
http://bazaar-vcs.org/

bzr comes with ABSOLUTELY NO WARRANTY.  bzr is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 2 or later.

Bazaar is part of the GNU Project to produce a free operating system.

$ git --version
git version 1.7.0.4

$ svn --version 
svn, version 1.6.6 (r40053)
   compiled Dec 12 2009, 05:06:12

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme

Reported as bug 580146.


Why not use a tool made specifically to convert repositories from one format to another, such as Tailor? Or use fast-export/fast-import which — I believe — bzr and git bot support? FWIW while git-bzr didn’t live up to its promises of bidirectionallity, it did convert several bzr repos flawlessly to git ones.

The third (and a bit more gore, though much less than using SVN as an intermediate) option I’d consider (if those above failed) would be using hg-convert for bzr->hg and hg-git for hg->git (a reverse of the initial role of the extension, but I’ve seen people use it to have git as an hg client so...)

Posted by Masklinn at

We have a winner:

mkdir -p ~/.bazaar/plugins
cd ~/.bazaar/plugins
bzr branch lp:bzr-fastimport fastimport

cd ~/git
mkdir venus
cd venus
git init
bzr fast-export ~/bzr/venus | git fast-import

Elapsed time on the last command: 10.878s

Posted by Sam Ruby at

By the way here is the result of testing it out using git-bzr:

$ bzr get http://intertwingly.net/code/venus bzr-venus
Branched 118 revision(s).
 $ git init git-venus
Initialized empty Git repository in /Users/masklinn/projects/tests/git-venus/.git/
 $ cd git-venus/
 $ git bzr add bzr ../bzr-venus/
Bazaar branch bzr added.
You can fetch it with 'git bzr fetch bzr'.
 $ time git bzr fetch bzr
There doesn't seem to be an existing refmap. 
Doing an initial import of  into bzr/master
22:45:34 Calculating the revisions to include ...
22:45:34 Starting export of 365 revisions ...
22:45:45 Exported 365 revisions in 0:00:11
git-fast-import statistics:
---------------------------------------------------------------------
Alloc'd objects:       5000
Total objects:         2897 (       691 duplicates                  )
      blobs  :         1249 (       509 duplicates        647 deltas)
      trees  :         1283 (       182 duplicates       1099 deltas)
      commits:          365 (         0 duplicates          0 deltas)
      tags   :            0 (         0 duplicates          0 deltas)
Total branches:           1 (         1 loads     )
      marks:           1024 (       365 unique    )
      atoms:            364
Memory total:          2344 KiB
       pools:          2110 KiB
     objects:           234 KiB
---------------------------------------------------------------------
pack_report: getpagesize()            =       4096
pack_report: core.packedGitWindowSize = 1073741824
pack_report: core.packedGitLimit      = 8589934592
pack_report: pack_used_ctr            =       5088
pack_report: pack_mmap_calls          =        916
pack_report: pack_open_windows        =          1 /          1
pack_report: pack_mapped              =    3575631 /    3575631
---------------------------------------------------------------------


real	0m11.598s
user	0m11.917s
sys	0m0.610s

For what it may be worth, resulting git repo is 3.6MB (4.4 for bzr source), git gc gets it down to 928KB, and gitx seems to have no issue with browsing it.

Posted by masklinn at

Oh shoot, you managed to try it out before I could get done with my followup.

Posted by Masklinn at

venus@github

Posted by Sam Ruby at

And... fixed.

Posted by Sam Ruby at

Add your comment