/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

Avoid invoking git directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 
71
71
if getattr(sys, "frozen", None):
72
72
    # allow import additional libs from ./_lib for bzr.exe only
73
 
    sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), '_lib')))
 
73
    sys.path.append(os.path.normpath(
 
74
        os.path.join(os.path.dirname(__file__), '_lib')))
 
75
 
 
76
 
 
77
def import_dulwich():
 
78
    try:
 
79
        from dulwich import __version__ as dulwich_version
 
80
    except ImportError:
 
81
        raise bzr_errors.DependencyNotPresent("dulwich",
 
82
            "bzr-git: Please install dulwich, https://launchpad.net/dulwich")
 
83
    else:
 
84
        if dulwich_version < dulwich_minimum_version:
 
85
            raise bzr_errors.DependencyNotPresent("dulwich",
 
86
                "bzr-git: Dulwich is too old; at least %d.%d.%d is required" %
 
87
                    dulwich_minimum_version)
 
88
 
74
89
 
75
90
_versions_checked = False
76
91
def lazy_check_versions():
77
92
    global _versions_checked
78
93
    if _versions_checked:
79
94
        return
 
95
    import_dulwich()
80
96
    _versions_checked = True
81
 
    try:
82
 
        from dulwich import __version__ as dulwich_version
83
 
    except ImportError:
84
 
        raise bzr_errors.DependencyNotPresent("dulwich",
85
 
            "bzr-git: Please install dulwich, https://launchpad.net/dulwich")
86
 
    else:
87
 
        if dulwich_version < dulwich_minimum_version:
88
 
            raise bzr_errors.DependencyNotPresent("dulwich", "bzr-git: Dulwich is too old; at least %d.%d.%d is required" % dulwich_minimum_version)
89
97
 
90
98
bzrdir.format_registry.register_lazy('git',
91
99
    "bzrlib.plugins.git.dir", "LocalGitBzrDirFormat",
111
119
 
112
120
    colocated_branches = True
113
121
 
 
122
    def __eq__(self, other):
 
123
        return type(self) == type(other)
 
124
 
114
125
    def is_supported(self):
115
126
        return True
116
127
 
130
141
 
131
142
        """
132
143
        lazy_check_versions()
133
 
        # we dont grok readonly - git isn't integrated with transport.
134
 
        from bzrlib.transport.local import LocalTransport
135
 
        if isinstance(transport, LocalTransport):
136
 
            import dulwich
137
 
            gitrepo = dulwich.repo.Repo(transport.local_abspath(".").encode(osutils._fs_enc))
138
 
        else:
139
 
            from bzrlib.plugins.git.transportgit import TransportRepo
140
 
            gitrepo = TransportRepo(transport)
 
144
        from bzrlib.plugins.git.transportgit import TransportRepo
 
145
        gitrepo = TransportRepo(transport)
141
146
        from bzrlib.plugins.git.dir import LocalGitDir, GitLockableFiles, GitLock
142
147
        lockfiles = GitLockableFiles(transport, GitLock())
143
148
        return LocalGitDir(transport, lockfiles, gitrepo, self)
145
150
    @classmethod
146
151
    def probe_transport(klass, transport):
147
152
        try:
148
 
            if not (transport.has('info/refs') or 
149
 
                    transport.has('.git/branches') or 
150
 
                    transport.has('branches')):
 
153
            if not transport.has_any(['info/refs', '.git/branches',
 
154
                                      'branches']):
151
155
                raise bzr_errors.NotBranchError(path=transport.base)
152
156
        except bzr_errors.NoSuchFile:
153
157
            raise bzr_errors.NotBranchError(path=transport.base)
275
279
    'Git Smart server protocol over TCP. (default port: 9418)')
276
280
 
277
281
 
278
 
from bzrlib.repository import network_format_registry as repository_network_format_registry
 
282
from bzrlib.repository import (
 
283
    network_format_registry as repository_network_format_registry,
 
284
    )
279
285
repository_network_format_registry.register_lazy('git',
280
286
    'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
281
287
 
282
 
from bzrlib.bzrdir import network_format_registry as bzrdir_network_format_registry
 
288
from bzrlib.bzrdir import (
 
289
    network_format_registry as bzrdir_network_format_registry,
 
290
    )
283
291
bzrdir_network_format_registry.register('git', GitBzrDirFormat)
284
292
 
285
 
 
286
 
def get_rich_root_format(stacked=False):
287
 
    if stacked:
288
 
        return bzrdir.format_registry.make_bzrdir("1.9-rich-root")
289
 
    else:
290
 
        return bzrdir.format_registry.make_bzrdir("default-rich-root")
291
 
 
292
293
send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
293
294
                                   'send_git', 'Git am-style diff format')
294
295