~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Martin Pool
  • Date: 2007-01-24 11:20:17 UTC
  • mto: This revision was merged to the branch mainline in revision 2244.
  • Revision ID: mbp@sourcefrog.net-20070124112017-mp52x60whw4llr43
change to using external Repository format registry

Show diffs side-by-side

added added

removed removed

Lines of Context:
1136
1136
                                 committer, revprops, revision_id)
1137
1137
 
1138
1138
 
 
1139
class RepositoryFormatRegistry(registry.Registry):
 
1140
    """Registry of RepositoryFormats.
 
1141
    """
 
1142
    
 
1143
 
 
1144
format_registry = RepositoryFormatRegistry()
 
1145
"""Registry of formats, indexed by their identifying format string."""
 
1146
 
 
1147
 
1139
1148
class RepositoryFormat(object):
1140
1149
    """A repository format.
1141
1150
 
1160
1169
    parameterisation.
1161
1170
    """
1162
1171
 
1163
 
    _registry = registry.Registry()
1164
 
    """Registry of formats, indexed by their identifying format string."""
1165
 
 
1166
1172
    def __str__(self):
1167
1173
        return "<%s>" % self.__class__.__name__
1168
1174
 
1177
1183
        try:
1178
1184
            transport = a_bzrdir.get_repository_transport(None)
1179
1185
            format_string = transport.get("format").read()
1180
 
            return klass._registry.get(format_string)
 
1186
            return format_registry.get(format_string)
1181
1187
        except errors.NoSuchFile:
1182
1188
            raise errors.NoRepositoryPresent(a_bzrdir)
1183
1189
        except KeyError:
1184
1190
            raise errors.UnknownFormatError(format=format_string)
1185
1191
 
1186
1192
    @classmethod
1187
 
    def register_format(klass, format):
1188
 
        klass._registry.register(format.get_format_string(), format)
1189
 
 
1190
 
    @classmethod
1191
1193
    @deprecated_method(symbol_versioning.zero_fourteen)
1192
1194
    def set_default_format(klass, format):
1193
1195
        klass._set_default_format(format)
1198
1200
 
1199
1201
        The format must already be registered.
1200
1202
        """
1201
 
        klass._registry.default_key = format.get_format_string()
 
1203
        format_registry.default_key = format.get_format_string()
 
1204
 
 
1205
    @classmethod
 
1206
    def register_format(klass, format):
 
1207
        format_registry.register(format.get_format_string(), format)
1202
1208
 
1203
1209
    @classmethod
1204
1210
    def unregister_format(klass, format):
1205
 
        klass._registry.remove(format.get_format_string())
 
1211
        format_registry.remove(format.get_format_string())
1206
1212
    
1207
1213
    @classmethod
1208
1214
    def get_default_format(klass):
1209
1215
        """Return the current default format."""
1210
 
        return klass._registry.get(klass._registry.default_key)
 
1216
        return format_registry.get(format_registry.default_key)
1211
1217
 
1212
1218
    def _get_control_store(self, repo_transport, control_files):
1213
1219
        """Return the control store for this repository."""