~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Neil Martinsen-Burrell
  • Date: 2011-12-09 04:17:50 UTC
  • mto: This revision was merged to the branch mainline in revision 6356.
  • Revision ID: nmb@wartburg.edu-20111209041750-amismw2as944epjj
add get_branches method to return a dictionary of names and branches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1048
1048
 
1049
1049
    def list_branches(self):
1050
1050
        """See ControlDir.list_branches."""
 
1051
        ret = []
 
1052
        # Default branch
 
1053
        try:
 
1054
            ret.append(self.open_branch())
 
1055
        except (errors.NotBranchError, errors.NoRepositoryPresent):
 
1056
            pass
 
1057
 
1051
1058
        # colocated branches
1052
 
        ret = [self.open_branch(name.decode("utf-8")) for name in
1053
 
               self._read_branch_list()]
 
1059
        ret.extend([self.open_branch(name.decode("utf-8")) for name in
 
1060
                    self._read_branch_list()])
 
1061
        return ret
1054
1062
 
1055
 
        # Default branch
 
1063
    def get_branches(self):
 
1064
        """See ControlDir.get_branches."""
 
1065
        ret = {}
1056
1066
        try:
1057
 
            current = self.open_branch()
1058
 
            if not any([current.base == b.base for b in ret]):
1059
 
                ret.append(current)
 
1067
            ret[None] = self.open_branch()
1060
1068
        except (errors.NotBranchError, errors.NoRepositoryPresent):
1061
1069
            pass
1062
1070
 
 
1071
        for name in self._read_branch_list():
 
1072
            ret[name] = self.open_branch(name.decode('utf-8'))
 
1073
 
1063
1074
        return ret
1064
1075
 
1065
1076
    def get_branch_transport(self, branch_format, name=None):