Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrate bazaar to git with commit-properties to link bugs fixed

We were using bazaar-vcs for some years but decided to migrate to git because of some long standing annoying bugs and stopped development of bzr.

While using bazaar, we extensively used the "bug tracker metadata" feature of bazaar (http://doc.bazaar.canonical.com/bzr.dev/en/user-reference/bugs-help.html). So every bug-fix commit included the ID to the corresponding mantis-bug-Id so that we have the link between source and mantis.

Our commit-message does not include the mantis-id, we only used the "metadata-feature":

enter image description here

It is very important for us that we don`t loose these informations so I need a solution for migrating this bug-links in some form.

I already tried to export/import our bazaar repository into git using the fast-import/fast-export commands:

bzr fast-export --no-plain --rewrite-tag-names /var/www/source_branch/ | git fast-import

Unfortunately I get the following error:

fatal: This version of fast-import does not support feature commit-properties.

However, if I use the option --plain instead of --no-plain the import works, but we lose all connections to our bugs.

Is there some solution/workaround for migrating from bzr to git without loosing all these bug-links which are so important for us?

[Edit]: I just analysed the fast-import/fast-export file-format which is very simple. It should be possible to write some script to modify the file and move the (property bugs...) lines into the corresponding commit message line. However, if there is an out-of-the box solution I would be happy to hear it :)

like image 887
David Roth Avatar asked Oct 22 '22 19:10

David Roth


2 Answers

Git Fast-import does not support metadata properties so there was no way of migrating these infos solely with the existing tools.

Since there was no response and losing all these bug-ids was no option for us, I wrote a fast-export stream-rewriter which is capable of rewriting the stream in a format that git understands but with all our bug id infos included.

The C# rewriter works by executing the following steps:

  1. Parse commits from input stream
  2. Check if a commit contains a property bugs command
  3. Parse the bug id and modify the commit-message with the extracted bug id
  4. Exclude other unsupported bzr-fastexport only commands ("feature", "property branch nick"))

More infos about this rewriter + the code can be found here: http://www.fusonic.net/en/blog/2013/03/26/migrating-from-bazaar-to-git/

like image 107
David Roth Avatar answered Nov 02 '22 12:11

David Roth


I had a similar need. I tried David's rewriter, but it produced output that git import would fail on. I suspect it was a subtle bug in renaming of some files in a commit.

I realized it might be easier to just modify 'bzr fast-export --plain' to just do what I wanted.

I filed the upstream (bzr fast-export) bug at LP: #1606973 and attached a solution that worked for me. After modifying fastimport/exporter.py, I just did:

bzr fast-export --git-branch=master --plain | git fast-import
like image 30
Scott Moser Avatar answered Nov 02 '22 11:11

Scott Moser