Importing from mercurial (some quirks and working recipe)

John Arbash Meinel john at arbash-meinel.com
Wed Jan 30 19:27:51 GMT 2008


Marcin Kasperski wrote:
> Hello, everybody.
> 
> I am currently using Mercurial, but decided to take a look at bazaar.
> My first idea was of course to convert some of my existing mercurial
> repos and play a bit with that. I faced some problems, so here is the
> working recipe
> 
> a) Install bzr 1.1.0, bzr 0.9 won't work. In my case it meant grabbing
> launchpad ubuntu packages and using them in favor of standard ubuntu bzr.
> 
> b) Grab hg-import plugin
> 
>  mkdir ~/.bazaar/plugins
>  bzr branch https://code.launchpad.net/~luks/+junk/bzr-hgimport
>  mv bzr-hgimport hgimport
>  # crucial, directory name can't contain -
> 
> c) Create new bazaar repo
> 
>  bzr init newdirectory
>  cd newdirectory
> 
> d) Import
> 
>  bzr hg-import /path/to/mercurial/dir
> 
> (nice progressbar follows)
> 
> That's all, it works.
> 
> 
> Now about some quirks
> 
> 1) After the above, I commited some changes to the mercurial repo and
> tried to re-issue bzr hg-import. Some new change was grabbed, but is
> clearly incomplete (only one file was changed, the rest changes wasn't
> taken). So it seems hg-import does not handle incremental updates
> (well, it did not promise IIRC, but it could warn about it)
> 
> 2) When I tried issuing bzr hg-import in directory init-ed with bzr 0.9
> (created before I updated to 1.1.0), it worked for a long time to finally
> crash with incredibly cryptic error message:
> 
> bzr: ERROR: Tags not supported by BzrBranch5('file:///home/marcink/tmp/TESTST/szachy_partie_moje.bzr/'); you may be able to use bzr upgrade --dirstate-tags.
> 
> It was just a bit of luck that I guessed that above means "You must
> use newer repository format" ;-)

You probably could have just done:

bzr init --dirstate-tags newdirectory

The format was available back in 0.9, it just turns out that 1.1 has it 
on by default.

I'm not sure why hg-import would completely fail if it couldn't copy the 
tags across. It could probably handle it in a variety of ways (one is to 
just improve the error, another is to just not convert the tags and give 
a warning.)

> 
> 3) I also tried bzr-hg (alternative plugin). This one seems to provide direct
> bzr branch /path/to/mercurial/repo command, but ... crashes with (the crash is the same whether I use bzr 0.9, or 1.1.0):

I don't think 'bzr branch /path/to/mercurial/repo ...' is what you want, 
because Bazaar should be defaulting to preserving the source format. 
Meaning that "bzr branch /path/to/hg" should be trying to create a local 
"hg" repository. You still want to do "bzr init local; cd local; bzr 
pull /path/to/hg". (Because then you already have a branch in a given 
format, so it will convert the source into that format on the fly.)

That said, I'm not sure of the current state of bzr-hg, it was 
originally written just to see if it could be done, so it may need more 
attention to keep it compatible.

John
=:->



More information about the bazaar mailing list