"switch -b" sets incorrect parent for heavyweight checkout

Bug #513709 reported by Dr Al on 2010-01-28
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Low
Dr Al

Bug Description

From a user's point of view, a heavyweight checkout should operate like a lightweight checkout but with added benefits (faster operation over a network etc). Using a feature branch model with a light weight checkout, the parent branch of a new feature branch created by "switch -b" is the original feature branch. With a heavyweight checkout, the parent branch is incorrectly set as the checkout location.

For example:

###################
# SETUP (COMMON): #
###################

$ bzr init-repo --no-trees testproj
    Shared repository (format: 2a)
    Location:
      shared repository: testproj
$ bzr init testproj/trunk
    Created a repository branch (format: 2a)
    Using shared repository: C:/al/testing/testproj/

###############
# LIGHTWEIGHT: #
###############

$ bzr co --lightweight testproj/trunk/ trlco
$ cd trlco
$ bzr switch -b feature-branch-lw
    Tree is up to date at revision 0.
    Switched to branch: C:/al/testing/testproj/feature-branch-lw/
$ cd ..
$ bzr info testproj/feature-branch-lw/
    Repository branch (format: 2a)
    Location:
      shared repository: testproj
      repository branch: testproj/feature-branch-lw

    Related branches:
      parent branch: testproj/trunk

# This is correct: parent branch is trunk

################
# HEAVYWEIGHT: #
################

$ bzr co testproj/trunk/ trhco
$ cd trhco
$ bzr switch -b feature-branch-hw
    Tree is up to date at revision 0.
    Switched to branch: C:/al/testing/testproj/feature-branch-hw/
$ cd ..
$ bzr info testproj/feature-branch-hw/
    Repository branch (format: 2a)
    Location:
      shared repository: testproj
      repository branch: testproj/feature-branch-hw

    Related branches:
      parent branch: trhco

# This is incorrect: the parent branch should be testproj/trunk

Related branches

Dr Al (abudden) on 2010-01-28
description: updated
John A Meinel (jameinel) on 2010-02-02
Changed in bzr:
importance: Undecided → Low
status: New → Confirmed
Dr Al (abudden) wrote :

Would anyone be willing to mentor me on attempting to fix this bug? I'm really keen to see it sorted as it seriously affects the use of feature branches with bound-branches. However, I'm not really sure of where to start looking for the place in the code where the parent branch is set after a switch checkout.

Martin Pool (mbp) wrote :

Hi Dr Al,

We would be happy to mentor you. You might like to try talking on #bzr on irc where people can give you real-time help.

One place to start would be to add a scriptrunner test based on the examples you use above; you can expect that will fail; it will then confirm this is fixed when it does otherwise.

A heavyweight checkout is implemented as a BranchReferenceFormat object which when opened gives you the referenced branch.

When you make a new bzr branch, it's 'parent' configuration defaults to the branch that it was branched from. So in some ways it makes sense and is consistent with real branches that if you create feature-branch-tw from the trhco branch, it should say the latter is its parent. However in this case it's not really useful.

So it seems like we want the rule to be that we set the master location to be the real canonical location of the source branch, after following any references. That seems to be set in Branch.sprout. Eventually we will also probably want a unit test just for this specific behaviour, in test_branch.

I hope that gives you a clue to get started. If you want to talk more, just ask, here or on the list or on irc.

Vincent Ladeuil (vila) on 2011-05-06
Changed in bzr:
assignee: nobody → Dr Al (abudden)
status: Confirmed → In Progress
milestone: none → 2.4b3
Vincent Ladeuil (vila) on 2011-05-06
Changed in bzr:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers