/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

Implement GitRepository.revision_graph_can_have_wrong_parents().

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
 
29
47
from bzrlib import (
30
48
    bzrdir,
31
49
    errors as bzr_errors,
 
50
    osutils,
32
51
    )
33
52
from bzrlib.foreign import (
34
53
    foreign_vcs_registry,
46
65
from bzrlib.trace import (
47
66
    warning,
48
67
    )
49
 
 
50
 
# versions ending in 'exp' mean experimental mappings
51
 
# versions ending in 'dev' mean development version
52
 
# versions ending in 'final' mean release (well tested, etc)
53
 
version_info = (0, 2, 0, 'dev', 0)
54
 
 
55
 
if version_info[3] == 'final':
56
 
    version_string = '%d.%d.%d' % version_info[:3]
57
 
else:
58
 
    version_string = '%d.%d.%d%s%d' % version_info
59
 
__version__ = version_string
60
 
 
61
 
MINIMUM_DULWICH_VERSION = (0, 1, 1)
62
 
COMPATIBLE_BZR_VERSIONS = [(1, 13, 0)]
 
68
from bzrlib.version_info_formats.format_rio import (
 
69
    RioVersionInfoBuilder,
 
70
    )
 
71
 
63
72
 
64
73
if getattr(sys, "frozen", None):
65
74
    # allow import additional libs from ./_lib for bzr.exe only
79
88
        if dulwich_version < MINIMUM_DULWICH_VERSION:
80
89
            raise ImportError("bzr-git: Dulwich is too old; at least %d.%d.%d is required" % MINIMUM_DULWICH_VERSION)
81
90
 
82
 
bzrlib.api.require_any_api(bzrlib, COMPATIBLE_BZR_VERSIONS)
83
 
 
84
91
bzrdir.format_registry.register_lazy('git', 
85
92
    "bzrlib.plugins.git.dir", "LocalGitBzrDirFormat",
86
93
    help='GIT repository.', native=False, experimental=True,
90
97
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec", 
91
98
    "RevisionSpec_git")
92
99
 
 
100
 
93
101
class GitBzrDirFormat(bzrdir.BzrDirFormat):
94
102
    _lock_class = TransportLock
95
103
 
96
104
    def is_supported(self):
97
105
        return True
98
106
 
 
107
    def network_name(self):
 
108
        return "git"
 
109
 
99
110
 
100
111
class LocalGitBzrDirFormat(GitBzrDirFormat):
101
112
    """The .git directory control format."""
115
126
            url = url[len('readonly+'):]
116
127
 
117
128
        try:
118
 
            gitrepo = git.repo.Repo(transport.local_abspath("."))
 
129
            gitrepo = git.repo.Repo(transport.local_abspath(".").encode(osutils._fs_enc))
119
130
        except bzr_errors.NotLocalUrl:
120
131
            raise bzr_errors.NotBranchError(path=transport.base)
121
132
        from bzrlib.plugins.git.dir import LocalGitDir, GitLockableFiles, GitLock
159
170
                "non-local transports")
160
171
 
161
172
        from dulwich.repo import Repo
162
 
        Repo.create(transport.local_abspath(".")) 
 
173
        Repo.create(transport.local_abspath(".").encode(osutils._fs_enc)) 
163
174
        return self.open(transport)
164
175
 
165
176
    def is_supported(self):
205
216
        from bzrlib.plugins.git.remote import GitSmartTransport
206
217
        if not isinstance(transport, GitSmartTransport):
207
218
            raise bzr_errors.NotBranchError(transport.base)
208
 
        # The only way to know a path exists and contains a valid repository 
209
 
        # is to do a request against it:
210
 
        try:
211
 
            transport.fetch_pack(lambda x: [], None, lambda x: None, 
212
 
                                 lambda x: mutter("git: %s" % x))
213
 
        except errors.git_errors.GitProtocolError:
214
 
            raise bzr_errors.NotBranchError(path=transport.base)
215
 
        else:
216
 
            return format
217
 
        raise bzr_errors.NotBranchError(path=transport.base)
 
219
        return format
218
220
 
219
221
    def get_format_description(self):
220
222
        return "Remote Git Repository"
236
238
 
237
239
register_lazy_transport("git://", 'bzrlib.plugins.git.remote',
238
240
                        'TCPGitSmartTransport')
239
 
 
240
241
register_lazy_transport("git+ssh://", 'bzrlib.plugins.git.remote',
241
242
                        'SSHGitSmartTransport')
242
243
 
243
244
foreign_vcs_registry.register_lazy("git", 
244
 
                        "bzrlib.plugins.git.mapping", 
245
 
                        "foreign_git",
246
 
                        "Stupid content tracker")
 
245
    "bzrlib.plugins.git.mapping", "foreign_git", "Stupid content tracker")
247
246
 
248
 
plugin_cmds.register_lazy("cmd_git_serve", [], "bzrlib.plugins.git.commands")
249
247
plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
250
 
 
251
 
def get_rich_root_format():
252
 
    try:
 
248
plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"], 
 
249
    "bzrlib.plugins.git.commands")
 
250
 
 
251
def update_stanza(rev, stanza):
 
252
    mapping = getattr(rev, "mapping", None)
 
253
    if mapping is not None and mapping.revid_prefix.startswith("git-"):
 
254
        stanza.add("git-commit", rev.foreign_revid)
 
255
 
 
256
 
 
257
rio_hooks = getattr(RioVersionInfoBuilder, "hooks", None)
 
258
if rio_hooks is not None:
 
259
    rio_hooks.install_named_hook('revision', update_stanza, None)
 
260
 
 
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
def get_rich_root_format(stacked=False):
 
282
    if stacked:
 
283
        return bzrdir.format_registry.make_bzrdir("1.9-rich-root")
 
284
    else:
253
285
        return bzrdir.format_registry.make_bzrdir("default-rich-root")
254
 
    except KeyError:
255
 
        return bzrdir.format_registry.make_bzrdir("1.9-rich-root")
256
286
 
257
287
def test_suite():
258
288
    from bzrlib.plugins.git import tests