/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

Rely less on command-line git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import bzrlib
28
28
import bzrlib.api
29
 
 
30
 
# versions ending in 'exp' mean experimental mappings
31
 
# versions ending in 'dev' mean development version
32
 
# versions ending in 'final' mean release (well tested, etc)
33
 
version_info = (0, 3, 3, 'dev', 0)
34
 
 
35
 
if version_info[3] == 'final':
36
 
    version_string = '%d.%d.%d' % version_info[:3]
37
 
else:
38
 
    version_string = '%d.%d.%d%s%d' % version_info
39
 
__version__ = version_string
40
 
 
41
 
MINIMUM_DULWICH_VERSION = (0, 3, 1)
42
 
COMPATIBLE_BZR_VERSIONS = [(1, 14, 0), (1, 15, 0)]
43
 
 
44
 
bzrlib.api.require_any_api(bzrlib, COMPATIBLE_BZR_VERSIONS)
45
 
 
46
 
 
47
29
from bzrlib import (
48
30
    bzrdir,
49
31
    errors as bzr_errors,
70
52
    )
71
53
 
72
54
 
 
55
# versions ending in 'exp' mean experimental mappings
 
56
# versions ending in 'dev' mean development version
 
57
# versions ending in 'final' mean release (well tested, etc)
 
58
version_info = (0, 2, 2, 'dev', 0)
 
59
 
 
60
if version_info[3] == 'final':
 
61
    version_string = '%d.%d.%d' % version_info[:3]
 
62
else:
 
63
    version_string = '%d.%d.%d%s%d' % version_info
 
64
__version__ = version_string
 
65
 
 
66
MINIMUM_DULWICH_VERSION = (0, 2, 2)
 
67
COMPATIBLE_BZR_VERSIONS = [(1, 14, 0), (1, 15, 0)]
 
68
 
73
69
if getattr(sys, "frozen", None):
74
70
    # allow import additional libs from ./_lib for bzr.exe only
75
71
    sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), '_lib')))
88
84
        if dulwich_version < MINIMUM_DULWICH_VERSION:
89
85
            raise ImportError("bzr-git: Dulwich is too old; at least %d.%d.%d is required" % MINIMUM_DULWICH_VERSION)
90
86
 
 
87
bzrlib.api.require_any_api(bzrlib, COMPATIBLE_BZR_VERSIONS)
 
88
 
91
89
bzrdir.format_registry.register_lazy('git', 
92
90
    "bzrlib.plugins.git.dir", "LocalGitBzrDirFormat",
93
91
    help='GIT repository.', native=False, experimental=True,
104
102
    def is_supported(self):
105
103
        return True
106
104
 
107
 
    def network_name(self):
108
 
        return "git"
109
 
 
110
105
 
111
106
class LocalGitBzrDirFormat(GitBzrDirFormat):
112
107
    """The .git directory control format."""
216
211
        from bzrlib.plugins.git.remote import GitSmartTransport
217
212
        if not isinstance(transport, GitSmartTransport):
218
213
            raise bzr_errors.NotBranchError(transport.base)
219
 
        return format
 
214
        # The only way to know a path exists and contains a valid repository 
 
215
        # is to do a request against it:
 
216
        try:
 
217
            transport.fetch_pack(lambda x: [], None, lambda x: None, 
 
218
                                 lambda x: mutter("git: %s" % x))
 
219
        except errors.git_errors.GitProtocolError:
 
220
            raise bzr_errors.NotBranchError(path=transport.base)
 
221
        else:
 
222
            return format
 
223
        raise bzr_errors.NotBranchError(path=transport.base)
220
224
 
221
225
    def get_format_description(self):
222
226
        return "Remote Git Repository"
244
248
foreign_vcs_registry.register_lazy("git", 
245
249
    "bzrlib.plugins.git.mapping", "foreign_git", "Stupid content tracker")
246
250
 
 
251
plugin_cmds.register_lazy("cmd_git_serve", [], "bzrlib.plugins.git.commands")
247
252
plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
248
253
plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"], 
249
254
    "bzrlib.plugins.git.commands")
258
263
if rio_hooks is not None:
259
264
    rio_hooks.install_named_hook('revision', update_stanza, None)
260
265
 
261
 
 
262
 
try:
263
 
    from bzrlib.transport import transport_server_registry
264
 
except ImportError:
265
 
    pass
266
 
else:
267
 
    transport_server_registry.register_lazy('git',
268
 
        'bzrlib.plugins.git.server', 
269
 
        'serve_git',
270
 
        'Git Smart server protocol over TCP. (default port: 9418)')
271
 
 
272
 
 
273
 
from bzrlib.repository import network_format_registry as repository_network_format_registry
274
 
repository_network_format_registry.register_lazy('git', 
275
 
    'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
276
 
 
277
 
from bzrlib.bzrdir import network_format_registry as bzrdir_network_format_registry
278
 
bzrdir_network_format_registry.register('git', GitBzrDirFormat)
279
 
 
280
 
 
281
266
def get_rich_root_format(stacked=False):
282
267
    if stacked:
283
268
        return bzrdir.format_registry.make_bzrdir("1.9-rich-root")