/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

Fix branch cloning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
class GitDir(bzrdir.BzrDir):
72
72
    """An adapter to the '.git' dir used by git."""
73
73
 
 
74
    def is_supported(self):
 
75
        return True
 
76
 
 
77
    def cloning_metadir(self, stacked=False):
 
78
        return bzrlib.bzrdir.format_registry.make_bzrdir("1.9-rich-root")
 
79
 
 
80
 
 
81
class LocalGitDir(GitDir):
 
82
    """An adapter to the '.git' dir used by git."""
 
83
 
74
84
    _gitrepository_class = repository.LocalGitRepository
75
85
 
76
86
    def __init__(self, transport, lockfiles, gitrepo, format):
93
103
    get_repository_transport = get_branch_transport
94
104
    get_workingtree_transport = get_branch_transport
95
105
 
96
 
    def is_supported(self):
97
 
        return True
98
 
 
99
106
    def open_branch(self, ignored=None):
100
107
        """'create' a branch for this dir."""
101
108
        repo = self.open_repository()
102
 
        if repo._git.heads == []:
103
 
            head = None
104
 
        else:
105
 
            head = repo._git.head()
106
 
        return branch.LocalGitBranch(self, repo, "HEAD", head, self._lockfiles)
 
109
        return branch.LocalGitBranch(self, repo, "HEAD", repo._git.head(), self._lockfiles)
107
110
 
108
111
    def open_repository(self, shared=False):
109
112
        """'open' a repository for this dir."""
117
120
            return workingtree.GitWorkingTree(self, self.open_repository(), 
118
121
                                                  self.open_branch())
119
122
 
120
 
    def cloning_metadir(self, stacked=False):
121
 
        if stacked:
122
 
            return bzrlib.bzrdir.format_registry.make_bzrdir("pack-0.92")
123
 
        else:
124
 
            return bzrlib.bzrdir.format_registry.make_bzrdir("1.6")
125
 
 
126
123
    def create_repository(self, shared=False):
127
124
        return self.open_repository()
128
125
 
129
126
 
130
 
class LocalGitBzrDirFormat(bzrdir.BzrDirFormat):
 
127
class GitBzrDirFormat(bzrdir.BzrDirFormat):
 
128
    _lock_class = TransportLock
 
129
 
 
130
    def is_supported(self):
 
131
        return True
 
132
 
 
133
 
 
134
class LocalGitBzrDirFormat(GitBzrDirFormat):
131
135
    """The .git directory control format."""
132
136
 
133
 
    _gitdir_class = GitDir
134
 
    _lock_class = TransportLock
 
137
    _gitdir_class = LocalGitDir
135
138
 
136
139
    @classmethod
137
140
    def _known_formats(self):
157
160
    @classmethod
158
161
    def probe_transport(klass, transport):
159
162
        """Our format is present if the transport ends in '.not/'."""
 
163
        from bzrlib.plugins.git import git
160
164
        # little ugly, but works
161
165
        format = klass()
162
166
        # delegate to the main opening code. This pays a double rtt cost at the
166
170
        try:
167
171
            format.open(transport)
168
172
            return format
169
 
        except Exception, e:
 
173
        except git.errors.NotGitRepository, e:
170
174
            raise errors.bzr_errors.NotBranchError(path=transport.base)
171
175
        raise errors.bzr_errors.NotBranchError(path=transport.base)
172
176
 
192
196
        return True
193
197
 
194
198
 
195
 
class RemoteGitBzrDirFormat(bzrdir.BzrDirFormat):
 
199
class RemoteGitBzrDirFormat(GitBzrDirFormat):
196
200
    """The .git directory control format."""
197
201
 
198
 
    _lock_class = TransportLock
199
 
 
200
202
    @classmethod
201
203
    def _known_formats(self):
202
204
        return set([RemoteGitBzrDirFormat()])
229
231
        try:
230
232
            transport.fetch_pack(lambda x: [], None, lambda x: None, 
231
233
                                 lambda x: mutter("git: %s" % x))
232
 
        except GitProtocolException, e:
 
234
        except errors.git_errors.GitProtocolError:
233
235
            raise errors.bzr_errors.NotBranchError(path=transport.base)
234
236
        else:
235
237
            return format
244
246
    def initialize_on_transport(self, transport):
245
247
        raise errors.bzr_errors.UninitializableFormat(self)
246
248
 
247
 
    def is_supported(self):
248
 
        return True