迁移Bazaar到Git:路径不在分支错误



我正在尝试将这个Bazaar repo转换为Git。

bzr branch lp:onboard
cd onboard
git init
bzr fast-export --plain . | git fast-import

但是我得到这个错误:

22:10:43 Calculating the revisions to include ...
22:10:43 Starting export of 2952 revisions ...
22:10:43 1000/2952 commits exported at 448681/minute 
...
22:10:43 1000/2952 commits exported at 239415/minute 
fatal: Path onboard/copying not in branch
fast-import: dumping crash report to .git/fast_import_crash_3847
brz: broken pipe

fast_import_crash_3847

尝试bzrBreezy,两个不同的操作系统(Arch Linux和Ubuntu)。

这是bzrfast-export功能的一个bug。


在修订1中,目录python-virtkey-0.3/sok-0.23/被添加,其中包括文件sok-0.23/copying.
在修订2中,python-virtkey-0.3/被重命名为python-virtkey/,sok-0.23/被重命名为onboard/,sok-0.23/copying被重命名为onboard/copying.
在修订56中,onboard/copying被重命名为COPYING

问题是,fast-export只在版本2中发出这个:

commit refs/heads/master
mark :2
committer Henrik Nilsen Omma <henrik@ubuntu.com> 1155815101 +0100
data 18
rename and cleanup
from :1
D python-virtkey_0.3.dsc
D python-virtkey_0.3_i386.changes
D sok_0.23.dsc
D sok_0.23_i386.changes

它错过了迭代重命名的目录,并为其中的每个单独的文件发出重命名。

要解决这个问题,您需要在repo历史中找到所有这样的目录重命名,并相应地修复快速输入流。如果您这样做,请注意快速导入格式也包含二进制数据,因此您可能无法在不破坏二进制文件的情况下使用文本编辑器执行此操作。

如果你检查bzr log -v | grep '/ =>',你会看到有14个目录重命名,你需要手动修复所有它们来解决这个问题。

即使你没有得到错误消息,结果也可能是错误的,而没有修复它,因为重命名没有完成,如果一个文件在重命名后被编辑,第一次提交实际上创建了它,而旧文件仍然存在,等等。

因此,最好的方法可能是报告错误,如果还没有完成,等待适当的修复,然后仔细调查转换结果,以确保没有更多这样的问题,可能不会导致失败,但只是错误的结果。

这个bug应该是这个:https://bugs.launchpad.net/brz/+bug/1890216
,修复已经在:https://code.launchpad.net/~cjwatson/brz/fastimport-fix-directory-renames/+merge/410767
1.5年了,但是似乎没有人愿意集成它。

除了快速导出,您还可以使用Breezy的本机支持来推送到Git:

% bzr branch https://code.launchpad.net/onboard onboard-bzr
Branched 2295 revisions.
% git init onboard-git
Initialized empty Git repository in /tmp/onboard-git/.git/
% cd onboard-bzr
% bzr push --lossy ../onboard-git
Pushing from a Bazaar to a Git repository. For better performance, push into a Bazaar repository.
All changes applied successfully.
Pushed up to revision 2295.
15 tags updated.
% cd ..
% diff -ur onboard-bzr onboard-git
Only in onboard-bzr: .bzr
Only in onboard.git: .git

我在brz导出修订时或之后遇到了这个问题:

$ brz fast-export | git fast-import                                                                             fatal: not a git repository (or any of the parent directories): .git
15:27:48 Calculating the revisions to include ...
15:27:48 Starting export of 237 revisions ...
brz: broken pipe

我的解决方法是导出到一个文件,创建git repo并导入。

brz fast-export > brz-export
git init .
cat brz-export | git fast-import

最新更新