/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

SetĀ supports_full_versioned_files=False.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
from bzrlib import (
46
46
    errors as bzr_errors,
47
 
    osutils,
48
 
    )
49
 
try:
50
 
    from bzrlib.controldir import (
51
 
        ControlDirFormat,
52
 
        ControlDir,
53
 
        Prober,
54
 
        format_registry,
55
 
        )
56
 
except ImportError:
57
 
    # bzr < 2.3
58
 
    from bzrlib.bzrdir import (
59
 
        BzrDirFormat,
60
 
        BzrDir,
61
 
        format_registry,
62
 
        )
63
 
    ControlDir = BzrDir
64
 
    ControlDirFormat = BzrDirFormat
65
 
    Prober = object
66
 
    has_controldir = False
67
 
else:
68
 
    has_controldir = True
 
47
    )
 
48
 
 
49
from bzrlib.controldir import (
 
50
    ControlDirFormat,
 
51
    Prober,
 
52
    format_registry,
 
53
    )
69
54
 
70
55
from bzrlib.foreign import (
71
56
    foreign_vcs_registry,
83
68
from bzrlib.commands import (
84
69
    plugin_cmds,
85
70
    )
86
 
from bzrlib.version_info_formats.format_rio import (
87
 
    RioVersionInfoBuilder,
88
 
    )
89
71
from bzrlib.send import (
90
72
    format_registry as send_format_registry,
91
73
    )
119
101
    _versions_checked = True
120
102
 
121
103
format_registry.register_lazy('git',
122
 
    "bzrlib.plugins.git.dir", "LocalGitControlDirFormat",
 
104
    "bzrlib.plugins.git", "LocalGitControlDirFormat",
123
105
    help='GIT repository.', native=False, experimental=False,
124
106
    )
125
107
 
126
108
format_registry.register_lazy('git-bare',
127
 
    "bzrlib.plugins.git.dir", "BareLocalGitControlDirFormat",
 
109
    "bzrlib.plugins.git", "BareLocalGitControlDirFormat",
128
110
    help='Bare GIT repository (no working tree).', native=False,
129
111
    experimental=False,
130
112
    )
133
115
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
134
116
    "RevisionSpec_git")
135
117
 
136
 
try:
137
 
    from bzrlib.revisionspec import dwim_revspecs
138
 
except ImportError:
139
 
    pass
140
 
else:
 
118
from bzrlib.revisionspec import dwim_revspecs, RevisionSpec_dwim
 
119
if getattr(RevisionSpec_dwim, "append_possible_lazy_revspec", None):
 
120
    RevisionSpec_dwim.append_possible_lazy_revspec(
 
121
        "bzrlib.plugins.git.revspec", "RevisionSpec_git")
 
122
else: # bzr < 2.4
141
123
    from bzrlib.plugins.git.revspec import RevisionSpec_git
142
124
    dwim_revspecs.append(RevisionSpec_git)
143
125
 
147
129
    _lock_class = TransportLock
148
130
 
149
131
    colocated_branches = True
 
132
    fixed_components = True
150
133
 
151
134
    def __eq__(self, other):
152
135
        return type(self) == type(other)
193
176
    def _known_formats(self):
194
177
        return set([LocalGitControlDirFormat()])
195
178
 
 
179
    @property
 
180
    def repository_format(self):
 
181
        from bzrlib.plugins.git.repository import GitRepositoryFormat
 
182
        return GitRepositoryFormat()
 
183
 
 
184
    def get_branch_format(self):
 
185
        from bzrlib.plugins.git.branch import GitBranchFormat
 
186
        return GitBranchFormat()
 
187
 
196
188
    def open(self, transport, _found=None):
