/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

Use dictionary with verifiers rather than requiring testament3-sha1 everywhere.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
    help='GIT repository.', native=False, experimental=False,
124
124
    )
125
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,
130
 
    )
131
 
 
132
126
from bzrlib.revisionspec import revspec_registry
133
127
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
134
128
    "RevisionSpec_git")
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 = RemoteGitControlDirFormat()
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
 
293
272
    def get_format_description(self):
294
273
        return "Remote Git Repository"
295
274
 
 
275
    def get_format_string(self):
 
276
        return "Remote Git Repository"
 
277
 
296
278
    def initialize_on_transport(self, transport):
297
279
        raise bzr_errors.UninitializableFormat(self)
298
280
 
299
281
 
300
282
if has_controldir:
301
283
    ControlDirFormat.register_format(LocalGitControlDirFormat())
302
 
    ControlDirFormat.register_format(BareLocalGitControlDirFormat())
303
284
    ControlDirFormat.register_format(RemoteGitControlDirFormat())
304
285
    ControlDirFormat.register_prober(LocalGitProber)
305
286
    ControlDirFormat.register_prober(RemoteGitProber)
306
287
else:
307
288
    ControlDirFormat.register_control_format(LocalGitControlDirFormat)
308
 
    ControlDirFormat.register_control_format(BareLocalGitControlDirFormat)
309
289
    ControlDirFormat.register_control_format(RemoteGitControlDirFormat)
310
290
 
311
291
register_transport_proto('git://',