Confused about branching

Asked by tommyt on 2010-03-25

I think I may have done something wrong with a branch I made. I did the following:

1. Made a branch to work on a new feature I thought might take a while (It didn't). Bazaar explorer recommended projectname/trunk/trunk for the branch name, which seemed weird so I changed it to projectname/trunk/branch1
2. I opened the new branch, I finished my changes and commit changes in the branch.
3. I opened parent branch and it notified me of a new directory branch1 that it wanted to version. That seemed weird to me. I clicked merge to update the parent branch (trunk), which seemed to work.
4. I didn't want to include the new branch as a versioned directory in my trunk branch, so i deleted it: rm -r projectname/trunk/branch1
5. I commit changes in the trunk branch. Everything seemed fine.
6. Now when I open my trunk it gives me an error that says: "Not a branch: projectname/trunk/branch1".

Did I do something wrong? Are we supposed to keep branch directories around indefinitely, and version them? I think I am using the "shared repository" structure if that matters. Thanks for any help.

Question information

Language:
English Edit question
Status:
Answered
For:
Bazaar Explorer Edit question
Assignee:
No assignee Edit question
Last query:
2010-03-25
Last reply:
2010-03-29

tommyt wrote:
> New question #105456 on Bazaar Explorer:
> https://answers.launchpad.net/bzr-explorer/+question/105456
>
> I think I may have done something wrong with a branch I made. I did the following:
>
> 1. Made a branch to work on a new feature I thought might take a while (It didn't). Bazaar explorer recommended projectname/trunk/trunk for the branch name, which seemed weird so I changed it to projectname/trunk/branch1

How did you create that branch? It's certainly in the wrong place. The
branch should have been in a sister directory to trunk, not below it.

When creating feature branches, the recommended way to do it is:

1. Open the shared repository (projectname/)
2. Select the trunk branch
3. Hit the Branch button. The destination should be blank, ready for you
to enter in a sensible name.

> 2. I opened the new branch, I finished my changes and commit changes in the branch.
> 3. I opened parent branch and it notified me of a new directory branch1 that it wanted to version. That seemed weird to me. I clicked merge to update the parent branch (trunk), which seemed to work.

It thinks you've created a new directory within trunk. You certainly
don't want that.

> 4. I didn't want to include the new branch as a versioned directory in my trunk branch, so i deleted it: rm -r projectname/trunk/branch1
> 5. I commit changes in the trunk branch. Everything seemed fine.

It's not. If you look at the history of trunk, it probably thinks the
previous revision has a directory called branch1.

> 6. Now when I open my trunk it gives me an error that says: "Not a branch: projectname/trunk/branch1".
>
> Did I do something wrong? Are we supposed to keep branch directories around indefinitely, and version them? I think I am using the "shared repository" structure if that matters. Thanks for any help.

So we need to repair this. It sounds like the change/fix was a simple
one so I'm guessing it's easy to do it again. If not, let me know and
I'll recommend a slightly longer recovery process than the one given below..

Otherwise, here's how to recover your trunk branch so that its history
is correct again.

1. Change directory to projectname/trunk.
2. Use 'bzr qlog' to find out the good revision (let's call it X) before
the merge.
3. Use

  bzr uncommit -rX
  bzr revert -rX

to get your tree and history back to the right state.

4. Redo the fix. This time, open the shared repository and create the
feature branch as explained above. Once the fix is applied to the
feature branch, open the trunk branch and merge the feature branch. When
complete, delete the feature branch.

If you have any problems, let us know. If you want real-time help, try
our IRC channel (#bzr) on freenode.

Ian C.

tommyt (tbsisan) said : #2

Hi, thanks for your suggestions.

To answer your question:
I created the branch by going through the menu option Bazaar->Start->Branch from the trunk branch. If you do it this way there is a suggestion filled in of the form projectname/trunk/trunk. I followed your instruction about using the branch button, which does as you say. I never noticed that on the project view page before. The sister directory method makes a lot more sense.

To clarify:
I never added the branch1 directory to the trunk, nor did I commit any changes in trunk while the branch1 directory was there. Going through my log history, no revision has any knowledge of the branch1 directory. The history does show the branch in what appears to me to be a normal fashion (as revision 20.1.1 with a light blue dot, branching from revision 20 and returning at revision 21). However, I still get the error described above when in the trunk view, in the window at the bottom of bzr explorer in red font.

Also, before attempting any fixes, I'd like to back up my repository. Is it as simple as copy/pasting my project directory and everything within?

I will give your suggestions a closer look tomorrow. Thanks.

Yes, backing up is as simply as copying the repository directory (and all subdirectories) somewhere safe.

The window at the bottom is showing the "submit report", i.e. what would be merged if a given branch is merged into it's submit location. As a rule, the trunk should never have a submit location: it other branches which you want to merge into it. To fix this, go to Settings --> Configuration --> Branch Configuration and delete the line saying "submit_location = ..."

Ian C.

Can you help with this problem?

Provide an answer of your own, or ask tommyt for more information if necessary.

To post a message you must log in.