Using fast-import from git into bk



I was trying to move data between git and bitkeeper, in this case exporting from git. Apparently with the repo I was using I wasn’t able to do this for at least two interoperability reasons (maybe more, but that’s as far as my testing got).

In the first case, I was doing:

% git fast-export --progress=100 -M -C --all \
    | (cd ../bk/$repo && bk fast-import)

but it died with:

fast-import: line 'R ports/winnt/libntp/nt_clockstuff.c ports/winnt/ntpd/nt_clockstuff.c' not supported

so I figured that bk didn’t support the -M option. I took that out, and retried, but it died with:

fast-import: Unknown command: tag ntp-stable
fast-import: no csets to import on stdin

Unfortunately I foresee needing to move repo contents back and forth between the two formats, without any loss of metadata (including moving files around between directories, etc). Both bk and git have “mv” commands… so why doesn’t fast-import grok this?

I’m using:

fast-import: Unknown command: tag ntp-stable
fast-import: no csets to import on stdin




git’s mv isn’t like bk’s mv. Git doesn’t record the mv as an event, git’s meta data does not include a file object (it’s one of the most frustrating things about git).

So doing incremental exports from bk to git works fine because bk records mv (and create and delete) events. BK has a graph per file, you can do bk revtool foo.c and you are looking at the graph for foo.c; “bk revtool” looks at the repostory’s graph, that’s the only graph git has.

So going from git to bk we don’t get the information we need. You think we do but that’s not the case. The rename info that git gives us is a guess, that’s why there is that 0-100% next to it, that’s showing you how much of the two versions of the file were identical. So that info is unreliable, it’s just a guess.

So you should be able to do a single branch fast export, in fact I just tested it on that fixed repo of yours with this:

bk fast-export | (/bin/rm -rf ../ntp.git; git init ../ntp.git; cd ../ntp.git && git fast-import)
cd ..
git -C *git fast-export master | bk fast-import ntp.import

and that worked.

But you need to realize that while you can correctly do incremental exports from bk to git, there is no way to do that the other direction, git -> bk. Each time you do the git -> bk conversion you will get a tree that is incompatible with the previous trees.