/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-15 15:11:31 UTC
  • mfrom: (2230.3.55 branch6)
  • Revision ID: pqm@pqm.ubuntu.com-20070215151131-1f2ce67d76e40200
Provide new branch6 format

Show diffs side-by-side

added added

removed removed

Lines of Context:
925
925
 
926
926
    def create_branch(self):
927
927
        """See BzrDir.create_branch."""
928
 
        from bzrlib.branch import BranchFormat
929
 
        return BranchFormat.get_default_format().initialize(self)
 
928
        return self._format.get_branch_format().initialize(self)
930
929
 
931
930
    def create_repository(self, shared=False):
932
931
        """See BzrDir.create_repository."""
1011
1010
                return True
1012
1011
        except errors.NoRepositoryPresent:
1013
1012
            pass
 
1013
        try:
 
1014
            if not isinstance(self.open_branch()._format,
 
1015
                              format.get_branch_format().__class__):
 
1016
                # the repository needs an upgrade.
 
1017
                return True
 
1018
        except errors.NotBranchError:
 
1019
            pass
1014
1020
        # currently there are no other possible conversions for meta1 formats.
1015
1021
        return False
1016
1022
 
1439
1445
 
1440
1446
    _lock_class = lockdir.LockDir
1441
1447
 
 
1448
    def __init__(self):
 
1449
        self._branch_format = None
 
1450
 
 
1451
    def get_branch_format(self):
 
1452
        if self._branch_format is None:
 
1453
            from bzrlib.branch import BranchFormat
 
1454
            self._branch_format = BranchFormat.get_default_format()
 
1455
        return self._branch_format
 
1456
 
 
1457
    def set_branch_format(self, format):
 
1458
        self._branch_format = format
 
1459
 
1442
1460
    def get_converter(self, format=None):
1443
1461
        """See BzrDirFormat.get_converter()."""
1444
1462
        if format is None:
1970
1988
                self.pb.note('starting repository conversion')
1971
1989
                converter = CopyConverter(self.target_format.repository_format)
1972
1990
                converter.convert(repo, pb)
 
1991
        try:
 
1992
            branch = self.bzrdir.open_branch()
 
1993
        except errors.NotBranchError:
 
1994
            pass
 
1995
        else:
 
1996
            # Avoid circular imports
 
1997
            from bzrlib import branch as _mod_branch
 
1998
            if (branch._format.__class__ is _mod_branch.BzrBranchFormat5 and
 
1999
                self.target_format.get_branch_format().__class__ is
 
2000
                _mod_branch.BzrBranchFormat6):
 
2001
                branch_converter = _mod_branch.Converter5to6()
 
2002
                branch_converter.convert(branch)
1973
2003
        return to_convert
1974
2004
 
1975
2005
 
1987
2017
    e.g. BzrDirMeta1 with weave repository.  Also, it's more user-oriented.
1988
2018
    """
1989
2019
 
1990
 
    def register_metadir(self, key, repo, help, native=True, deprecated=False):
 
2020
    def register_metadir(self, key, repo, help, native=True, deprecated=False,
 
2021
                         branch_format=None):
1991
2022
        """Register a metadir subformat.
1992
2023
 
1993
2024
        These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
1999
2030
        # This should be expanded to support setting WorkingTree and Branch
2000
2031
        # formats, once BzrDirMetaFormat1 supports that.
2001
2032
        def helper():
 
2033
            import bzrlib.branch
2002
2034
            mod_name, repo_factory_name = repo.rsplit('.', 1)
2003
2035
            try:
2004
2036
                mod = __import__(mod_name, globals(), locals(),
2013
2045
                    % (repo, mod))
2014
2046
            bd = BzrDirMetaFormat1()
2015
2047
            bd.repository_format = repo_format_class()
 
2048
            if branch_format is not None:
 
2049
                bd.set_branch_format(getattr(bzrlib.branch, branch_format)())
2016
2050
            return bd
2017
2051
        self.register(key, helper, help, native, deprecated)
2018
2052
 
2108
2142
format_registry.register_metadir('knit',
2109
2143
    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
2110
2144
    'Format using knits.  Recommended.',
2111
 
    )
 
2145
    branch_format='BzrBranchFormat5')
2112
2146
format_registry.set_default('knit')
2113
2147
format_registry.register_metadir('metaweave',
2114
2148
    'bzrlib.repofmt.weaverepo.RepositoryFormat7',
2118
2152
format_registry.register_metadir('experimental-knit2',
2119
2153
    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit2',
2120
2154
    'Experimental successor to knit.  Use at your own risk.',
2121
 
    )
 
2155
    branch_format='BzrBranchFormat5')
 
2156
format_registry.register_metadir('experimental-branch6',
 
2157
    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
 
2158
    'Experimental successor to knit.  Use at your own risk.',
 
2159
    branch_format='BzrBranchFormat6')