1941
1943
converter = CopyConverter(self.target_format.repository_format)
1942
1944
converter.convert(repo, pb)
1943
1945
return to_convert
1948
class BzrDirFormatInfo(object):
1950
def __init__(self, native, deprecated):
1951
self.deprecated = deprecated
1952
self.native = native
1955
class BzrDirFormatRegistry(registry.Registry):
1956
"""Registry of user-selectable BzrDir subformats.
1958
Differs from BzrDirFormat._control_formats in that it provides sub-formats,
1959
e.g. BzrDirMeta1 with weave repository. Also, it's more user-oriented.
1962
def register_metadir(self, key, repo, help, native=True, deprecated=False):
1963
"""Register a metadir subformat.
1965
repo is the repository format name as a string.
1967
# This should be expanded to support setting WorkingTree and Branch
1968
# formats, once BzrDirMetaFormat1 supports that.
1970
import bzrlib.repository
1971
repo_format = getattr(bzrlib.repository, repo)
1972
bd = BzrDirMetaFormat1()
1973
bd.repository_format = repo_format()
1975
self.register(key, helper, help, native, deprecated)
1977
def register(self, key, factory, help, native=True, deprecated=False):
1978
"""Register a BzrDirFormat factory.
1980
The factory must be a callable that takes one parameter: the key.
1981
It must produce an instance of the BzrDirFormat when called.
1983
This function mainly exists to prevent the info object from being
1986
registry.Registry.register(self, key, factory, help,
1987
BzrDirFormatInfo(native, deprecated))
1989
def register_lazy(self, key, module_name, member_name, help, native=True,
1991
registry.Registry.register_lazy(self, key, module_name, member_name,
1992
help, BzrDirFormatInfo(native, deprecated))
1994
def set_default(self, key):
1995
"""Set the 'default' key to be a clone of the supplied key.
1997
This method must be called once and only once.
1999
registry.Registry.register(self, 'default', self.get(key),
2000
self.get_help(key), info=self.get_info(key))
2002
def make_bzrdir(self, key):
2003
return self.get(key)()
2005
def help_topic(self, topic):
2006
output = textwrap.dedent("""\
2007
Bazaar directory formats
2008
------------------------
2010
These formats can be used for creating branches, working trees, and
2014
default_help = self.get_help('default')
2016
for key in self.keys():
2017
if key == 'default':
2019
help = self.get_help(key)
2020
if help == default_help:
2021
default_realkey = key
2023
help_pairs.append((key, help))
2025
def wrapped(key, help, info):
2027
help = '(native) ' + help
2028
return ' %s:\n%s\n\n' % (key,
2029
textwrap.fill(help, initial_indent=' ',
2030
subsequent_indent=' '))
2031
output += wrapped('%s/default' % default_realkey, default_help,
2032
self.get_info('default'))
2033
deprecated_pairs = []
2034
for key, help in help_pairs:
2035
info = self.get_info(key)
2037
deprecated_pairs.append((key, help))
2039
output += wrapped(key, help, info)
2040
if len(deprecated_pairs) > 0:
2041
output += "Deprecated formats\n------------------\n\n"
2042
for key, help in deprecated_pairs:
2043
info = self.get_info(key)
2044
output += wrapped(key, help, info)
2049
format_registry = BzrDirFormatRegistry()
2050
format_registry.register('weave', BzrDirFormat6,
2051
'Pre-0.8 format. Slower than knit and does not'
2052
' support checkouts or shared repositories.', deprecated=True)
2053
format_registry.register_metadir('knit', 'RepositoryFormatKnit1',
2054
'Format using knits. Recommended.')
2055
format_registry.set_default('knit')
2056
format_registry.register_metadir('metaweave', 'RepositoryFormat7',
2057
'Transitional format in 0.8. Slower than knit.',
2059
format_registry.register_metadir('experimental-knit2', 'RepositoryFormatKnit2',
2060
'Experimental successor to knit. Use at your own risk.')