For colocated branches, I think the question is whether or not the working tree and its reference to the branch should count as an entry in list_branches. If I did "bzr init --development-colo file:test,branch=trunk" then I would be very surprised if "bzr branches" listed trunk twice.
The code that tests list_branches in blacbox/test_switch.py, which actually has a working tree, uses set(list_branches()) presumably to eliminate order dependency, but it also obscures any possible repeats. In bzrlib/tests/per_branch/test_branch.py:test_create_colocated there are no working trees and similarly in bzrlib/tests/per_controldir/test_controldir.py: test_list_branches and bzrlib/tests/per_controldir_colo/test_supported:test_unicode. I think that my original code excerpt could be added as a failing test.
For colocated branches, I think the question is whether or not the working tree and its reference to the branch should count as an entry in list_branches. If I did "bzr init --development-colo file:test, branch= trunk" then I would be very surprised if "bzr branches" listed trunk twice.
The code that tests list_branches in blacbox/ test_switch. py, which actually has a working tree, uses set(list_ branches( )) presumably to eliminate order dependency, but it also obscures any possible repeats. In bzrlib/ tests/per_ branch/ test_branch. py:test_ create_ colocated there are no working trees and similarly in bzrlib/ tests/per_ controldir/ test_controldir .py: test_list_branches and bzrlib/ tests/per_ controldir_ colo/test_ supported: test_unicode. I think that my original code excerpt could be added as a failing test.