试图了解BZR存储库

Naw*_*Man 4 bazaar

我使用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
Run Code Online (Sandbox Code Playgroud)

从现在开始,如果我这样做bzr pull ../../trunk,我得到:

bzr: ERROR: These branches have diverged. Use the missing command to see how.
Use the merge command to reconcile them.
Run Code Online (Sandbox Code Playgroud)

如果我这样做bzr merge ../../trunk,我得到:

bzr: ERROR: Branches have no common ancestor, and no merge base revision was specified.
Run Code Online (Sandbox Code Playgroud)

bzr conflicts 什么都不返回,我仍然无法拉动或合并.

这里发生了什么?接下来我该怎么办 请帮忙.

先感谢您.

Ada*_*ser 6

我认为合并错误的原因是您在创建第二个分支之前没有创建修订. bzr qlog TestBzrRepo可能有助于理解这种情况.

试试bzr merge ../../trunk -r 0..-1.


Sto*_*ica 6

bzr init-repo创建一个所谓的共享存储库.在共享存储库中,所有修订都存储在.bzr存储库的.bzr目录中,并且分支的目录本身仅存储分支元信息,而不存储修订本身.这样,分支目录变得非常轻量级,并且分支的共同修订不会重复.

假设我们在其中创建了一个共享存储库和分支,如下所示:

bzr init-repo the-project     # create shared repo
bzr init the-project/trunk    # create a branch inside shared repo
cd the-project/trunk          # cd to branch dir
cp -r /path/to/files/* .      # copy the project's files into the branch
bzr add                       # tell bazaar to add everything to version control
bzr commit -m 'added files'   # commit the changes (add files)
bzr branch . ../branch1       # create another branch from the current one
bzr branch . ../branch2       # create another branch from the current one
Run Code Online (Sandbox Code Playgroud)

然后布局的目录将如下所示:

the-project/.bzr          -- only revisions are stored here, no branch info
the-project/trunk/.bzr    -- only branch info is stored here, no revisions
the-project/branch1/.bzr  -- only branch info is stored here, no revisions
the-project/branch2/.bzr  -- only branch info is stored here, no revisions
Run Code Online (Sandbox Code Playgroud)

如果您没有使用共享存储库,情况会有很大不同,例如:

bzr init trunk                # create a repo
cd trunk                      # cd to repo dir
cp -r /path/to/files/* .      # copy the project's files into the repo
bzr add                       # tell bazaar to add everything to version control
bzr commit -m 'added files'   # commit the changes (add files)
bzr branch . ../branch1       # create another repo from the current one
bzr branch . ../branch2       # create another repo from the current one
Run Code Online (Sandbox Code Playgroud)

在这种情况下(没有共享仓库),布局的目录将如下所示:

trunk/.bzr    -- revisions + branch info are stored here
branch1/.bzr  -- revisions + branch info are stored here
branch2/.bzr  -- revisions + branch info are stored here
Run Code Online (Sandbox Code Playgroud)

在这种情况下,修订将在所有3个分支中重复.

bzr pull如果当前分支是另一个分支后面的一些修订版,那么它很有用,因此可以以简单的方式附加缺少的修订版.如果当前分支有一些另一个没有的修订,则拉动失败,如示例所示.这是完全正常的,在这种情况下的解决方案是与...进行正常合并bzr merge.

bzr merge在您的示例中失败,因为两个分支(主干和另一个分支)没有共同的修订.这是因为当你从trunk分支时,它完全是空的,没有对它进行修改.这两个分支是完全独立的,绝对没有共同的修改.

仍然可以将不相关的分支组合为@bialix在评论中解释,bzr merge ../../trunk -r0..-1但我不认为这是你的意图.从没有修订的主干分支是没有意义的,在实际用例中,您将从具有至少1个修订的分支分支,在这种情况下,您将不会得到此类错误,并且合并将按预期工作.