~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Robert Collins
  • Date: 2009-02-23 05:12:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4038.
  • Revision ID: robertc@robertcollins.net-20090223051205-92ypm6chik138tpy
Add a BranchFormat.network_name() method as preparation for creating branches via RPC calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
from bzrlib.testament import Testament
48
48
""")
49
49
 
50
 
from bzrlib import registry
51
50
from bzrlib.decorators import needs_read_lock, needs_write_lock
52
51
from bzrlib.inter import InterObject
53
52
from bzrlib.inventory import Inventory, InventoryDirectory, ROOT_ID
 
53
from bzrlib import registry
54
54
from bzrlib.symbol_versioning import (
55
55
        deprecated_method,
56
56
        one_one,
2207
2207
            control_files)
2208
2208
 
2209
2209
 
2210
 
class RepositoryFormatRegistry(registry.Registry):
2211
 
    """Registry of RepositoryFormats."""
2212
 
 
2213
 
    def __init__(self, other_registry=None):
2214
 
        registry.Registry.__init__(self)
2215
 
        self._other_registry = other_registry
2216
 
 
2217
 
    def register_lazy(self, key, module_name, member_name,
2218
 
                      help=None, info=None,
2219
 
                      override_existing=False):
2220
 
        # Overridden to allow capturing registrations to two seperate
2221
 
        # registries in a single call.
2222
 
        registry.Registry.register_lazy(self, key, module_name, member_name,
2223
 
                help=help, info=info, override_existing=override_existing)
2224
 
        if self._other_registry is not None:
2225
 
            self._other_registry.register_lazy(key, module_name, member_name,
2226
 
                help=help, info=info, override_existing=override_existing)
2227
 
 
2228
 
    def get(self, format_string):
2229
 
        r = registry.Registry.get(self, format_string)
2230
 
        if callable(r):
2231
 
            r = r()
2232
 
        return r
2233
 
    
2234
 
 
2235
 
network_format_registry = RepositoryFormatRegistry()
 
2210
network_format_registry = registry.FormatRegistry()
2236
2211
"""Registry of formats indexed by their network name.
2237
2212
 
2238
2213
The network name for a repository format is an identifier that can be used when
2241
2216
"""
2242
2217
 
2243
2218
 
2244
 
format_registry = RepositoryFormatRegistry(network_format_registry)
 
2219
format_registry = registry.FormatRegistry(network_format_registry)
2245
2220
"""Registry of formats, indexed by their BzrDirMetaFormat format string.
2246
2221
 
2247
2222
This can contain either format instances themselves, or classes/factories that