~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/weave_fmt/bzrdir.py

(jelmer) Use 'development-subtree' format rather than
 'dirstate-with-subtree' in tests. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Weave-era BzrDir formats."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from bzrlib.bzrdir import (
20
22
    BzrDir,
21
23
    BzrDirFormat,
81
83
            stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
82
84
            make_working_trees=make_working_trees, shared_repo=shared_repo)
83
85
 
 
86
    @classmethod
 
87
    def from_string(cls, format_string):
 
88
        if format_string != cls.get_format_string():
 
89
            raise AssertionError("unexpected format string %r" % format_string)
 
90
        return cls()
 
91
 
84
92
 
85
93
class BzrDirFormat5(BzrDirFormatAllInOne):
86
94
    """Bzr control format 5.
98
106
    def __eq__(self, other):
99
107
        return type(self) == type(other)
100
108
 
101
 
    def get_format_string(self):
 
109
    @classmethod
 
110
    def get_format_string(cls):
102
111
        """See BzrDirFormat.get_format_string()."""
103
112
        return "Bazaar-NG branch, format 5\n"
104
113
 
161
170
    def __eq__(self, other):
162
171
        return type(self) == type(other)
163
172
 
164
 
    def get_format_string(self):
 
173
    @classmethod
 
174
    def get_format_string(cls):
165
175
        """See BzrDirFormat.get_format_string()."""
166
176
        return "Bazaar-NG branch, format 6\n"
167
177
 
669
679
    def __eq__(self, other):
670
680
        return type(self) == type(other)
671
681
 
672
 
    def get_format_string(self):
 
682
    @classmethod
 
683
    def get_format_string(cls):
673
684
        """See BzrDirFormat.get_format_string()."""
674
685
        return "Bazaar-NG branch, format 0.0.4\n"
675
686
 
708
719
        return RepositoryFormat4()
709
720
    repository_format = property(__return_repository_format)
710
721
 
 
722
    @classmethod
 
723
    def from_string(cls, format_string):
 
724
        if format_string != cls.get_format_string():
 
725
            raise AssertionError("unexpected format string %r" % format_string)
 
726
        return cls()
 
727
 
711
728
 
712
729
class BzrDirPreSplitOut(BzrDir):
713
730
    """A common class for the all-in-one formats."""
867
884
        return not isinstance(self._format, format.__class__)
868
885
 
869
886
    def open_branch(self, name=None, unsupported=False,
870
 
                    ignore_fallbacks=False):
 
887
                    ignore_fallbacks=False, possible_transports=None):
871
888
        """See BzrDir.open_branch."""
872
889
        from bzrlib.plugins.weave_fmt.branch import BzrBranchFormat4
873
890
        format = BzrBranchFormat4()
874
891
        format.check_support_status(unsupported)
875
 
        return format.open(self, name, _found=True)
 
892
        return format.open(self, name, _found=True,
 
893
            possible_transports=possible_transports)
876
894
 
877
895
    def sprout(self, url, revision_id=None, force_new_repo=False,
878
896
               possible_transports=None, accelerator_tree=None,
909
927
                                        hardlink=hardlink)
910
928
        return result
911
929
 
 
930
    def set_branch_reference(self, target_branch, name=None):
 
931
        from bzrlib.branch import BranchReferenceFormat
 
932
        if name is not None:
 
933
            raise errors.NoColocatedBranchSupport(self)
 
934
        raise errors.IncompatibleFormat(BranchReferenceFormat, self._format)
 
935
 
912
936
 
913
937
class BzrDir4(BzrDirPreSplitOut):
914
938
    """A .bzr version 4 control object.
948
972
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat5
949
973
        return RepositoryFormat5().open(self, _found=True)
950
974
 
951
 
    def open_workingtree(self, _unsupported=False,
 
975
    def open_workingtree(self, unsupported=False,
952
976
            recommend_upgrade=True):
953
977
        """See BzrDir.create_workingtree."""
954
978
        from bzrlib.plugins.weave_fmt.workingtree import WorkingTreeFormat2
973
997
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
974
998
        return RepositoryFormat6().open(self, _found=True)
975
999
 
976
 
    def open_workingtree(self, _unsupported=False,
977
 
        recommend_upgrade=True):
 
1000
    def open_workingtree(self, unsupported=False, recommend_upgrade=True):
978
1001
        """See BzrDir.create_workingtree."""
979
1002
        # we don't warn here about upgrades; that ought to be handled for the
980
1003
        # bzrdir as a whole