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

Support bzr init --git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""An adapter between a Git control dir and a Bazaar BzrDir"""
18
18
 
19
 
import git
 
19
import git, os
20
20
 
21
21
from bzrlib.lazy_import import lazy_import
22
22
from bzrlib import (
26
26
    )
27
27
 
28
28
lazy_import(globals(), """
 
29
from bzrlib.lockable_files import TransportLock
29
30
from bzrlib.plugins.git import (
30
31
    errors,
31
32
    branch,
114
115
    def cloning_metadir(self):
115
116
        return bzrdir.BzrDirFormat.get_default_format()
116
117
 
 
118
    def create_repository(self, shared=False):
 
119
        return self.open_repository()
 
120
 
117
121
 
118
122
class GitBzrDirFormat(bzrdir.BzrDirFormat):
119
123
    """The .git directory control format."""
120
124
 
121
125
    _gitdir_class = GitDir
 
126
    _lock_class = TransportLock
122
127
 
123
128
    @classmethod
124
129
    def _known_formats(self):
159
164
    def get_format_description(self):
160
165
        return "Local Git Repository"
161
166
 
 
167
    def get_format_string(self):
 
168
        return "Local Git Repository"
 
169
 
 
170
    def initialize_on_transport(self, transport):
 
171
        from bzrlib.transport.local import LocalTransport
 
172
 
 
173
        if not isinstance(transport, LocalTransport):
 
174
            raise NotImplementedError(self.initialize, 
 
175
                "Can't create Git Repositories/branches on "
 
176
                "non-local transports")
 
177
 
 
178
        git.repo.Repo.create(transport.local_abspath(".")) 
 
179
        return self.open(transport)
 
180
 
162
181
 
163
182
bzrdir.BzrDirFormat.register_control_format(GitBzrDirFormat)