/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

Fix some more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
    try:
82
82
        from dulwich import __version__ as dulwich_version
83
83
    except ImportError:
84
 
        raise bzr_errors.DependencyNotPresent("dulwich", "bzr-git: Please install dulwich, https://launchpad.net/dulwich")
 
84
        raise bzr_errors.DependencyNotPresent("dulwich",
 
85
            "bzr-git: Please install dulwich, https://launchpad.net/dulwich")
85
86
    else:
86
87
        if dulwich_version < dulwich_minimum_version:
87
88
            raise bzr_errors.DependencyNotPresent("dulwich", "bzr-git: Dulwich is too old; at least %d.%d.%d is required" % dulwich_minimum_version)
88
89
 
89
 
bzrdir.format_registry.register_lazy('git', 
 
90
bzrdir.format_registry.register_lazy('git',
90
91
    "bzrlib.plugins.git.dir", "LocalGitBzrDirFormat",
91
92
    help='GIT repository.', native=False, experimental=True,
92
93
    )
93
94
 
94
95
from bzrlib.revisionspec import revspec_registry
95
 
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec", 
 
96
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
96
97
    "RevisionSpec_git")
97
98
 
98
99
try:
108
109
 
109
110
    _lock_class = TransportLock
110
111
 
 
112
    colocated_branches = True
 
113
 
111
114
    def is_supported(self):
112
115
        return True
113
116
 
127
130
 
