开发者

Create branches inside an existing bzr project

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
tes开发者_如何学运维tFeature2
...

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