197
189
        """Open this directory.
198
190
 
213
205
        return "Local Git Repository"
214
206
 
215
207
    def initialize_on_transport(self, transport):
216
 
        from bzrlib.transport.local import LocalTransport
217
 
 
218
 
        if not isinstance(transport, LocalTransport):
219
 
            raise NotImplementedError(self.initialize,
220
 
                "Can't create Git Repositories/branches on "
221
 
                "non-local transports")
222
208
        lazy_check_versions()
223
 
        from dulwich.repo import Repo
224
 
        Repo.init(transport.local_abspath(".").encode(osutils._fs_enc),
225
 
            bare=self.bare)
 
209
        from bzrlib.plugins.git.transportgit import TransportRepo
 
210
        TransportRepo.init(transport, bare=self.bare)
226
211
        return self.open(transport)
227
212
 
 
213
    def initialize_on_transport_ex(self, transport, use_existing_dir=False,
 
214
        create_prefix=False, force_new_repo=False, stacked_on=None,
 
215
        stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
 
216
        shared_repo=False, vfs_only=False):
 
217
        from bzrlib import trace
 
218
        from bzrlib.bzrdir import CreateRepository
 
219
        from bzrlib.transport import do_catching_redirections
 
220
        def make_directory(transport):
 
221
            transport.mkdir('.')
 
222
            return transport
 
223
        def redirected(transport, e, redirection_notice):
 
224
            trace.note(redirection_notice)
 
225
            return transport._redirected_to(e.source, e.target)
 
226
        try:
 
227
            transport = do_catching_redirections(make_directory, transport,
 
228
                redirected)
 
229
        except bzr_errors.FileExists:
 
230
            if not use_existing_dir:
 
231
                raise
 
232
        except bzr_errors.NoSuchFile:
 
233
            if not create_prefix:
 
234
                raise
 
235
            transport.create_prefix()
 
236
        controldir = self.initialize_on_transport(transport)
 
237
        repository = controldir.open_repository()
 
238
        repository.lock_write()
 
239
        return (repository, controldir, False, CreateRepository(controldir))
 
240
 
228
241
    def is_supported(self):
229
242
        return True
230
243
 
297
310
        raise bzr_errors.UninitializableFormat(self)
298
311
 
299
312
 
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)
 
313
ControlDirFormat.register_format(LocalGitControlDirFormat())
 
314
ControlDirFormat.register_format(BareLocalGitControlDirFormat())
 
315
ControlDirFormat.register_format(RemoteGitControlDirFormat())
 
316
ControlDirFormat.register_prober(LocalGitProber)
 
317
ControlDirFormat.register_prober(RemoteGitProber)
310
318
 
311
319
register_transport_proto('git://',
312
320
        help="Access using the Git smart server protocol.")
332
340
    if mapping is not None and mapping.revid_prefix.startswith("git-"):
333
341
        stanza.add("git-commit", rev.foreign_revid)
334
342
 
335
 
 
336
 
rio_hooks = getattr(RioVersionInfoBuilder, "hooks", None)
337
 
if rio_hooks is not None:
338
 
    rio_hooks.install_named_hook('revision', update_stanza, None)
 
343
try:
 
344
    from bzrlib.hooks import install_lazy_named_hook
 
345
except ImportError: # Compatibility with bzr < 2.4
 
346
    from bzrlib.version_info_formats.format_rio import (
 
347
        RioVersionInfoBuilder,
 
348
        )
 
349
    RioVersionInfoBuilder.hooks.install_named_hook('revision', update_stanza, 
 
350
        "git commits")
 
351
else:
 
352
    install_lazy_named_hook("bzrlib.version_info_formats.format_rio",
 
353
        "RioVersionInfoBuilder.hooks", "revision", update_stanza,
 
354
        "git commits")
339
355
 
340
356
 
341
357
from bzrlib.transport import transport_server_registry
346
362
 
347
363
 
348
364
from bzrlib.repository import (
 
365
    format_registry as repository_format_registry,
349
366
    network_format_registry as repository_network_format_registry,
350
367
    )
351
368
repository_network_format_registry.register_lazy('git',
352
369
    'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
353
370
 
354
371
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
 
        )
 
372
    register_extra_lazy_repository_format = getattr(repository_format_registry,
 
373
        "register_extra_lazy")
 
374
except AttributeError: # bzr < 2.4
 
375
    pass
 
376
else:
 
377
    register_extra_lazy_repository_format('bzrlib.plugins.git.repository',
 
378
        'GitRepositoryFormat')
 
379
 
 
380
from bzrlib.branch import (
 
381
    network_format_registry as branch_network_format_registry,
 
382
    )
 
383
branch_network_format_registry.register_lazy('git',
 
384
    'bzrlib.plugins.git.branch', 'GitBranchFormat')
 
385
 
 
386
try:
 
387
    from bzrlib.branch import (
 
388
        format_registry as branch_format_registry,
 
389
        )
 
390
except ImportError: # bzr < 2.4
 
391
    pass
 
392
else:
 
393
    branch_format_registry.register_extra_lazy(
 
394
        'bzrlib.plugins.git.branch',
 
395
        'GitBranchFormat',
 
396
        )
 
397
 
 
398
try:
 
399
    from bzrlib.workingtree import (
 
400
        format_registry as workingtree_format_registry,
 
401
        )
 
402
except ImportError: # bzr < 2.4
 
403
    pass
 
404
else:
 
405
    workingtree_format_registry.register_extra_lazy(
 
406
        'bzrlib.plugins.git.workingtree',
 
407
        'GitWorkingTreeFormat',
 
408
        )
 
409
 
 
410
from bzrlib.controldir import (
 
411
    network_format_registry as controldir_network_format_registry,
 
412
    )
362
413
controldir_network_format_registry.register('git', GitControlDirFormat)
363
414
 
364
415
send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
368
419
                             'bzrlib.plugins.git.help',
369
420
                             'help_git', 'Using Bazaar with Git')
370
421
 
371
 
try:
372
 
    from bzrlib.diff import format_registry as diff_format_registry
373
 
except ImportError:
374
 
    pass
375
 
else:
376
 
    diff_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
377
 
        'GitDiffTree', 'Git am-style diff format')
 
422
from bzrlib.diff import format_registry as diff_format_registry
 
423
diff_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
 
424
    'GitDiffTree', 'Git am-style diff format')
378
425
 
379
426
def test_suite():
380
427
    from bzrlib.plugins.git import tests