~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Martin Pool
  • Date: 2007-02-06 06:27:24 UTC
  • mto: This revision was merged to the branch mainline in revision 2283.
  • Revision ID: mbp@sourcefrog.net-20070206062724-a5uo1u27jxsal2t0
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo.

Change help for --format to just say 'see help formats'

RepositoryFormat.register_metadir gains an optional parameter for the
module name containing the repository format, and lazily loads from there.

Disable test_interrepository_get_returns_correct_optimiser, because it
seems too brittle.

Remove InterWeaveRepo, these should now just be upgraded.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
45
45
    lockdir,
46
46
    registry,
47
47
    revision as _mod_revision,
48
 
    repository as _mod_repository,
49
48
    symbol_versioning,
50
49
    urlutils,
51
50
    xml4,
873
872
 
874
873
    def open_repository(self):
875
874
        """See BzrDir.open_repository."""
876
 
        from bzrlib.repository import RepositoryFormat4
 
875
        from bzrlib.repofmt.weaverepo import RepositoryFormat4
877
876
        return RepositoryFormat4().open(self, _found=True)
878
877
 
879
878
 
885
884
 
886
885
    def open_repository(self):
887
886
        """See BzrDir.open_repository."""
888
 
        from bzrlib.repository import RepositoryFormat5
 
887
        from bzrlib.repofmt.weaverepo import RepositoryFormat5
889
888
        return RepositoryFormat5().open(self, _found=True)
890
889
 
891
890
    def open_workingtree(self, _unsupported=False):
902
901
 
903
902
    def open_repository(self):
904
903
        """See BzrDir.open_repository."""
905
 
        from bzrlib.repository import RepositoryFormat6
 
904
        from bzrlib.repofmt.weaverepo import RepositoryFormat6
906
905
        return RepositoryFormat6().open(self, _found=True)
907
906
 
908
907
    def open_workingtree(self, _unsupported=False):
1303
1302
 
1304
1303
    def __return_repository_format(self):
1305
1304
        """Circular import protection."""
1306
 
        from bzrlib.repository import RepositoryFormat4
 
1305
        from bzrlib.repofmt.weaverepo import RepositoryFormat4
1307
1306
        return RepositoryFormat4()
1308
1307
    repository_format = property(__return_repository_format)
1309
1308
 
1343
1342
        Except when they are being cloned.
1344
1343
        """
1345
1344
        from bzrlib.branch import BzrBranchFormat4
1346
 
        from bzrlib.repository import RepositoryFormat5
 
1345
        from bzrlib.repofmt.weaverepo import RepositoryFormat5
1347
1346
        from bzrlib.workingtree import WorkingTreeFormat2
1348
1347
        result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1349
1348
        RepositoryFormat5().initialize(result, _internal=True)
1363
1362
 
1364
1363
    def __return_repository_format(self):
1365
1364
        """Circular import protection."""
1366
 
        from bzrlib.repository import RepositoryFormat5
 
1365
        from bzrlib.repofmt.weaverepo import RepositoryFormat5
1367
1366
        return RepositoryFormat5()
1368
1367
    repository_format = property(__return_repository_format)
1369
1368
 
1402
1401
        Except when they are being cloned.
1403
1402
        """
1404
1403
        from bzrlib.branch import BzrBranchFormat4
1405
 
        from bzrlib.repository import RepositoryFormat6
 
1404
        from bzrlib.repofmt.weaverepo import RepositoryFormat6
1406
1405
        from bzrlib.workingtree import WorkingTreeFormat2
1407
1406
        result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1408
1407
        RepositoryFormat6().initialize(result, _internal=True)
1422
1421
 
1423
1422
    def __return_repository_format(self):
1424
1423
        """Circular import protection."""
1425
 
        from bzrlib.repository import RepositoryFormat6
 
1424
        from bzrlib.repofmt.weaverepo import RepositoryFormat6
1426
1425
        return RepositoryFormat6()
1427
1426
    repository_format = property(__return_repository_format)
1428
1427
 
1834
1833
 
1835
1834
    def convert(self, to_convert, pb):
1836
1835
        """See Converter.convert()."""
 
1836
        from bzrlib.repofmt.weaverepo import RepositoryFormat7_instance
1837
1837
        from bzrlib.branch import BzrBranchFormat5
1838
1838
        self.bzrdir = to_convert
1839
1839
        self.pb = pb
1869
1869
        # we hard code the formats here because we are converting into
1870
1870
        # the meta format. The meta format upgrader can take this to a 
1871
1871
        # future format within each component.
1872
 
        self.put_format('repository', _mod_repository.RepositoryFormat7())
 
1872
        self.put_format('repository', RepositoryFormat7_instance)
1873
1873
        for entry in repository_names:
1874
1874
            self.move_entry('repository', entry)
1875
1875
 
1987
1987
    e.g. BzrDirMeta1 with weave repository.  Also, it's more user-oriented.
1988
1988
    """
1989
1989
 
1990
 
    def register_metadir(self, key, repo, help, native=True, deprecated=False):
 
1990
    def register_metadir(self, key, repo, help, native=True, deprecated=False,
 
1991
            repo_module='bzrlib.repository'):
1991
1992
        """Register a metadir subformat.
1992
 
        
1993
 
        repo is the repository format name as a string.
 
1993
 
 
1994
        These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
 
1995
        by the Repository format.
 
1996
 
 
1997
        :param repo: The repository format class name as a string.
 
1998
 
 
1999
        :param repo_module: The module from which the repository class 
 
2000
        should be lazily loaded.  By default this is bzrlib.repository.
1994
2001
        """
1995
2002
        # This should be expanded to support setting WorkingTree and Branch
1996
2003
        # formats, once BzrDirMetaFormat1 supports that.
1997
2004
        def helper():
1998
 
            import bzrlib.repository
1999
 
            repo_format = getattr(bzrlib.repository, repo)
 
2005
            mod = __import__(repo_module, globals(), locals(), [repo])
 
2006
            try:
 
2007
                repo_format_class = getattr(mod, repo)
 
2008
            except AttributeError:
 
2009
                raise AttributeError('no repository format %r in module %r' 
 
2010
                    % (repo, mod))
2000
2011
            bd = BzrDirMetaFormat1()
2001
 
            bd.repository_format = repo_format()
 
2012
            bd.repository_format = repo_format_class()
2002
2013
            return bd
2003
2014
        self.register(key, helper, help, native, deprecated)
2004
2015
 
2098
2109
format_registry.set_default('knit')
2099
2110
format_registry.register_metadir('metaweave', 'RepositoryFormat7',
2100
2111
    'Transitional format in 0.8.  Slower than knit.',
2101
 
    deprecated=True)
 
2112
    deprecated=True,
 
2113
    repo_module='bzrlib.repofmt.weaverepo')
2102
2114
format_registry.register_metadir('experimental-knit2', 'RepositoryFormatKnit2',
2103
2115
    'Experimental successor to knit.  Use at your own risk.')