Sanitizing a branch (I got a result)
Erik de Castro Lopo
erikd+bzr at mega-nerd.com
Sun Mar 22 20:27:22 GMT 2009
Erik de Castro Lopo wrote:
> When I come up with something I'm happy with I'll report back.
Well here I am.
After reading way more documentation than I really like to and a few
false starts I followed the route sugggested by Stephen J. Turnbull:
> So export a fastimport database, import to git, do the history etc
> munging in git using filter-branch, then import back to bzr.
I expected to have to do this a couple of times to get it right, but
at the end of my first trial run I was happy enough with the result
that I decided to keep it.
I was using the standard bzr that comes with Ubuntu Intrepid (1.6.1)
with the fast-import plugin from launchpad. I did the fast-export part
to a file, mainly so I could have a look at what the file contained :-).
This process was completely painless.
Importing into Git was also painless (and fast) but resulted in a
directory that was empty except for a .git directory. A visit to the
Git IRC channel and I ran "git reset --hard HEAD" to populate the
I then 6 passes removing cruft files using:
git filter-branch --tree-filter 'rm -f file1 file2' HEAD
The "-f" in the rm is important so that it doesn't fail in earlier
revisions where the files may not exist. Each of these passes through
my tree took about 10 minutes.
Once I was happy with the final result "bzr fast-import" gave me my
new sanitized tree (after making me wait for over an hour :-) ).
I now intend to use bzr-loom to add my cruft back into the tree in
a more controlled manner. I will then manually rebase a couple of
related hacking branches on top of the new branch.
I must say I am very impressed with how well Bzr and Git interacted
here. I was also impressed with the speed of Git.
More information about the bazaar