1
1
# Copyright (C) 2007 Canonical Ltd
2
# Copyright (C) 2010 Jelmer Vernooij
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)
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)
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
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)
120
from dulwich.repo import SYMREF
121
refcontents = self._git.refs.read_ref(ref)
122
if refcontents.startswith(SYMREF):
123
ref = refcontents[len(SYMREF):]
116
126
def is_control_filename(self, filename):
117
127
return filename == '.git' or filename.startswith('.git/')
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)
126
get_repository_transport = get_branch_transport
127
get_workingtree_transport = get_branch_transport
136
def get_repository_transport(self, format):
138
return self.transport
139
if isinstance(format, LocalGitBzrDirFormat):
140
return self.transport
141
raise bzr_errors.IncompatibleFormat(format, self._format)
143
def get_workingtree_transport(self, format):
145
return self.transport
146
if isinstance(format, LocalGitBzrDirFormat):
147
return self.transport
148
raise bzr_errors.IncompatibleFormat(format, self._format)
129
150
def _open_branch(self, name=None, ignore_fallbacks=None, unsupported=False):
130
151
"""'create' a branch for this dir."""
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)
172
194
def backup_bzrdir(self):