115
106
return self._gitrepository_class(self, self._lockfiles)
117
108
def open_workingtree(self, recommend_upgrade=True):
118
if (not self._git.bare and
119
os.path.exists(os.path.join(self._git.controldir(), "index"))):
110
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
111
raise errors.bzr_errors.NoWorkingTree(loc)
120
113
return workingtree.GitWorkingTree(self, self.open_repository(),
121
114
self.open_branch())
122
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
123
raise errors.bzr_errors.NoWorkingTree(loc)
116
def cloning_metadir(self, stacked=False):
118
return bzrlib.bzrdir.format_registry.make_bzrdir("pack-0.92")
120
return bzrlib.bzrdir.format_registry.make_bzrdir("1.6")
125
122
def create_repository(self, shared=False):
126
123
return self.open_repository()
126
class LocalGitBzrDirFormat(bzrdir.BzrDirFormat):
127
"""The .git directory control format."""
129
_gitdir_class = GitDir
130
_lock_class = TransportLock
133
def _known_formats(self):
134
return set([LocalGitBzrDirFormat()])
136
def open(self, transport, _found=None):
137
"""Open this directory.
140
from bzrlib.plugins.git import git
141
# we dont grok readonly - git isn't integrated with transport.
143
if url.startswith('readonly+'):
144
url = url[len('readonly+'):]
147
gitrepo = git.repo.Repo(transport.local_abspath("."))
148
except errors.bzr_errors.NotLocalUrl:
149
raise errors.bzr_errors.NotBranchError(path=transport.base)
150
lockfiles = GitLockableFiles(transport, GitLock())
151
return self._gitdir_class(transport, lockfiles, gitrepo, self)
154
def probe_transport(klass, transport):
155
"""Our format is present if the transport ends in '.not/'."""
156
# little ugly, but works
158
# delegate to the main opening code. This pays a double rtt cost at the
159
# moment, so perhaps we want probe_transport to return the opened thing
160
# rather than an openener ? or we could return a curried thing with the
161
# dir to open already instantiated ? Needs more thought.
163
format.open(transport)
166
raise errors.bzr_errors.NotBranchError(path=transport.base)
167
raise errors.bzr_errors.NotBranchError(path=transport.base)
169
def get_format_description(self):
170
return "Local Git Repository"
172
def get_format_string(self):
173
return "Local Git Repository"
175
def initialize_on_transport(self, transport):
176
from bzrlib.transport.local import LocalTransport
177
from bzrlib.plugins.git import git
179
if not isinstance(transport, LocalTransport):
180
raise NotImplementedError(self.initialize,
181
"Can't create Git Repositories/branches on "
182
"non-local transports")
184
git.repo.Repo.create(transport.local_abspath("."))
185
return self.open(transport)
187
def is_supported(self):
191
class RemoteGitBzrDirFormat(bzrdir.BzrDirFormat):
192
"""The .git directory control format."""
194
_lock_class = TransportLock
197
def _known_formats(self):
198
return set([RemoteGitBzrDirFormat()])
200
def open(self, transport, _found=None):
201
"""Open this directory.
204
from bzrlib.plugins.git.remote import RemoteGitDir, GitSmartTransport
205
if not isinstance(transport, GitSmartTransport):
206
raise errors.bzr_errors.NotBranchError(transport.base)
207
# we dont grok readonly - git isn't integrated with transport.
209
if url.startswith('readonly+'):
210
url = url[len('readonly+'):]
212
lockfiles = GitLockableFiles(transport, GitLock())
213
return RemoteGitDir(transport, lockfiles, self)
216
def probe_transport(klass, transport):
217
"""Our format is present if the transport ends in '.not/'."""
218
# little ugly, but works
220
from bzrlib.plugins.git.remote import GitSmartTransport
221
if not isinstance(transport, GitSmartTransport):
222
raise errors.bzr_errors.NotBranchError(transport.base)
223
# The only way to know a path exists and contains a valid repository
224
# is to do a request against it:
226
transport.fetch_pack(lambda x: [], None, lambda x: None,
227
lambda x: mutter("git: %s" % x))
228
except GitProtocolException, e:
229
raise errors.bzr_errors.NotBranchError(path=transport.base)
232
raise errors.bzr_errors.NotBranchError(path=transport.base)
234
def get_format_description(self):
235
return "Remote Git Repository"
237
def get_format_string(self):
238
return "Remote Git Repository"
240
def initialize_on_transport(self, transport):
241
raise errors.bzr_errors.UninitializableFormat(self)
243
def is_supported(self):