Rev 4076: Audit and make sure we are registering network_name's as factories, not instances. in http://people.ubuntu.com/~robertc/baz2.0/pending/network-name.factories

Robert Collins robertc at robertcollins.net
Tue Mar 3 21:12:31 GMT 2009


At http://people.ubuntu.com/~robertc/baz2.0/pending/network-name.factories

------------------------------------------------------------
revno: 4076
revision-id: robertc at robertcollins.net-20090303211206-cuzsauuklqtg4389
parent: pqm at pqm.ubuntu.com-20090303085413-35seprvnu885xorz
committer: Robert Collins <robertc at robertcollins.net>
branch nick: network-name.factories
timestamp: Wed 2009-03-04 08:12:06 +1100
message:
  Audit and make sure we are registering network_name's as factories, not instances.
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2009-03-03 05:50:55 +0000
+++ b/bzrlib/branch.py	2009-03-03 21:12:06 +0000
@@ -1275,8 +1275,9 @@
     def register_format(klass, format):
         """Register a metadir format."""
         klass._formats[format.get_format_string()] = format
-        # Metadir formats have a network name of their format string.
-        network_format_registry.register(format.get_format_string(), format)
+        # Metadir formats have a network name of their format string, and get
+        # registered as class factories.
+        network_format_registry.register(format.get_format_string(), format.__class__)
 
     @classmethod
     def set_default_format(klass, format):
@@ -1730,7 +1731,7 @@
 _legacy_formats = [BzrBranchFormat4(),
     ]
 network_format_registry.register(
-    _legacy_formats[0].network_name(), _legacy_formats[0])
+    _legacy_formats[0].network_name(), _legacy_formats[0].__class__)
 
 
 class BzrBranch(Branch):

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2009-03-03 05:50:55 +0000
+++ b/bzrlib/bzrdir.py	2009-03-03 21:12:06 +0000
@@ -1832,7 +1832,7 @@
     def register_format(klass, format):
         klass._formats[format.get_format_string()] = format
         # bzr native formats have a network name of their format string.
-        network_format_registry.register(format.get_format_string(), format)
+        network_format_registry.register(format.get_format_string(), format.__class__)
 
     @classmethod
     def register_control_format(klass, format):

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2009-03-03 07:22:25 +0000
+++ b/bzrlib/remote.py	2009-03-03 21:12:06 +0000
@@ -155,8 +155,7 @@
         if len(response) != 3:
             raise errors.UnexpectedSmartServerResponse(response)
         control_name, repo_name, branch_name = response
-        # ICK: perhaps change these registries to be factories only?
-        format = bzrdir.network_format_registry.get(control_name).__class__()
+        format = bzrdir.network_format_registry.get(control_name)
         if repo_name:
             format.repository_format = repository.network_format_registry.get(
                 repo_name)




More information about the bazaar-commits mailing list