/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 dir.py

Fix some more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2007 Canonical Ltd
 
2
# Copyright (C) 2010 Jelmer Vernooij
2
3
#
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
79
80
        return get_rich_root_format(stacked)
80
81
 
81
82
    def _branch_name_to_ref(self, name):
82
 
        from bzrlib.plugins.git.branch import branch_name_to_ref
83
 
        return branch_name_to_ref(name)
 
83
        raise NotImplementedError(self._branch_name_to_ref)
84
84
 
85
85
    if bzrlib_version >= (2, 2):
86
86
        def open_branch(self, name=None, ignore_fallbacks=None,
113
113
        self._lockfiles = lockfiles
114
114
        self._mode_check_done = None
115
115
 
 
116
    def _branch_name_to_ref(self, name):
 
117
        from bzrlib.plugins.git.refs import branch_name_to_ref
 
118
        ref = branch_name_to_ref(name, None)
 
119
        if ref == "HEAD":
 
120
            from dulwich.repo import SYMREF
 
121
            refcontents = self._git.refs.read_ref(ref)
 
122
            if refcontents.startswith(SYMREF):
 
123
                ref = refcontents[len(SYMREF):]
 
124
        return ref
 
125
 
116
126
    def is_control_filename(self, filename):
117
127
        return filename == '.git' or filename.startswith('.git/')
118
128
 
119
 
    def get_branch_transport(self, branch_format):
 
129
    def get_branch_transport(self, branch_format, name):
120
130
        if branch_format is None:
121
131
            return self.transport
122
132
        if isinstance(branch_format, LocalGitBzrDirFormat):
123
133
            return self.transport
124
134
        raise bzr_errors.IncompatibleFormat(branch_format, self._format)
125
135
 
126
 
    get_repository_transport = get_branch_transport
127
 
    get_workingtree_transport = get_branch_transport
 
136
    def get_repository_transport(self, format):
 
137
        if format is None:
 
138
            return self.transport
 
139
        if isinstance(format, LocalGitBzrDirFormat):
 
140
            return self.transport
 
141
        raise bzr_errors.IncompatibleFormat(format, self._format)
 
142
 
 
143
    def get_workingtree_transport(self, format):
 
144
        if format is None:
 
145
            return self.transport
 
146
        if isinstance(format, LocalGitBzrDirFormat):
 
147
            return self.transport
 
148
        raise bzr_errors.IncompatibleFormat(format, self._format)
128
149
 
129
150
    def _open_branch(self, name=None, ignore_fallbacks=None, unsupported=False):
130
151
        """'create' a branch for this dir."""
139
160
    def list_branches(self):
140
161
        ret = []
141
162
        for name in self._git.get_refs():
142
 
            if name.startswith("refs/heads/") or name == "HEAD":
 
163
            if name.startswith("refs/heads/"):
143
164
                ret.append(self.open_branch(name=name))
144
165
        return ret
145
166
 
166
187
 
167
188
    def create_branch(self, name=None):
168
189
        refname = self._branch_name_to_ref(name)
169
 
        self._git.refs[refname] = "0" * 40
 
190
        from dulwich.protocol import ZERO_SHA
 
191
        self._git.refs[refname or "HEAD"] = ZERO_SHA
170
192
        return self.open_branch(name)
171
193
 
172
194
    def backup_bzrdir(self):