/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

Use bzr-foreign function names for converting between git and bzr revids.

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 os
 
19
import git
20
20
 
21
 
import bzrlib
22
21
from bzrlib.lazy_import import lazy_import
23
22
from bzrlib import (
24
23
    bzrdir,
27
26
    )
28
27
 
29
28
lazy_import(globals(), """
30
 
from bzrlib.lockable_files import TransportLock
31
29
from bzrlib.plugins.git import (
32
30
    errors,
33
31
    branch,
37
35
""")
38
36
 
39
37
 
40
 
 
41
38
class GitLock(object):
42
39
    """A lock that thunks through to Git."""
43
40
 
98
95
        if repo._git.heads == []:
99
96
            head = None
100
97
        else:
101
 
            head = repo._git.head()
 
98
            head = repo._git.heads[0].commit.id
102
99
        return branch.GitBranch(self, repo, head, 
103
100
                                    self.root_transport.base, self._lockfiles)
104
101
 
114
111
            return workingtree.GitWorkingTree(self, self.open_repository(), 
115
112
                                                  self.open_branch())
116
113
 
117
 
    def cloning_metadir(self, stacked=False):
118
 
        if stacked:
119
 
            return bzrlib.bzrdir.format_registry.make_bzrdir("pack-0.92")
120
 
        else:
121
 
            return bzrlib.bzrdir.format_registry.make_bzrdir("1.6")
122
 
 
123
 
    def create_repository(self, shared=False):
124
 
        return self.open_repository()
 
114
    def cloning_metadir(self):
 
115
        return bzrdir.BzrDirFormat.get_default_format()
125
116
 
126
117
 
127
118
class GitBzrDirFormat(bzrdir.BzrDirFormat):
128
119
    """The .git directory control format."""
129
120
 
130
121
    _gitdir_class = GitDir
131
 
    _lock_class = TransportLock
132
122
 
133
123
    @classmethod
134
124
    def _known_formats(self):
138
128
        """Open this directory.
139
129
 
140
130
        """
141
 
        from bzrlib.plugins.git import git
142
131
        # we dont grok readonly - git isn't integrated with transport.
143
132
        url = transport.base
144
133
        if url.startswith('readonly+'):
170
159
    def get_format_description(self):
171
160
        return "Local Git Repository"
172
161
 
173
 
    def get_format_string(self):
174
 
        return "Local Git Repository"
175
 
 
176
 
    def initialize_on_transport(self, transport):
177
 
        from bzrlib.transport.local import LocalTransport
178
 
        from bzrlib.plugins.git import git
179
 
 
180
 
        if not isinstance(transport, LocalTransport):
181
 
            raise NotImplementedError(self.initialize, 
182
 
                "Can't create Git Repositories/branches on "
183
 
                "non-local transports")
184
 
 
185
 
        git.repo.Repo.create(transport.local_abspath(".")) 
186
 
        return self.open(transport)
187
 
 
188
162
 
189
163
bzrdir.BzrDirFormat.register_control_format(GitBzrDirFormat)