/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 __init__.py

More renames.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        )
63
63
    ControlDir = BzrDir
64
64
    ControlDirFormat = BzrDirFormat
65
 
    Prober = object
66
65
    has_controldir = False
67
66
else:
68
67
    has_controldir = True
120
119
 
121
120
format_registry.register_lazy('git',
122
121
    "bzrlib.plugins.git.dir", "LocalGitControlDirFormat",
123
 
    help='GIT repository.', native=False, experimental=False,
124
 
    )
125
 
 
126
 
format_registry.register_lazy('git-bare',
127
 
    "bzrlib.plugins.git.dir", "BareLocalGitControlDirFormat",
128
 
    help='Bare GIT repository (no working tree).', native=False,
129
 
    experimental=False,
 
122
    help='GIT repository.', native=False, experimental=True,
130
123
    )
131
124
 
132
125
from bzrlib.revisionspec import revspec_registry
158
151
        return "git"
159
152
 
160
153
 
161
 
class LocalGitProber(Prober):
162
 
 
163
 
    def probe_transport(self, transport):
 
154
class LocalGitControlDirFormat(GitControlDirFormat):
 
155
    """The .git directory control format."""
 
156
 
 
157
    @classmethod
 
158
    def _known_formats(self):
 
159
        return set([LocalGitControlDirFormat()])
 
160
 
 
161
    def open(self, transport, _found=None):
 
162
        """Open this directory.
 
163
 
 
164
        """
 
165
        lazy_check_versions()
 
166
        from bzrlib.plugins.git.transportgit import TransportRepo
 
167
        gitrepo = TransportRepo(transport)
 
168
        from bzrlib.plugins.git.dir import LocalGitDir, GitLockableFiles, GitLock
 
169
        lockfiles = GitLockableFiles(transport, GitLock())
 
170
        return LocalGitDir(transport, lockfiles, gitrepo, self)
 
171
 
 
172
    @classmethod
 
173
    def probe_transport(klass, transport):
164
174
        try:
165
175
            if not transport.has_any(['info/refs', '.git/branches',
166
176
                                      'branches']):
172
182
            raise bzr_errors.NotBranchError(path=transport.base)
173
183
        lazy_check_versions()
174
184
        import dulwich
175
 
        from bzrlib.plugins.git.transportgit import TransportRepo
 
185
        format = klass()
176
186
        try:
177
 
            gitrepo = TransportRepo(transport)
 
187
            format.open(transport)
 
188
            return format
178
189
        except dulwich.errors.NotGitRepository, e:
179
190
            raise bzr_errors.NotBranchError(path=transport.base)
180
 
        else:
181
 
            if gitrepo.bare:
182
 
                return BareLocalGitControlDirFormat()
183
 
            else:
184
 
                return LocalGitControlDirFormat()
185
 
 
186
 
 
187
 
class LocalGitControlDirFormat(GitControlDirFormat):
188
 
    """The .git directory control format."""
189
 
 
190
 
    bare = False
191
 
 
192
 
    @classmethod
193
 
    def _known_formats(self):
194
 
        return set([LocalGitControlDirFormat()])
195
 
 
196
 
    def open(self, transport, _found=None):
197
 
        """Open this directory.
198
 
 
199
 
        """
200
 
        lazy_check_versions()
201
 
        from bzrlib.plugins.git.transportgit import TransportRepo
202
 
        gitrepo = TransportRepo(transport)
203
 
        from bzrlib.plugins.git.dir import LocalGitDir, GitLockableFiles, GitLock
204
 
        lockfiles = GitLockableFiles(transport, GitLock())
205
 
        return LocalGitDir(transport, lockfiles, gitrepo, self)
206
 
 
207
 
    @classmethod
208
 
    def probe_transport(klass, transport):
209
 
        prober = LocalGitProber()
210
 
        return prober.probe_transport(transport)
 
191
        raise bzr_errors.NotBranchError(path=transport.base)
211
192
 
212
193
    def get_format_description(self):
213
194
        return "Local Git Repository"
214
195
 
 
196
    def get_format_string(self):
 
197
        return "Local Git Repository"
 
198
 
215
199
    def initialize_on_transport(self, transport):
216
200
        from bzrlib.transport.local import LocalTransport
217
201
 
221
205
                "non-local transports")
222
206
        lazy_check_versions()
223
207
        from dulwich.repo import Repo
224
 
        Repo.init(transport.local_abspath(".").encode(osutils._fs_enc),
225
 
            bare=self.bare)
 
208
        Repo.init(transport.local_abspath(".").encode(osutils._fs_enc))
