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

Fix tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
 
121
121
format_registry.register_lazy('git',
122
122
    "bzrlib.plugins.git.dir", "LocalGitControlDirFormat",
123
 
    help='GIT repository.', native=False, experimental=False,
124
 
    )
125
 
 
126
 
format_registry.register_lazy('git-bare',
127
 
    "bzrlib.plugins.git.dir", "BareLocalGitControlDirFormat",
128
 
    help='Bare GIT repository (no working tree).', native=False,
129
 
    experimental=False,
 
123
    help='GIT repository.', native=False, experimental=True,
130
124
    )
131
125
 
132
126
from bzrlib.revisionspec import revspec_registry
172
166
            raise bzr_errors.NotBranchError(path=transport.base)
173
167
        lazy_check_versions()
174
168
        import dulwich
175
 
        from bzrlib.plugins.git.transportgit import TransportRepo
 
169
        format = LocalGitControlDirFormat()
176
170
        try:
177
 
            gitrepo = TransportRepo(transport)
 
171
            format.open(transport)
 
172
            return format
178
173
        except dulwich.errors.NotGitRepository, e:
179
174
            raise bzr_errors.NotBranchError(path=transport.base)
180
 
        else:
181
 
            if gitrepo.bare:
182
 
                return BareLocalGitControlDirFormat()
183
 
            else:
184
 
                return LocalGitControlDirFormat()
 
175
        raise bzr_errors.NotBranchError(path=transport.base)
185
176
 
186
177
 
187
178
class LocalGitControlDirFormat(GitControlDirFormat):
188
179
    """The .git directory control format."""
189
180
 
190
 
    bare = False
191
 
 
192
181
    @classmethod
193
182
    def _known_formats(self):
194
183
        return set([LocalGitControlDirFormat()])
212
201
    def get_format_description(self):
213
202
        return "Local Git Repository"
214
203
 
 
204
    def get_format_string(self):
 
205
        return "Local Git Repository"
 
206
 
215
207
    def initialize_on_transport(self, transport):
216
208
        from bzrlib.transport.local import LocalTransport
217
209
 
221
213
                "non-local transports")
222
214
        lazy_check_versions()
223
215
        from dulwich.repo import Repo
224
 
        Repo.init(transport.local_abspath(".").encode(osutils._fs_enc),
225
 
            bare=self.bare)
 
216
        Repo.init(transport.local_abspath(".").encode(osutils._fs_enc))
226
217
        return self.open(transport)
227
218
 
228
219
    def is_supported(self):
229
220
        return True
230
221
 
231
222
 
232
 
class BareLocalGitControlDirFormat(LocalGitControlDirFormat):
233
 
 
234
 
    bare = True
235
 
    supports_workingtrees = False
236
 
 
237
 
    @classmethod
238
 
    def _known_formats(self):
239
 
        return set([RemoteGitControlDirFormat()])
240
 
 
241
 
    def get_format_description(self):
242
 
        return "Local Git Repository (bare)"
243
 
 
244
 
 
245
223
class RemoteGitProber(Prober):
246
224
 
247
225
    def probe_transport(self, transport):
251
229
        if (not url.startswith("git://") and not url.startswith("git+")):
252
230
            raise bzr_errors.NotBranchError(transport.base)
253
231
        # little ugly, but works
 
232
        format = klass()
254
233
        from bzrlib.plugins.git.remote import GitSmartTransport
255
234
        if not isinstance(transport, GitSmartTransport):
256
235
            raise bzr_errors.NotBranchError(transport.base)
257
 
        return RemoteGitControlDirFormat()
 
236
        return format
258
237
 
259
238
 
260
239
 
261
240
class RemoteGitControlDirFormat(GitControlDirFormat):
262
241
    """The .git directory control format."""
263
242
 
264
 
    supports_workingtrees = False
265
 
 
266
243
    @classmethod
267
244
    def _known_formats(self):
268
245
        return set([RemoteGitControlDirFormat()])
293
270
    def get_format_description(self):
294
271
        return "Remote Git Repository"
295
272
 
 
273
    def get_format_string(self):
 
274
        return "Remote Git Repository"
 
275
 
296
276
    def initialize_on_transport(self, transport):
297
277
        raise bzr_errors.UninitializableFormat(self)
298
278
 
299
279
 
300
280
if has_controldir:
301
 
    ControlDirFormat.register_format(LocalGitControlDirFormat())
302
 
    ControlDirFormat.register_format(BareLocalGitControlDirFormat())
303
 
    ControlDirFormat.register_format(RemoteGitControlDirFormat())
 
281
    ControlDirFormat.register_format(LocalGitControlDirFormat)
 
282
    ControlDirFormat.register_format(RemoteGitControlDirFormat)
304
283
    ControlDirFormat.register_prober(LocalGitProber)
305
284
    ControlDirFormat.register_prober(RemoteGitProber)
306
285
else:
307
286
    ControlDirFormat.register_control_format(LocalGitControlDirFormat)
308
 
    ControlDirFormat.register_control_format(BareLocalGitControlDirFormat)
309
287
    ControlDirFormat.register_control_format(RemoteGitControlDirFormat)
310
288
 
311
289
register_transport_proto('git://',
351
329
repository_network_format_registry.register_lazy('git',
352
330
    'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
353
331
 
354
 
try:
355
 
    from bzrlib.controldir import (
356
 
        network_format_registry as controldir_network_format_registry,
357
 
        )
358
 
except ImportError:
359
 
    from bzrlib.bzrdir import (
360
 
        network_format_registry as controldir_network_format_registry,
361
 
        )
362
 
controldir_network_format_registry.register('git', GitControlDirFormat)
 
332
from bzrlib.bzrdir import (
 
333
    network_format_registry as bzrdir_network_format_registry,
 
334
    )
 
335
bzrdir_network_format_registry.register('git', GitControlDirFormat)
363
336
 
364
337
send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
365
338
                                   'send_git', 'Git am-style diff format')