~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Andrew Bennetts
  • Date: 2009-02-10 05:44:04 UTC
  • mto: (4017.3.1 push.roundtrips)
  • mto: This revision was merged to the branch mainline in revision 4022.
  • Revision ID: andrew.bennetts@canonical.com-20090210054404-tej9hra1kpom9fc2
Add network_name() to RepositoryFormat.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2191
2191
class RepositoryFormatRegistry(registry.Registry):
2192
2192
    """Registry of RepositoryFormats."""
2193
2193
 
 
2194
    def __init__(self, other_registry=None):
 
2195
        registry.Registry.__init__(self)
 
2196
        self._other_registry = other_registry
 
2197
 
 
2198
    def register_lazy(self, key, module_name, member_name,
 
2199
                      help=None, info=None,
 
2200
                      override_existing=False):
 
2201
        registry.Registry.register_lazy(self, key, module_name, member_name,
 
2202
                help=help, info=info, override_existing=override_existing)
 
2203
        if self._other_registry is not None:
 
2204
            self._other_registry.register_lazy(key, module_name, member_name,
 
2205
                help=help, info=info, override_existing=override_existing)
 
2206
 
2194
2207
    def get(self, format_string):
2195
2208
        r = registry.Registry.get(self, format_string)
2196
2209
        if callable(r):
2198
2211
        return r
2199
2212
    
2200
2213
 
2201
 
format_registry = RepositoryFormatRegistry()
 
2214
network_format_registry = RepositoryFormatRegistry()
 
2215
"""Registry of formats indexed by their network name."""
 
2216
 
 
2217
 
 
2218
format_registry = RepositoryFormatRegistry(network_format_registry)
2202
2219
"""Registry of formats, indexed by their identifying format string.
2203
2220
 
2204
2221
This can contain either format instances themselves, or classes/factories that
2397
2414
        finally:
2398
2415
            control_files.unlock()
2399
2416
 
2400
 
 
2401
 
# formats which have no format string are not discoverable
2402
 
# and not independently creatable, so are not registered.  They're 
 
2417
    def network_name(self):
 
2418
        """Metadir formats have matching disk and network format strings."""
 
2419
        return self.get_format_string()
 
2420
 
 
2421
 
 
2422
# Pre-0.8 formats that don't have a disk format string, but do have a network
 
2423
# name are just registered in network_format_registry.
 
2424
network_format_registry.register_lazy(
 
2425
    "Bazaar-NG branch, format 5\n",
 
2426
    'bzrlib.repofmt.weaverepo',
 
2427
    'RepositoryFormat5',
 
2428
)
 
2429
network_format_registry.register_lazy(
 
2430
    "Bazaar-NG branch, format 6\n",
 
2431
    'bzrlib.repofmt.weaverepo',
 
2432
    'RepositoryFormat6',
 
2433
)
 
2434
 
 
2435
# formats which have no format string are not discoverable or independently
 
2436
# creatable on disk, so are not registered in format_registry.  They're 
2403
2437
# all in bzrlib.repofmt.weaverepo now.  When an instance of one of these is
2404
2438
# needed, it's constructed directly by the BzrDir.  Non-native formats where
2405
2439
# the repository is not separately opened are similar.