/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

Merge new bzr-foreign.

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, os
 
19
import os
20
20
 
21
21
import bzrlib
22
22
from bzrlib.lazy_import import lazy_import
37
37
""")
38
38
 
39
39
 
 
40
 
40
41
class GitLock(object):
41
42
    """A lock that thunks through to Git."""
42
43
 
52
53
    def peek(self):
53
54
        pass
54
55
 
 
56
    def validate_token(self, token):
 
57
        pass
 
58
 
55
59
 
56
60
class GitLockableFiles(lockable_files.LockableFiles):
57
61
    """Git specific lockable files abstraction."""
58
62
 
59
 
    def __init__(self, lock):
 
63
    def __init__(self, transport, lock):
60
64
        self._lock = lock
61
65
        self._transaction = None
62
66
        self._lock_mode = None
63
67
        self._lock_count = 0
 
68
        self._transport = transport
64
69
 
65
70
 
66
71
class GitDir(bzrdir.BzrDir):
97
102
        if repo._git.heads == []:
98
103
            head = None
99
104
        else:
100
 
            head = repo._git.heads[0].commit.id
 
105
            head = repo._git.head()
101
106
        return branch.GitBranch(self, repo, head, 
102
107
                                    self.root_transport.base, self._lockfiles)
103
108
 
137
142
        """Open this directory.
138
143
 
139
144
        """
 
145
        from bzrlib.plugins.git import git
140
146
        # we dont grok readonly - git isn't integrated with transport.
141
147
        url = transport.base
142
148
        if url.startswith('readonly+'):
146
152
            gitrepo = git.repo.Repo(transport.local_abspath("."))
147
153
        except errors.bzr_errors.NotLocalUrl:
148
154
            raise errors.bzr_errors.NotBranchError(path=transport.base)
149
 
        lockfiles = GitLockableFiles(GitLock())
 
155
        lockfiles = GitLockableFiles(transport, GitLock())
150
156
        return self._gitdir_class(transport, lockfiles, gitrepo, self)
151
157
 
152
158
    @classmethod
173
179
 
174
180
    def initialize_on_transport(self, transport):
175
181
        from bzrlib.transport.local import LocalTransport
 
182
        from bzrlib.plugins.git import git
176
183
 
177
184
        if not isinstance(transport, LocalTransport):
178
185
            raise NotImplementedError(self.initialize, 
182
189
        git.repo.Repo.create(transport.local_abspath(".")) 
183
190
        return self.open(transport)
184
191
 
 
192
    def is_supported(self):
 
193
        return True
 
194
 
185
195
 
186
196
bzrdir.BzrDirFormat.register_control_format(GitBzrDirFormat)