将Bazaar存储库迁移到Git:路径不在分支错误

huangapple go评论58阅读模式
英文:

Migrating a Bazaar repo to Git: path not in branch error

问题

我正在尝试将 Bazaar 存储库转换为 Git。

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

但我遇到了这个错误:

22:10:43 计算要包括的修订版本...
22:10:43 开始导出 2952 个修订版本...
22:10:43 每分钟以 448681 条记录的速度导出 1000/2952 个提交
...
22:10:43 每分钟以 239415 条记录的速度导出 1000/2952 个提交
致命错误:路径 onboard/copying 不在分支中
fast-import:将崩溃报告转储到 .git/fast_import_crash_3847
brz:管道中断

fast_import_crash_3847

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

英文:

I am trying to convert this Bazaar repo to Git.

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

But I get this error:

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

Tried bzr and Breezy, two different OS (Arch Linux and Ubuntu).

答案1

得分: 4

这是有关bzrfast-export功能中的一个错误。

在修订版本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

它遗漏了遍历重命名的目录并为其中的每个文件发出重命名的部分。

要解决这个问题,您需要查找存储库历史中的所有这种目录重命名,并相应地修复fast-input流。如果这样做,请注意fast-import格式还包含二进制数据,因此您可能无法使用文本编辑器进行此操作,因为这可能会损坏二进制文件。

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

即使没有收到错误消息,如果不进行修复,结果可能是错误的,因为然后重命名不会执行,如果文件在重命名后进行了编辑,则第一个提交实际上会在旧文件仍然存在的情况下创建它,依此类推。

所以最好的方法可能是报告错误,如果尚未完成,等待适当的修复,然后密切调查转换结果,以确保没有更多这样的问题,这些问题可能不会导致失败,而只是导致错误的结果。

该错误应该是这个:https://bugs.launchpad.net/brz/+bug/1890216,已经有可用的修复程序:https://code.launchpad.net/~cjwatson/brz/fastimport-fix-directory-renames/+merge/410767,已经有1.5年了,但似乎没有人关心集成它。

英文:

That is a bug in the fast-export functionality of bzr.

In revision 1 the directories python-virtkey-0.3/ and sok-0.23/ were added, among other things including the file sok-0.23/copying.
In revision 2 python-virtkey-0.3/ was renamed to python-virtkey/ and sok-0.23/ to onboard/ and thus sok-0.23/copying to onboard/copying.
In revision 56 then onboard/copying was renamed to COPYING.

The problem is, that fast-export emits only this for revision 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

It misses to iterate the renamed directory and emit renamings for each individual file in them.

To work-around the problem, you would need to find all such directory renames in the repo history and fix the fast-input stream accordingly. If you do so, be aware that the fast-import format also contains binary data, so you might not be able to do this with a text editor without breaking the binary files.

If you check with bzr log -v | grep '/ =>' you see that there were 14 directory renamings and you would need to manually fix all of them to work-around the issue.

Even if you do not get an error message, the result might be wrong without fixing it, as then the renamings are not done and if a file then would have been edited after the rename, the first commit actually creates it while the old file still remains present and so on.

So the best way is probably to report the bug if not already done and wait for a proper fix, and then closely investigate the conversion result to make sure there are not more such issues that maybe do not result in a failure but just in a wrong result.

The bug should be this one: https://bugs.launchpad.net/brz/+bug/1890216
with a fix already available at: https://code.launchpad.net/~cjwatson/brz/fastimport-fix-directory-renames/+merge/410767
since 1.5 years, but noone seems to bother integrating it.

答案2

得分: 1

不使用fast-export,您还可以使用Breezy对推送到Git的本机支持:

% bzr branch https://code.launchpad.net/onboard onboard-bzr
已分支 2295 个修订版本。
% git init onboard-git
在 /tmp/onboard-git/.git/ 中初始化了一个空的Git仓库。
% cd onboard-bzr
% bzr push --lossy ../onboard-git
从Bazaar推送到Git存储库。为了获得更好的性能,请推送到Bazaar存储库。
所有更改都成功应用。
推送到修订版本 2295。
更新了 15 个标签。
% cd ..
% diff -ur onboard-bzr onboard-git
只存在于onboard-bzr中: .bzr
只存在于onboard.git中: .git
英文:

Instead of fast-export, you can also use Breezy's native support for pushing to 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

答案3

得分: 0

I encountered this issue either when or after brz was exporting revisions:

$ 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

The workaround for me was to export to a file, create the git repo and import.

brz fast-export > brz-export
git init .
cat brz-export | git fast-import
英文:

I encountered this issue either when or after brz was exporting revisions:

$ 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

The workaround for me was to export to a file, create the git repo and import.

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

huangapple
  • 本文由 发表于 2023年4月7日 03:16:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75953013.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定