Please explain "branches"

Asked by Gary Weinfurther

Our office uses shared repos on a central file server. This is working very well in our environment. (Although, as an aside, we do get frequent lock file problems and we have to use break-lock more times than we think is necessary).

Our normal wokring process is to do an initial checkout to a working copy on our computers, then do updates and commits as necessary. I have not tried doing lightweight checkouts, but I will try it on a future project.

Now we have a project where we want to create a separate branch to do some what-if scenarios. I now have a bunch of questions:

1. In the Bazaar documentation, the term "branch" seems to be used for everything, and as such, I don't really understand what a branch in Bazaar is. It seems to be used interchangeably with "working copy" and "repository." What is a Bazaar branch? Do I already have a branch, even though I haven't yet "branched" the codebase?

2. What is the procedure for splitting off a branch of the codebase? Do I have to create a new repository for the new branch? I'm confused.

3. Can I switch between the two branches, and if so, how? Do I have to maintain two working copies?

I am using TortoiseBZR, while a colleague is using Bazaar Explorer.

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Martin Pool
Solved:
Last query:
Last reply:
Revision history for this message
Martin Pool (mbp) said :
#1

Hi,

Seems like there's some room for documentation improvements there...

A branch is, essentially, a writeable pointer to the revision at the top of the branch; in implementation it is a .bzr/branch directory. It may be at the same location as a working directory or it may be stand alone. If you've made any commits, you must have at least one branch.

2. You do not need a new repository directory. Either use 'bzr branch' or use the 'Branch' action in explorer: http://doc.bazaar.canonical.com/explorer/en/visual-tour-gnome.html#branch

3. You can either have a working tree for each branch, or you can have just one and use 'bzr switch' to point it first at one branch and then another.

If you read http://doc.bazaar.canonical.com/bzr.dev/en/user-guide/core_concepts.html and http://doc.bazaar.canonical.com/bzr.dev/en/user-guide/index.html and tell me which bits are unclear perhaps we can improve it.

Revision history for this message
Gary Weinfurther (gary-weinfurther) said :
#2

Thanks, Martin, for trying to shed some light. Your definition, though, is similar to the Bazaar docs, in that it is a recursive definition:

"A branch is, essentially, a writeable pointer to the revision at the top of the branch"

I have a central repository "L:/project/source" and a local working tree "D:/project/source". Do I create a new branch like this?

bzr branch L:/project/source L:/project/source/newbranch

It seems bizarre to put the branch in a subdirectory of the repository, where it could be among other folders of the project.

Then to start working on the new branch, do I do this?

bzr switch L:/project/source/newbranch

Revision history for this message
Gary Weinfurther (gary-weinfurther) said :
#3

I also find it puzzling that TortoiseBzr has a Switch command built into its menu, but no Branch command. I know I can use "Run command" but if branching is such a common function, why isn't it easier to do?

Revision history for this message
Best Martin Pool (mbp) said :
#4

> I have a central repository "L:/project/source" and a local working tree
> "D:/project/source".  Do I create a new branch like this?
>
> bzr branch L:/project/source L:/project/source/newbranch

You would say

bzr branch L:/project/source/trunk L:/project/source/newbranch

where source is the repo dir and trunk is your initial branch. That
is the layout I would recommend.

> It seems bizarre to put the branch in a subdirectory of the repository,
> where it could be among other folders of the project.

It should be inside the repository directory, which should be separate
from your trunk branch.

>
> Then to start working on the new branch, do I do this?
>
> bzr switch L:/project/source/newbranch

If you want to switch an existing working directory, yes.

--
Martin

Revision history for this message
Martin Pool (mbp) said :
#5

On 23 November 2010 01:54, Gary Weinfurther
<email address hidden> wrote:
> Question #134734 on Bazaar changed:
> https://answers.launchpad.net/bzr/+question/134734
>
> Gary Weinfurther posted a new comment:
> I also find it puzzling that TortoiseBzr has a Switch command built into
> its menu, but no Branch command.  I know I can use "Run command" but if
> branching is such a common function, why isn't it easier to do?

Not sure; I don't work on Tortoise. Tortoise however is mostly
concerned with working tree operations and perhaps they intend you to
use explorer to branch.
--
Martin

Revision history for this message
Gary Weinfurther (gary-weinfurther) said :
#6

Thanks Martin Pool, that solved my question.