/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

Don't modify dictionary during iteration.

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",
109
117
 
110
118
    _lock_class = TransportLock
111
119
 
 
120
    colocated_branches = True
 
121
 
 
122
    def __eq__(self, other):
 
123
        return type(self) == type(other)
 
124
 
112
125
    def is_supported(self):
113
126
        return True
114
127
 
128
141
 
129
142
        """
130
143
        lazy_check_versions()
131
 
        # we dont grok readonly - git isn't integrated with transport.
132
 
        from bzrlib.transport.local import LocalTransport
133
 
        if isinstance(transport, LocalTransport):
134
 
            import dulwich
135
 
            gitrepo = dulwich.repo.Repo(transport.local_abspath(".").encode(osutils._fs_enc))
136
 
        else:
137
 
            from bzrlib.plugins.git.transportgit import TransportRepo
138
 
            gitrepo = TransportRepo(transport)
 
144
        from bzrlib.plugins.git.transportgit import TransportRepo
 
145
        gitrepo = TransportRepo(transport)
139
146
        from bzrlib.plugins.git.dir import LocalGitDir, GitLockableFiles, GitLock
140
147
        lockfiles = GitLockableFiles(transport, GitLock())
141
148
        return LocalGitDir(transport, lockfiles, gitrepo, self)
143
150
    @classmethod
144
151
    def probe_transport(klass, transport):
145
152
        try:
146
 
            if not (transport.has('info/refs') or 
147
 
                    transport.has('.git/branches') or 
148
 
                    transport.has('branches')):
 
153
            if not transport.has_any(['info/refs', '.git/branches',
 
154
                                      'branches']):
149
155
                raise bzr_errors.NotBranchError(path=transport.base)
150
156
        except bzr_errors.NoSuchFile:
151
157
            raise bzr_errors.NotBranchError(path=transport.base)
252
258
plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
253
259
plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"],
254
260
    "bzrlib.plugins.git.commands")
 
261
plugin_cmds.register_lazy("cmd_git_refs", [], "bzrlib.plugins.git.commands")
 
262
plugin_cmds.register_lazy("cmd_git_apply", [], "bzrlib.plugins.git.commands")
255
263
 
256
264
def update_stanza(rev, stanza):
257
265
    mapping = getattr(rev, "mapping", None)
271
279
    'Git Smart server protocol over TCP. (default port: 9418)')
272
280
 
273
281
 
274
 
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
    )
275
285
repository_network_format_registry.register_lazy('git',
276
286
    'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
277
287
 
278
 
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
    )
279
291
bzrdir_network_format_registry.register('git', GitBzrDirFormat)
280
292
 
281
 
 
282
 
def get_rich_root_format(stacked=False):
283
 
    if stacked:
284
 
        return bzrdir.format_registry.make_bzrdir("1.9-rich-root")
285
 
    else:
286
 
        return bzrdir.format_registry.make_bzrdir("default-rich-root")
287
 
 
288
293
send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
289
294
                                   'send_git', 'Git am-style diff format')
290
295
 
 
296
try:
 
297
    from bzrlib.diff import format_registry as diff_format_registry
 
298
except ImportError:
 
299
    pass
 
300
else:
 
301
    diff_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
 
302
        'GitDiffTree', 'Git am-style diff format')
 
303
 
291
304
def test_suite():
292
305
    from bzrlib.plugins.git import tests
293
306
    return tests.test_suite()