Converting an SVN Repository to Bazaar

James Henstridge james at jamesh.id.au
Thu Jan 22 03:41:52 GMT 2009


On Wed, Jan 21, 2009 at 8:10 PM, A. S. Budden <abudden at gmail.com> wrote:
> Dear all,
>
> I have been trying to convert my subversion repository to a bazaar
> repository, but I have been having some problems so was hoping that
> someone on this list might be able to help.
>
> My (personal) subversion repository (which was originally a CVS
> repository) used to be organised with the root containing trunk/ tags/
> and branches/, but I (relatively) recently (and rather dramatically)
> reorganised it such that it has a number of directories and
> subdirectories with categories and then some project folders within
> those categories.  In two cases, those folders then contain trunk/,
> tags/ and branches/, but in most cases they do not (as I've not
> required them).  A short subset of the project folders is shown at the
> bottom of the email.
>
> I have tried a few approaches to converting the repository, but had no
> success.  My first attempt was to use svn2bzr [1] on the whole
> repository: this produced a matching layout, but the only way I could
> get anything out of the bazaar repository was to check out the entire
> 1.5 GB repository!  After some googling, I found "An Academic Gets
> Bazaar" [2], which sounded really promising.  So I downloaded
> svndumpfilter4 [3] and tried the suggested command line listed on the
> website:
>
> svndumpfilter4 --untangle=./subversion applications/vim/vimfiles/ <
> svn-1917.dump > svn-1917-vimfiles.dump
>
> However, the "untangle" option wasn't recognised (unsurprisingly I
> guess as it isn't in the optparse code at the bottom of the script!).
> Therefore, I removed this option and tried again.  After a fairly long
> wait, I ended up with a new dump file, so I entered the next two
> suggested commands:
>
> svnadmin create repo-vimfiles
> svnadmin load --ignore-uuid repo-vimfiles < svn-1917-vimfiles.dump
>
> As far as I can tell, this created a new repository that was identical
> to the original one, implying that svndumpfilter4 had simply copied my
> dump file!
>
> After this, I went back to svn2bzr for another look and decided to try
> the "--prefix" option.  This looked very promising, but it seems to
> copy only those changes that occurred after the last reorganisation of
> my repository (presumably because the prefix filter was ignoring
> changes on the old directory structure).  Therefore, on very new
> projects, it worked fine; on really old projects it resulted in an
> empty repository and on projects that had been created prior to the
> reorganisation and changed after it, svn2bzr crashed (as it was trying
> to change a file that it hadn't created).
>
> I am now feeling somewhat out of ideas so was wondering whether anyone
> could offer any suggestions as to how I might be able to proceed
> without starting from scratch and losing all of the history...
>
> Many thanks in advance for any help that you can offer.

You might be best off editing the svn2bzr source code and defining a
new DynamicBranchCreator subclass that describes your branch scheme.
You will want to override the _want_brt(path) method to return True
for any path that should be converted to a branch and False for
anything above those directories.

The TrunkBranchCreator and ProjectBranchCreator might be worth looking
at for reference, but you'll need something a bit more complex to both
recognise your old branch paths and new branch paths.  Provided that
you've only copied from old paths that were considered to be branches
to new paths that are considered branches, things should just work.
If you've essentially split modules, things might not work as well.

You'll then need to edit main() to provide a way to select your new
BranchCreator and then run with --scheme=whatever.

James.



More information about the bazaar mailing list