226
209
        return self.open(transport)
227
210
 
228
211
    def is_supported(self):
229
212
        return True
230
213
 
231
214
 
232
 
class BareLocalGitControlDirFormat(LocalGitControlDirFormat):
233
 
 
234
 
    bare = True
235
 
    supports_workingtrees = False
236
 
 
237
 
    @classmethod
238
 
    def _known_formats(self):
239
 
        return set([RemoteGitControlDirFormat()])
240
 
 
241
 
    def get_format_description(self):
242
 
        return "Local Git Repository (bare)"
243
 
 
244
 
 
245
 
class RemoteGitProber(Prober):
246
 
 
247
 
    def probe_transport(self, transport):
248
 
        url = transport.base
249
 
        if url.startswith('readonly+'):
250
 
            url = url[len('readonly+'):]
251
 
        if (not url.startswith("git://") and not url.startswith("git+")):
252
 
            raise bzr_errors.NotBranchError(transport.base)
253
 
        # little ugly, but works
254
 
        from bzrlib.plugins.git.remote import GitSmartTransport
255
 
        if not isinstance(transport, GitSmartTransport):
256
 
            raise bzr_errors.NotBranchError(transport.base)
257
 
        return RemoteGitControlDirFormat()
258
 
 
259
 
 
260
 
 
261
215
class RemoteGitControlDirFormat(GitControlDirFormat):
262
216
    """The .git directory control format."""
263
217
 
264
 
    supports_workingtrees = False
265
 
 
266
218
    @classmethod
267
219
    def _known_formats(self):
268
220
        return set([RemoteGitControlDirFormat()])
287
239
    @classmethod
288
240
    def probe_transport(klass, transport):
289
241
        """Our format is present if the transport ends in '.not/'."""
290
 
        prober = RemoteGitProber()
291
 
        return prober.probe_transport(transport)
 
242
        url = transport.base
 
243
        if url.startswith('readonly+'):
 
244
            url = url[len('readonly+'):]
 
245
        if (not url.startswith("git://") and not url.startswith("git+")):
 
246
            raise bzr_errors.NotBranchError(transport.base)
 
247
        # little ugly, but works
 
248
        format = klass()
 
249
        from bzrlib.plugins.git.remote import GitSmartTransport
 
250
        if not isinstance(transport, GitSmartTransport):
 
251
            raise bzr_errors.NotBranchError(transport.base)
 
252
        return format
292
253
 
293
254
    def get_format_description(self):
294
255
        return "Remote Git Repository"
295
256
 
 
257
    def get_format_string(self):
 
258
        return "Remote Git Repository"
 
259
 
296
260
    def initialize_on_transport(self, transport):
297
261
        raise bzr_errors.UninitializableFormat(self)
298
262
 
299
263
 
300
 
if has_controldir:
301
 
    ControlDirFormat.register_format(LocalGitControlDirFormat())
302
 
    ControlDirFormat.register_format(BareLocalGitControlDirFormat())
303
 
    ControlDirFormat.register_format(RemoteGitControlDirFormat())
304
 
    ControlDirFormat.register_prober(LocalGitProber)
305
 
    ControlDirFormat.register_prober(RemoteGitProber)
306
 
else:
307
 
    ControlDirFormat.register_control_format(LocalGitControlDirFormat)
308
 
    ControlDirFormat.register_control_format(BareLocalGitControlDirFormat)
309
 
    ControlDirFormat.register_control_format(RemoteGitControlDirFormat)
 
264
ControlDirFormat.register_control_format(LocalGitControlDirFormat)
 
265
ControlDirFormat.register_control_format(RemoteGitControlDirFormat)
310
266
 
311
267
register_transport_proto('git://',
312
268
        help="Access using the Git smart server protocol.")
351
307
repository_network_format_registry.register_lazy('git',
352
308
    'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
353
309
 
354
 
try:
355
 
    from bzrlib.controldir import (
356
 
        network_format_registry as controldir_network_format_registry,
357
 
        )
358
 
except ImportError:
359
 
    from bzrlib.bzrdir import (
360
 
        network_format_registry as controldir_network_format_registry,
361
 
        )
362
 
controldir_network_format_registry.register('git', GitControlDirFormat)
 
310
from bzrlib.bzrdir import (
 
311
    network_format_registry as bzrdir_network_format_registry,
 
312
    )
 
313
bzrdir_network_format_registry.register('git', GitControlDirFormat)
363
314
 
364
315
send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
365
316
                                   'send_git', 'Git am-style diff format')