在现有 bzr 项目中创建分支

发布于 2024-09-27 06:02:13 字数 639 浏览 6 评论 0原文

我是一个小项目的唯一开发人员。我用集市运送这个项目。在最初阶段,我做了以下工作:

mkdir myProject
cd myProject
bzr init
bzr mkdir src
bzr mkdir data
bzr mkdir foo
....

我在这个项目上取得了一些进展,并且它已经包含了几十个提交。现在我意识到我需要为这个项目创建分支。类似

trunk
rel
testFeature1
testFeature2
...

完成此任务的最佳方法是什么?

我所做的是:

cd myProject
mkdir repo
mv .bzr repo
mv .bzrignore repo
del src data foo

mkdir trunk
cd trunk
bzr branch ../repo ./ --use-existing-dir

我对结果非常满意,除了在 myProject/repo 内发出的 bzr status 抱怨所有这些丢失的文件这一事实。

现在问问题:我的方法可以接受吗?对于 repo 目录中丢失的文件我该怎么办?

I'm the only developer of a small project. I truck that project with bazaar. At the initial stages I did the following:

mkdir myProject
cd myProject
bzr init
bzr mkdir src
bzr mkdir data
bzr mkdir foo
....

I have had some progress with this project and it already contains couple of dozens of commits. Now I have realized that I need to create branches for this project. Something like

trunk
rel
testFeature1
testFeature2
...

What is the best way to accomplish this?

What I did was:

cd myProject
mkdir repo
mv .bzr repo
mv .bzrignore repo
del src data foo

mkdir trunk
cd trunk
bzr branch ../repo ./ --use-existing-dir

I'm pretty much satisfied with the result, except for the fact that bzr status issued inside myProject/repo complains about all those missing files.

Now to the questions: is my approach acceptable? What should I do about the missing files in the repo directory?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

败给现实 2024-10-04 06:02:13

我要做的方法是:从您创建的项目开始:

mkdir myProject
cd myProject
bzr init
bzr mkdir src
bzr mkdir data
bzr mkdir foo
....
# (As per your steps above)
bzr add
bzr ci -m "Done stuff"

现在创建一个存储库并将分支推入其中:

# Now make it into a multi-branch project
cd ..
# Make a new repository with no working trees
bzr init-repo --no-trees repo
# Branch the project into the repository
bzr branch myProject repo/trunk
# Get rid of the project (by moving, to keep a backup)
mv myProject myProject_backup

现在开始进行签出(轻量级或其他方式,具体取决于您的偏好):

# Now get a working copy and put it in a separate folder to the repo
bzr co --lightweight repo/trunk myProject
# Now do stuff
cd myProject
# Hack hack hack
bzr ci -m "Done stuff"

现在,您可以为功能或其他内容创建分支:

# Time to change branch (-b creates the new branch in the repository):
bzr switch -b testFeature1
# Now it is a lightweight checkout of ../repo/testFeature1, which is branched off trunk
# Hack hack hack
bzr ci -m "Done stuff with testFeature1: seems to work"

并将更改合并回主干:

bzr switch trunk
bzr merge ../repo/testFeature1
bzr ci -m "Merged testFeature1 development."

请注意,bzr switch 采用相对于当前目录、绝对路径或相对于存储库的路径您已链接到存储库,但 bzr merge 需要相对于当前目录或绝对路径(不是相对于存储库)。


这可能不适合您的工作流程(结帐等),但它是实现您想要做的事情的相当有效的方法。希望有帮助。

The way I would go about this would be to do this: start with a project like the one you created:

mkdir myProject
cd myProject
bzr init
bzr mkdir src
bzr mkdir data
bzr mkdir foo
....
# (As per your steps above)
bzr add
bzr ci -m "Done stuff"

Now create a repository and push the branch into it:

# Now make it into a multi-branch project
cd ..
# Make a new repository with no working trees
bzr init-repo --no-trees repo
# Branch the project into the repository
bzr branch myProject repo/trunk
# Get rid of the project (by moving, to keep a backup)
mv myProject myProject_backup

Now start working on a checkout (lightweight or otherwise depending on your preference):

# Now get a working copy and put it in a separate folder to the repo
bzr co --lightweight repo/trunk myProject
# Now do stuff
cd myProject
# Hack hack hack
bzr ci -m "Done stuff"

Now you can create branches for features or whatever:

# Time to change branch (-b creates the new branch in the repository):
bzr switch -b testFeature1
# Now it is a lightweight checkout of ../repo/testFeature1, which is branched off trunk
# Hack hack hack
bzr ci -m "Done stuff with testFeature1: seems to work"

and merge the changes back into trunk:

bzr switch trunk
bzr merge ../repo/testFeature1
bzr ci -m "Merged testFeature1 development."

Note that bzr switch takes either a path that is either relative to the current directory, absolute, or relative to the repository when you're linked to a repository, but bzr merge requires a path that is relative to the current directory or absolute (not relative to the repository).


This may not fit your workflow (checkouts and the like), but it is a fairly effective way of achieving what you want to do. Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文