BzrDir.list_branches lists same branch twice when a branch reference exists
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Fix Released
|
Low
|
Neil Martinsen-Burrell |
Bug Description
The current implementation of bzrdir.
>>> import bzrlib
>>> from bzrlib import bzrdir
>>> dir = bzrdir.
>>> dir.create_
CHKInventoryRep
>>> dir.create_
BzrBranch7(
>>> dir.list_branches()
[BzrBranch7(
>>> from bzrlib import branch
>>> branch.
BzrBranch7(
>>> dir.list_branches()
[BzrBranch7(
The offending code in bzrlib/bzrdir.py is
def list_branches(
"""See ControlDir.
ret = []
# Default branch
try:
except (errors.
pass
# colocated branches
which adds the branch once as the default branch and once from _read_branch_list. For a colocated workspace, the default branch will always be in the branch list, so list_branches will always return a list with a repeat.
If we have no guarantees on the order in which list_branches returns, we can "return list(set(ret))" to de-dupe.
Related branches
- Vincent Ladeuil: Needs Fixing
- Jelmer Vernooij (community): Approve
-
Diff: 150 lines (+49/-11)8 files modifiedbzrlib/bzrdir.py (+6/-8)
bzrlib/controldir.py (+6/-2)
bzrlib/tests/blackbox/test_branch.py (+1/-1)
bzrlib/tests/per_bzrdir/test_bzrdir.py (+12/-0)
bzrlib/tests/per_controldir/test_controldir.py (+5/-0)
bzrlib/tests/per_controldir_colo/test_supported.py (+8/-0)
bzrlib/tests/per_controldir_colo/test_unsupported.py (+6/-0)
doc/en/release-notes/bzr-2.5.txt (+5/-0)
Changed in bzr: | |
assignee: | nobody → Neil Martinsen-Burrell (nmb) |
importance: | Undecided → Low |
status: | New → In Progress |
Changed in bzr: | |
milestone: | none → 2.5b5 |
status: | In Progress → Fix Released |
Oops, we can't list(set(...)) to remove duplicates because apparently branches don't compare equal based on their base attribute. Should they?