78
78
def cloning_metadir(self, stacked=False):
79
return get_rich_root_format(stacked)
79
return bzrdir.format_registry.make_bzrdir("default")
81
81
def _branch_name_to_ref(self, name):
82
82
raise NotImplementedError(self._branch_name_to_ref)
113
113
self._mode_check_done = None
115
115
def _branch_name_to_ref(self, name):
116
from bzrlib.plugins.git.branch import branch_name_to_ref
117
if name in (None, "HEAD"):
116
from bzrlib.plugins.git.refs import branch_name_to_ref
117
ref = branch_name_to_ref(name, None)
118
119
from dulwich.repo import SYMREF
119
refcontents = self._git.refs.read_ref("HEAD")
120
refcontents = self._git.refs.read_ref(ref)
120
121
if refcontents.startswith(SYMREF):
121
name = refcontents[len(SYMREF):]
124
return branch_name_to_ref(name, "HEAD")
122
ref = refcontents[len(SYMREF):]
126
125
def is_control_filename(self, filename):
127
126
return filename == '.git' or filename.startswith('.git/')
129
def get_branch_transport(self, branch_format):
128
def get_branch_transport(self, branch_format, name=None):
130
129
if branch_format is None:
131
130
return self.transport
132
131
if isinstance(branch_format, LocalGitBzrDirFormat):
133
132
return self.transport
134
133
raise bzr_errors.IncompatibleFormat(branch_format, self._format)
136
get_repository_transport = get_branch_transport
137
get_workingtree_transport = get_branch_transport
135
def get_repository_transport(self, format):
137
return self.transport
138
if isinstance(format, LocalGitBzrDirFormat):
139
return self.transport
140
raise bzr_errors.IncompatibleFormat(format, self._format)
142
def get_workingtree_transport(self, format):
144
return self.transport
145
if isinstance(format, LocalGitBzrDirFormat):
146
return self.transport
147
raise bzr_errors.IncompatibleFormat(format, self._format)
139
149
def _open_branch(self, name=None, ignore_fallbacks=None, unsupported=False):
140
150
"""'create' a branch for this dir."""
169
179
from bzrlib.plugins.git.workingtree import GitWorkingTree
170
return GitWorkingTree(self, repo, self.open_branch(), index)
181
branch = self.open_branch()
182
except bzr_errors.NotBranchError:
185
return GitWorkingTree(self, repo, branch, index)
171
186
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
172
187
raise bzr_errors.NoWorkingTree(loc)
177
192
def create_branch(self, name=None):
178
193
refname = self._branch_name_to_ref(name)
179
self._git.refs[refname] = "0" * 40
194
from dulwich.protocol import ZERO_SHA
195
self._git.refs[refname or "HEAD"] = ZERO_SHA
180
196
return self.open_branch(name)
182
198
def backup_bzrdir(self):