128
131
        """
129
132
        lazy_check_versions()
130
 
        import dulwich
131
133
        # we dont grok readonly - git isn't integrated with transport.
132
 
        url = transport.base
133
 
        if url.startswith('readonly+'):
134
 
            url = url[len('readonly+'):]
135
 
 
136
 
        try:
 
134
        from bzrlib.transport.local import LocalTransport
 
135
        if isinstance(transport, LocalTransport):
 
136
            import dulwich
137
137
            gitrepo = dulwich.repo.Repo(transport.local_abspath(".").encode(osutils._fs_enc))
138
 
        except bzr_errors.NotLocalUrl:
139
 
            raise bzr_errors.NotBranchError(path=transport.base)
 
138
        else:
 
139
            from bzrlib.plugins.git.transportgit import TransportRepo
 
140
            gitrepo = TransportRepo(transport)
140
141
        from bzrlib.plugins.git.dir import LocalGitDir, GitLockableFiles, GitLock
141
142
        lockfiles = GitLockableFiles(transport, GitLock())
142
143
        return LocalGitDir(transport, lockfiles, gitrepo, self)
143
144
 
144
145
    @classmethod
145
146
    def probe_transport(klass, transport):
146
 
        """Our format is present if the transport ends in '.not/'."""
147
 
        from bzrlib.transport.local import LocalTransport
148
 
 
149
 
        if not isinstance(transport, LocalTransport):
150
 
            raise bzr_errors.NotBranchError(path=transport.base)
151
 
 
152
 
        # This should quickly filter out most things that are not 
153
 
        # git repositories, saving us the trouble from loading dulwich.
154
 
        if not transport.has(".git") and not transport.has("objects"):
155
 
            raise bzr_errors.NotBranchError(path=transport.base)
156
 
 
 
147
        try:
 
148
            if not (transport.has('info/refs') or 
 
149
                    transport.has('.git/branches') or 
 
150
                    transport.has('branches')):
 
151
                raise bzr_errors.NotBranchError(path=transport.base)
 
152
        except bzr_errors.NoSuchFile:
 
153
            raise bzr_errors.NotBranchError(path=transport.base)
 
154
        from bzrlib import urlutils
 
155
        if urlutils.split(transport.base)[1] == ".git":
 
156
            raise bzr_errors.NotBranchError(path=transport.base)
157
157
        lazy_check_versions()
158
158
        import dulwich
159
159
        format = klass()
179
179
                "non-local transports")
180
180
        lazy_check_versions()
181
181
        from dulwich.repo import Repo
182
 
        Repo.create(transport.local_abspath(".").encode(osutils._fs_enc))
 
182
        Repo.init(transport.local_abspath(".").encode(osutils._fs_enc))
183
183
        return self.open(transport)
184
184
 
185
185
    def is_supported(self):
201
201
        url = transport.base
202
202
        if url.startswith('readonly+'):
203
203
            url = url[len('readonly+'):]
204
 
        if (not url.startswith("git://") and 
205
 
            not url.startswith("git+")):
 
204
        if (not url.startswith("git://") and not url.startswith("git+")):
206
205
            raise bzr_errors.NotBranchError(transport.base)
207
206
        from bzrlib.plugins.git.remote import RemoteGitDir, GitSmartTransport
208
207
        if not isinstance(transport, GitSmartTransport):
217
216
        url = transport.base
218
217
        if url.startswith('readonly+'):
219
218
            url = url[len('readonly+'):]
220
 
        if (not url.startswith("git://") and 
221
 
            not url.startswith("git+")):
 
219
        if (not url.startswith("git://") and not url.startswith("git+")):
222
220
            raise bzr_errors.NotBranchError(transport.base)
223
221
        # little ugly, but works
224
222
        format = klass()
240
238
bzrdir.BzrDirFormat.register_control_format(LocalGitBzrDirFormat)
241
239
bzrdir.BzrDirFormat.register_control_format(RemoteGitBzrDirFormat)
242
240
 
243
 
register_transport_proto('git://', 
 
241
register_transport_proto('git://',
244
242
        help="Access using the Git smart server protocol.")
245
 
register_transport_proto('git+ssh://', 
 
243
register_transport_proto('git+ssh://',
246
244
        help="Access using the Git smart server protocol over SSH.")
247
245
 
248
246
register_lazy_transport("git://", 'bzrlib.plugins.git.remote',
250
248
register_lazy_transport("git+ssh://", 'bzrlib.plugins.git.remote',
251
249
                        'SSHGitSmartTransport')
252
250
 
253
 
foreign_vcs_registry.register_lazy("git", 
 
251
foreign_vcs_registry.register_lazy("git",
254
252
    "bzrlib.plugins.git.mapping", "foreign_git", "Stupid content tracker")
255
253
 
256
254
plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
257
 
plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"], 
 
255
plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"],
258
256
    "bzrlib.plugins.git.commands")
 
257
plugin_cmds.register_lazy("cmd_git_refs", [], "bzrlib.plugins.git.commands")
 
258
plugin_cmds.register_lazy("cmd_git_apply", [], "bzrlib.plugins.git.commands")
259
259
 
260
260
def update_stanza(rev, stanza):
261
261
    mapping = getattr(rev, "mapping", None)
270
270
 
271
271
from bzrlib.transport import transport_server_registry
272
272
transport_server_registry.register_lazy('git',
273
 
    'bzrlib.plugins.git.server', 
 
273
    'bzrlib.plugins.git.server',
274
274
    'serve_git',
275
275
    'Git Smart server protocol over TCP. (default port: 9418)')
276
276
 
277
277
 
278
278
from bzrlib.repository import network_format_registry as repository_network_format_registry
279
 
repository_network_format_registry.register_lazy('git', 
 
279
repository_network_format_registry.register_lazy('git',
280
280
    'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
281
281
 
282
282
from bzrlib.bzrdir import network_format_registry as bzrdir_network_format_registry
292
292
send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
293
293
                                   'send_git', 'Git am-style diff format')
294
294
 
 
295
try:
 
296
    from bzrlib.diff import format_registry as diff_format_registry
 
297
except ImportError:
 
298
    pass
 
299
else:
 
300
    diff_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
 
301
        'GitDiffTree', 'Git am-style diff format')
 
302
 
295
303
def test_suite():
296
304
    from bzrlib.plugins.git import tests
297
305
    return tests.test_suite()