/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

(jelmer) Make sure that a branch user URL uniquely identifies that branch,
 and can be used to open it. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
771
771
        return controldir.ControlDir.create(base, format=format,
772
772
                possible_transports=possible_transports)
773
773
 
 
774
    def __repr__(self):
 
775
        return "<%s at %r>" % (self.__class__.__name__, self.user_url)
 
776
 
774
777
 
775
778
class BzrDirMeta1(BzrDir):
776
779
    """A .bzr meta version 1 control object.
788
791
    def create_branch(self, name=None, repository=None,
789
792
            append_revisions_only=None):
790
793
        """See BzrDir.create_branch."""
 
794
        if name is None:
 
795
            name = self._get_selected_branch()
791
796
        return self._format.get_branch_format().initialize(self, name=name,
792
797
                repository=repository,
793
798
                append_revisions_only=append_revisions_only)
938
943
    def open_branch(self, name=None, unsupported=False,
939
944
                    ignore_fallbacks=False):
940
945
        """See BzrDir.open_branch."""
 
946
        if name is None:
 
947
            name = self._get_selected_branch()
941
948
        format = self.find_branch_format(name=name)
942
949
        format.check_support_status(unsupported)
943
950
        return format.open(self, name=name,
983
990
        it uses the default branch.
984
991
 
985
992
        :param name: Optional branch name to use
986
 
        :return: Relative path to branch, branch name
 
993
        :return: Relative path to branch
987
994
        """
988
995
        if name is None:
989
 
            name = self._get_selected_branch()
990
 
        if name is None:
991
 
            return 'branch', None
992
 
        return urlutils.join('branches', name), name
 
996
            return 'branch'
 
997
        return urlutils.join('branches', name.encode("utf-8"))
993
998
 
994
999
    def _read_branch_list(self):
995
1000
        """Read the branch list.
1019
1024
 
1020
1025
    def destroy_branch(self, name=None):
1021
1026
        """See BzrDir.create_branch."""
1022
 
        path, name = self._get_branch_path(name)
 
1027
        if name is None:
 
1028
            name = self._get_selected_branch()
 
1029
        path = self._get_branch_path(name)
1023
1030
        if name is not None:
1024
1031
            self.control_files.lock_write()
1025
1032
            try:
1026
1033
                branches = self._read_branch_list()
1027
1034
                try:
1028
 
                    branches.remove(name)
 
1035
                    branches.remove(name.encode("utf-8"))
1029
1036
                except ValueError:
1030
1037
                    raise errors.NotBranchError(name)
1031
 
                self._write_branch_list(name)
 
1038
                self._write_branch_list(branches)
1032
1039
            finally:
1033
1040
                self.control_files.unlock()
1034
1041
        self.transport.delete_tree(path)
1043
1050
            pass
1044
1051
 
1045
1052
        # colocated branches
1046
 
        ret.extend([self.open_branch(name) for name in
 
1053
        ret.extend([self.open_branch(name.decode("utf-8")) for name in
1047
1054
                    self._read_branch_list()])
1048
1055
 
1049
1056
        return ret
1050
1057
 
1051
1058
    def get_branch_transport(self, branch_format, name=None):
1052
1059
        """See BzrDir.get_branch_transport()."""
1053
 
        path, name = self._get_branch_path(name)
 
1060
        path = self._get_branch_path(name)
1054
1061
        # XXX: this shouldn't implicitly create the directory if it's just
1055
1062
        # promising to get a transport -- mbp 20090727
1056
1063
        if branch_format is None:
1065
1072
            except errors.FileExists:
1066
1073
                pass
1067
1074
            branches = self._read_branch_list()
1068
 
            if not name in branches:
 
1075
            utf8_name = name.encode("utf-8")
 
1076
            if not utf8_name in branches:
1069
1077
                self.control_files.lock_write()
1070
1078
                try:
1071
1079
                    branches = self._read_branch_list()
1072
 
                    branches.append(name)
 
1080
                    branches.append(utf8_name)
1073
1081
                    self._write_branch_list(branches)
1074
1082
                finally:
1075
1083
                    self.control_files.unlock()