/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
 
    git_branch,
32
 
    git_repository,
33
 
    git_workingtree,
 
32
    branch,
 
33
    repository,
 
34
    workingtree,
34
35
    )
35
36
""")
36
37
 
64
65
class GitDir(bzrdir.BzrDir):
65
66
    """An adapter to the '.git' dir used by git."""
66
67
 
67
 
    _gitrepository_class = git_repository.GitRepository
 
68
    _gitrepository_class = repository.GitRepository
68
69
 
69
70
    def __init__(self, transport, lockfiles, gitrepo, format):
70
71
        self._format = format
96
97
            head = None
97
98
        else:
98
99
            head = repo._git.heads[0].commit.id
99
 
        return git_branch.GitBranch(self, repo, head, 
 
100
        return branch.GitBranch(self, repo, head, 
100
101
                                    self.root_transport.base, self._lockfiles)
101
102
 
102
103
    def open_repository(self, shared=False):
108
109
            loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
109
110
            raise errors.bzr_errors.NoWorkingTree(loc)
110
111
        else:
111
 
            return git_workingtree.GitWorkingTree(self, self.open_repository(), 
 
112
            return workingtree.GitWorkingTree(self, self.open_repository(), 
112
113
                                                  self.open_branch())
113
114
 
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)