Comment 2 for bug 132376

Revision history for this message
John A Meinel (jameinel) wrote :

Looking at the code, all of the registries at least have the concept of a default. Most code paths just use the default metadir.

Robert fixed this for repositories by making the definition a bit circular:
RepositoryFormat:
    @classmethod
    def get_default_format(klass):
        """Return the current default format."""
        from bzrlib import bzrdir
        return bzrdir.format_registry.make_bzrdir('default').repository_format

And
BzrDirMetaFormat1:
    def __return_repository_format(self):
        """Circular import protection."""
        if getattr(self, '_repository_format', None):
            return self._repository_format
        from bzrlib.repository import RepositoryFormat
        return RepositoryFormat.get_default_format()

    def __set_repository_format(self, value):
        """Allow changing the repository format for metadir formats."""
        self._repository_format = value

    repository_format = property(__return_repository_format, __set_repository_format)

There is also
BzrDirFormatRegistry:
    def set_default_repository(self, key):
        """Set the FormatRegistry default and Repository default.

        This is a transitional method while Repository.set_default_format
        is deprecated.
        """
        if 'default' in self:
            self.remove('default')
        self.set_default(key)
        format = self.get('default')()

^- This is a bit confusing to me, since 'key' here should be talking about a repository (by the function name) but would have to be describing a bzrdir format, since it is setting self.set_default(key). Also, is the last line just to ensure that the format was properly registered?