/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

Eliminate (duplicate) git_ prefix.

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
 
20
 
19
21
from bzrlib.lazy_import import lazy_import
20
22
from bzrlib import (
21
23
    bzrdir,
26
28
lazy_import(globals(), """
27
29
from bzrlib.plugins.git import (
28
30
    errors,
29
 
    git_branch,
30
 
    git_repository,
 
31
    branch,
 
32
    repository,
 
33
    workingtree,
31
34
    )
32
35
""")
33
36
 
35
38
class GitLock(object):
36
39
    """A lock that thunks through to Git."""
37
40
 
38
 
    def lock_write(self):
 
41
    def lock_write(self, token=None):
39
42
        pass
40
43
 
41
44
    def lock_read(self):
61
64
class GitDir(bzrdir.BzrDir):
62
65
    """An adapter to the '.git' dir used by git."""
63
66
 
64
 
    _gitrepository_class = git_repository.GitRepository
 
67
    _gitrepository_class = repository.GitRepository
65
68
 
66
 
    def __init__(self, transport, lockfiles, format):
 
69
    def __init__(self, transport, lockfiles, gitrepo, format):
67
70
        self._format = format
68
71
        self.root_transport = transport
69
 
        self.transport = transport.clone('.git')
 
72
        self._git = gitrepo
 
73
        if gitrepo.bare:
 
74
            self.transport = transport
 
75
        else:
 
76
            self.transport = transport.clone('.git')
70
77
        self._lockfiles = lockfiles
71
78
 
72
79
    def get_branch_transport(self, branch_format):
89
96
            head = None
90
97
        else:
91
98
            head = repo._git.heads[0].commit.id
92
 
        return git_branch.GitBranch(self, repo, head, 
 
99
        return branch.GitBranch(self, repo, head, 
93
100
                                    self.root_transport.base, self._lockfiles)
94
101
 
95
102
    def open_repository(self, shared=False):
97
104
        return self._gitrepository_class(self, self._lockfiles)
98
105
 
99
106
    def open_workingtree(self, recommend_upgrade=True):
100
 
        loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
101
 
        raise errors.bzr_errors.NoWorkingTree(loc)
 
107
        if self._git.bare:
 
108
            loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii')
 
109
            raise errors.bzr_errors.NoWorkingTree(loc)
 
110
        else:
 
111
            return workingtree.GitWorkingTree(self, self.open_repository(), 
 
112
                                                  self.open_branch())
102
113
 
103
114
    def cloning_metadir(self):
104
115
        return bzrdir.BzrDirFormat.get_default_format()
113
124
    def _known_formats(self):
114
125
        return set([GitBzrDirFormat()])
115
126
 
116
 
    def open(self, transport, _create=False, _found=None):
 
127
    def open(self, transport, _found=None):
117
128
        """Open this directory.
118
129
 
119
 
        :param _create: create the git dir on the fly. private to GitDirFormat.
120
130
        """
121
131
        # we dont grok readonly - git isn't integrated with transport.
122
132
        url = transport.base
123
133
        if url.startswith('readonly+'):
124
134
            url = url[len('readonly+'):]
125
 
        if not transport.has('.git'):
 
135
 
 
136
        try:
 
137
            gitrepo = git.repo.Repo(transport.local_abspath("."))
 
138
        except errors.bzr_errors.NotLocalUrl:
126
139
            raise errors.bzr_errors.NotBranchError(path=transport.base)
127
140
        lockfiles = GitLockableFiles(GitLock())
128
 
        return self._gitdir_class(transport, lockfiles, self)
 
141
        return self._gitdir_class(transport, lockfiles, gitrepo, self)
129
142
 
130
143
    @classmethod
131
144
    def probe_transport(klass, transport):