/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

SupportĀ bareĀ repositories.

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
 
126
132
from bzrlib.revisionspec import revspec_registry
127
133
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
128
134
    "RevisionSpec_git")
166
172
            raise bzr_errors.NotBranchError(path=transport.base)
167
173
        lazy_check_versions()
168
174
        import dulwich
169
 
        format = LocalGitControlDirFormat()
 
175
        from bzrlib.plugins.git.transportgit import TransportRepo
170
176
        try:
171
 
            format.open(transport)
172
 
            return format
 
177
            gitrepo = TransportRepo(transport)
173
178
        except dulwich.errors.NotGitRepository, e:
174
179
            raise bzr_errors.NotBranchError(path=transport.base)
175
 
        raise bzr_errors.NotBranchError(path=transport.base)
 
180
        else:
 
181
            if gitrepo.bare:
 
182
                return BareLocalGitControlDirFormat()
 
183
            else:
 
184
                return LocalGitControlDirFormat()
176
185
 
177
186
 
178
187
class LocalGitControlDirFormat(GitControlDirFormat):
179
188
    """The .git directory control format."""
180
189
 
 
190
    bare = False
 
191
 
181
192
    @classmethod
182
193
    def _known_formats(self):
183
194
        return set([LocalGitControlDirFormat()])
201
212
    def get_format_description(self):
202
213
        return "Local Git Repository"
203
214
 
204
 
    def get_format_string(self):
205
 
        return "Local Git Repository"
206
 
 
207
215
    def initialize_on_transport(self, transport):
208
216
        from bzrlib.transport.local import LocalTransport
209
217
 
213
221
                "non-local transports")
214
222
        lazy_check_versions()
215
223
        from dulwich.repo import Repo
216
 
        Repo.init(transport.local_abspath(".").encode(osutils._fs_enc))
 
224
        Repo.init(transport.local_abspath(".").encode(osutils._fs_enc),
 
225
            bare=self.bare)
217
226
        return self.open(transport)
218
227
 
219
228
    def is_supported(self):
220
229
        return True
221
230
 
222
231
 
 
232
class BareLocalGitControlDirFormat(LocalGitControlDirFormat):
 
233
 
 
234
    bare = True
 
235
 
 
236
    def get_format_description(self):
 
237
        return "Local Git Repository (bare)"
 
238
 
 
239
 
223
240
class RemoteGitProber(Prober):
224
241
 
225
242
    def probe_transport(self, transport):
272
289
    def get_format_description(self):
273
290
        return "Remote Git Repository"
274
291
 
275
 
    def get_format_string(self):
276
 
        return "Remote Git Repository"
277
 
 
278
292
    def initialize_on_transport(self, transport):
279
293
        raise bzr_errors.UninitializableFormat(self)
280
294
 
281
295
 
282
296
if has_controldir:
283
297
    ControlDirFormat.register_format(LocalGitControlDirFormat())
 
298
    ControlDirFormat.register_format(BareLocalGitControlDirFormat())
284
299
    ControlDirFormat.register_format(RemoteGitControlDirFormat())
285
300
    ControlDirFormat.register_prober(LocalGitProber)
286
301
    ControlDirFormat.register_prober(RemoteGitProber)
287
302
else:
288
303
    ControlDirFormat.register_control_format(LocalGitControlDirFormat)
 
304
    ControlDirFormat.register_control_format(BareLocalGitControlDirFormat)
289
305
    ControlDirFormat.register_control_format(RemoteGitControlDirFormat)
290
306
 
291
307
register_transport_proto('git://',