尝试了解 BZR 存储库
我使用 Bazaar,而且很喜欢它。一般来说,我只是创建不同的分支并分别管理它们。我刚刚发现所有这些分支都可以放入存储库中。如果我理解正确,这应该节省内存并提高速度,因为分支之间的一些共同祖先是共享的。 Q1:我这样理解对吗?
另一件事是,当我尝试使用它时,我发现了一些我真的不明白的问题。这是我的尝试。
bzr init-repo --trees TestBzrRepo
cd TestBzrRepo
bzr init trunk
mkdir branches
cd branches
bzr branch ../trunk b01-Add-file2-f
echo 'This is file 2' > file2.f
bzr add file2.f
bzr commit -m "Add file 2"
cd ../../trunk
echo 'This is file 1' > file1.f
bzr add file1.f
bzr commit -m "Add file 1"
cd ../branches/b01-Add-file2-f
从现在开始,如果我执行 bzr pull ../../trunk
,我得到:
bzr: ERROR: These branches have diverged. Use the missing command to see how.
Use the merge command to reconcile them.
如果我执行 bzr merge ../../trunk
,我得到:
bzr: ERROR: Branches have no common ancestor, and no merge base revision was specified.
bzr冲突
什么也不返回,我仍然无法拉取或合并。
这里发生了什么?以及接下来我应该做什么。 请帮忙。
先感谢您。
I use Bazaar and I love it. Generally, I just create different branches and manage them separately. I've just found that all those branches can be put into a repository. If I understand correctly, this should save memory and increase speed as some common ancestor between branches are shared. Q1: Do I understand this right?
Another thing is that when I try to use it I found some problem which I really do not get it. Here is how I attempt.
bzr init-repo --trees TestBzrRepo
cd TestBzrRepo
bzr init trunk
mkdir branches
cd branches
bzr branch ../trunk b01-Add-file2-f
echo 'This is file 2' > file2.f
bzr add file2.f
bzr commit -m "Add file 2"
cd ../../trunk
echo 'This is file 1' > file1.f
bzr add file1.f
bzr commit -m "Add file 1"
cd ../branches/b01-Add-file2-f
From now if I do bzr pull ../../trunk
, I got:
bzr: ERROR: These branches have diverged. Use the missing command to see how.
Use the merge command to reconcile them.
If I do bzr merge ../../trunk
, I got:
bzr: ERROR: Branches have no common ancestor, and no merge base revision was specified.
bzr conflicts
returns nothing and I still cannot pull or merge.
What happen here? and What should I do next.
Please help.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为合并错误的原因是您在创建第二个分支之前没有创建修订。
bzr qlog TestBzrRepo
可能有助于理解这种情况。尝试
bzr merge ../../trunk -r 0..-1
。I think the reason for the merge error is that you didn't create a revision before creating your second branch.
bzr qlog TestBzrRepo
might help to make sense of the situation.Try
bzr merge ../../trunk -r 0..-1
.bzr init-repo
创建一个所谓的共享存储库。在共享存储库中,所有修订都存储在存储库的.bzr
目录中,并且分支本身的.bzr
目录仅存储分支元信息,而不存储分支元信息。自己修改。这样分支目录变得非常轻量级,并且分支的公共修订不会重复。假设我们创建了一个共享存储库以及其中的分支,如下所示:
那么布局的目录将像这样运行:
如果您没有使用共享存储库,情况会非常不同,例如:
在这种情况下(没有共享存储库) )布局的目录将像这样运行:
在这种情况下,修订将在所有 3 个分支中重复。
如果当前分支是其他分支后面的某些修订版本,则
bzr pull
非常有用,以便可以以直接的方式附加缺少的修订版本。如果当前分支有一些修订而其他分支没有,则拉取会失败,如您的示例所示。这是完全正常的,这种情况下的解决方案是使用bzr merge
进行正常合并。bzr merge
在您的示例中失败,因为两个分支(主干和另一个分支)没有共同的修订。这是因为当您从主干分支时,它完全是空的,没有对其进行任何修改。这两个分支是完全独立的,绝对没有共同的修改。仍然可以将不相关的分支组合起来,正如 @bialix 在评论中所解释的那样
bzr merge ../../trunk -r0..-1
但我不认为这是你的意图。从没有修订的主干分支是毫无意义的,在实际用例中,您将从至少有 1 个修订的分支分支,在这种情况下,您不会收到此类错误,并且合并将按预期进行。bzr init-repo
creates a so-called shared repository. In a shared repository, all revisions are stored inside the.bzr
directory of the repository, and the.bzr
directories of the branches themselves store only branch meta information, not the the revisions themselves. This way the branch directories become very light-weight, and the common revisions of branches are not duplicated.Let's say we created a shared repository and branches inside it like this:
Then the directories of the layout will function like this:
If you were not using a shared repository the situation would be very different, for example:
In this case (no shared repo) the directories of the layout will function like this:
In this case the revisions will be duplicated in all 3 branches.
bzr pull
is useful if the current branch is some revisions behind the other branch, so that the missing revisions can be appended in a straightforward way. If the current branch has some revisions that the other doesn't, then the pull fails as in your example. This is perfectly normal, and the solution in such situation is to do a normal merge withbzr merge
.bzr merge
fails in your example because the two branches (trunk and the other branch) have no common revisions. This is because at the time you branched from trunk, it was completely empty, no revisions were committed to it. The two branches are completely independent, have absolutely no common revisions.It is still possible to combine unrelated branches as @bialix explained in a comment with
bzr merge ../../trunk -r0..-1
but I don't think this was your intention. It is pointless to branch from a trunk that has no revisions, in a realistic use case you would branch from a branch that has at least 1 revisions, in which case you will not get such error and the merge will work as expected.是的,存储库允许分支共享共同历史记录的存储。如果您有许多具有相关历史记录的分支机构,这可能会节省一大笔钱。
Yes, repositories allow branches to share storage for common history. If you have many branches with related history, this can be a big saving.