Rev 2243: change to using external Repository format registry in file:///home/mbp/bzr/Work/repoformats/

Martin Pool mbp at sourcefrog.net
Wed Jan 24 11:20:18 GMT 2007


------------------------------------------------------------
revno: 2243
revision-id: mbp at sourcefrog.net-20070124112017-mp52x60whw4llr43
parent: mbp at sourcefrog.net-20070124071209-yqiths20n6wxqaqr
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: repoformats
timestamp: Wed 2007-01-24 22:20:17 +1100
message:
  change to using external Repository format registry
modified:
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/tests/repository_implementations/__init__.py __init__.py-20060131092037-9564957a7d4a841b
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2007-01-24 07:12:09 +0000
+++ b/bzrlib/repository.py	2007-01-24 11:20:17 +0000
@@ -1136,6 +1136,15 @@
                                  committer, revprops, revision_id)
 
 
+class RepositoryFormatRegistry(registry.Registry):
+    """Registry of RepositoryFormats.
+    """
+    
+
+format_registry = RepositoryFormatRegistry()
+"""Registry of formats, indexed by their identifying format string."""
+
+
 class RepositoryFormat(object):
     """A repository format.
 
@@ -1160,9 +1169,6 @@
     parameterisation.
     """
 
-    _registry = registry.Registry()
-    """Registry of formats, indexed by their identifying format string."""
-
     def __str__(self):
         return "<%s>" % self.__class__.__name__
 
@@ -1177,17 +1183,13 @@
         try:
             transport = a_bzrdir.get_repository_transport(None)
             format_string = transport.get("format").read()
-            return klass._registry.get(format_string)
+            return format_registry.get(format_string)
         except errors.NoSuchFile:
             raise errors.NoRepositoryPresent(a_bzrdir)
         except KeyError:
             raise errors.UnknownFormatError(format=format_string)
 
     @classmethod
-    def register_format(klass, format):
-        klass._registry.register(format.get_format_string(), format)
-
-    @classmethod
     @deprecated_method(symbol_versioning.zero_fourteen)
     def set_default_format(klass, format):
         klass._set_default_format(format)
@@ -1198,16 +1200,20 @@
 
         The format must already be registered.
         """
-        klass._registry.default_key = format.get_format_string()
+        format_registry.default_key = format.get_format_string()
+
+    @classmethod
+    def register_format(klass, format):
+        format_registry.register(format.get_format_string(), format)
 
     @classmethod
     def unregister_format(klass, format):
-        klass._registry.remove(format.get_format_string())
+        format_registry.remove(format.get_format_string())
     
     @classmethod
     def get_default_format(klass):
         """Return the current default format."""
-        return klass._registry.get(klass._registry.default_key)
+        return format_registry.get(format_registry.default_key)
 
     def _get_control_store(self, repo_transport, control_files):
         """Return the control store for this repository."""

=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py	2007-01-24 07:12:09 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py	2007-01-24 11:20:17 +0000
@@ -24,8 +24,10 @@
 rather than in tests/branch_implementations/*.py.
 """
 
+from bzrlib import (
+    repository,
+    )
 from bzrlib.repository import (_legacy_formats,
-                               RepositoryFormat,
                                RepositoryTestProviderAdapter,
                                )
                             
@@ -47,7 +49,7 @@
         'bzrlib.tests.repository_implementations.test_repository',
         'bzrlib.tests.repository_implementations.test_revision',
         ]
-    all_formats = list(RepositoryFormat._registry.itervalues()) \
+    all_formats = list(repository.format_registry.itervalues()) \
         + _legacy_formats
     adapter = RepositoryTestProviderAdapter(
         default_transport,




More information about the bazaar-commits mailing list