71
71
class GitDir(bzrdir.BzrDir):
72
72
"""An adapter to the '.git' dir used by git."""
74
def is_supported(self):
77
def cloning_metadir(self, stacked=False):
78
return bzrlib.bzrdir.format_registry.make_bzrdir("1.9-rich-root")
81
class LocalGitDir(GitDir):
82
"""An adapter to the '.git' dir used by git."""
84
74
_gitrepository_class = repository.LocalGitRepository
86
76
def __init__(self, transport, lockfiles, gitrepo, format):
103
93
get_repository_transport = get_branch_transport
104
94
get_workingtree_transport = get_branch_transport
96
def is_supported(self):
106
99
def open_branch(self, ignored=None):
107
100
"""'create' a branch for this dir."""
108
101
repo = self.open_repository()
109
return branch.LocalGitBranch(self, repo, "HEAD", repo._git.head(), self._lockfiles)
102
if repo._git.heads == []:
105
head = repo._git.head()
106
return branch.LocalGitBranch(self, repo, "HEAD", head, self._lockfiles)
111
108
def open_repository(self, shared=False):
112
109
"""'open' a repository for this dir."""
113
110
return self._gitrepository_class(self, self._lockfiles)
115
112
def open_workingtree(self, recommend_upgrade=True):
116
if (not self._git.bare and
117
os.path.exists(os.path.join(self._git.controldir(), "index"))):
114
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
115
raise errors.bzr_errors.NoWorkingTree(loc)
118
117
return workingtree.GitWorkingTree(self, self.open_repository(),
119
118
self.open_branch())
120
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
121
raise errors.bzr_errors.NoWorkingTree(loc)
120
def cloning_metadir(self, stacked=False):
122
return bzrlib.bzrdir.format_registry.make_bzrdir("pack-0.92")
124
return bzrlib.bzrdir.format_registry.make_bzrdir("1.6")
123
126
def create_repository(self, shared=False):
124
127
return self.open_repository()
127
class GitBzrDirFormat(bzrdir.BzrDirFormat):
130
class LocalGitBzrDirFormat(bzrdir.BzrDirFormat):
131
"""The .git directory control format."""
133
_gitdir_class = GitDir
128
134
_lock_class = TransportLock
130
def is_supported(self):
134
class LocalGitBzrDirFormat(GitBzrDirFormat):
135
"""The .git directory control format."""
137
_gitdir_class = LocalGitDir
140
137
def _known_formats(self):
141
138
return set([LocalGitBzrDirFormat()])
183
179
def initialize_on_transport(self, transport):
184
180
from bzrlib.transport.local import LocalTransport
185
import dulwich as git
181
from bzrlib.plugins.git import git
187
183
if not isinstance(transport, LocalTransport):
188
184
raise NotImplementedError(self.initialize,
199
class RemoteGitBzrDirFormat(GitBzrDirFormat):
195
class RemoteGitBzrDirFormat(bzrdir.BzrDirFormat):
200
196
"""The .git directory control format."""
198
_lock_class = TransportLock
203
201
def _known_formats(self):
204
202
return set([RemoteGitBzrDirFormat()])
232
230
transport.fetch_pack(lambda x: [], None, lambda x: None,
233
231
lambda x: mutter("git: %s" % x))
234
except errors.git_errors.GitProtocolError:
232
except GitProtocolException, e:
235
233
raise errors.bzr_errors.NotBranchError(path=transport.base)