64
67
create_prefix=False, force_new_repo=False, stacked_on=None,
65
68
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
66
69
shared_repo=False):
67
"""See BzrDirFormat.initialize_on_transport_ex."""
70
"""See ControlDir.initialize_on_transport_ex."""
68
71
require_stacking = (stacked_on is not None)
69
72
# Format 5 cannot stack, but we've been asked to - actually init
81
84
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
82
85
make_working_trees=make_working_trees, shared_repo=shared_repo)
88
def from_string(cls, format_string):
89
if format_string != cls.get_format_string():
90
raise AssertionError("unexpected format string %r" % format_string)
85
94
class BzrDirFormat5(BzrDirFormatAllInOne):
86
95
"""Bzr control format 5.
98
107
def __eq__(self, other):
99
108
return type(self) == type(other)
101
def get_format_string(self):
111
def get_format_string(cls):
102
112
"""See BzrDirFormat.get_format_string()."""
103
113
return "Bazaar-NG branch, format 5\n"
107
117
return BzrBranchFormat4()
109
119
def get_format_description(self):
110
"""See BzrDirFormat.get_format_description()."""
120
"""See ControlDirFormat.get_format_description()."""
111
121
return "All-in-one format 5"
113
123
def get_converter(self, format=None):
114
"""See BzrDirFormat.get_converter()."""
124
"""See ControlDirFormat.get_converter()."""
115
125
# there is one and only one upgrade path here.
116
126
return ConvertBzrDir5To6()
161
171
def __eq__(self, other):
162
172
return type(self) == type(other)
164
def get_format_string(self):
175
def get_format_string(cls):
165
176
"""See BzrDirFormat.get_format_string()."""
166
177
return "Bazaar-NG branch, format 6\n"
168
179
def get_format_description(self):
169
"""See BzrDirFormat.get_format_description()."""
180
"""See ControlDirFormat.get_format_description()."""
170
181
return "All-in-one format 6"
172
183
def get_branch_format(self):
174
185
return BzrBranchFormat4()
176
187
def get_converter(self, format=None):
177
"""See BzrDirFormat.get_converter()."""
188
"""See ControlDirFormat.get_converter()."""
178
189
# there is one and only one upgrade path here.
179
190
return ConvertBzrDir6ToMeta()
230
241
if isinstance(self.bzrdir.transport, local.LocalTransport):
231
242
self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
232
243
self._convert_to_weaves()
233
return BzrDir.open(self.bzrdir.user_url)
244
return ControlDir.open(self.bzrdir.user_url)
235
246
self.pb.finished()
534
545
def convert(self, to_convert, pb):
535
546
"""See Converter.convert()."""
536
547
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
537
from bzrlib.branch import BzrBranchFormat5
548
from bzrlib.branchfmt.fullhistory import BzrBranchFormat5
538
549
self.bzrdir = to_convert
539
550
self.pb = ui.ui_factory.nested_progress_bar()
623
634
BzrDirMetaFormat1().get_format_string(),
624
635
mode=self.file_mode)
625
636
self.pb.finished()
626
return BzrDir.open(self.bzrdir.user_url)
637
return ControlDir.open(self.bzrdir.user_url)
628
639
def make_lock(self, name):
629
640
"""Make a lock for the new control dir name."""
669
680
def __eq__(self, other):
670
681
return type(self) == type(other)
672
def get_format_string(self):
684
def get_format_string(cls):
673
685
"""See BzrDirFormat.get_format_string()."""
674
686
return "Bazaar-NG branch, format 0.0.4\n"
676
688
def get_format_description(self):
677
"""See BzrDirFormat.get_format_description()."""
689
"""See ControlDirFormat.get_format_description()."""
678
690
return "All-in-one format 4"
680
692
def get_converter(self, format=None):
681
"""See BzrDirFormat.get_converter()."""
693
"""See ControlDirFormat.get_converter()."""
682
694
# there is one and only one upgrade path here.
683
695
return ConvertBzrDir4To5()
708
720
return RepositoryFormat4()
709
721
repository_format = property(__return_repository_format)
724
def from_string(cls, format_string):
725
if format_string != cls.get_format_string():
726
raise AssertionError("unexpected format string %r" % format_string)
712
730
class BzrDirPreSplitOut(BzrDir):
713
731
"""A common class for the all-in-one formats."""
715
733
def __init__(self, _transport, _format):
716
"""See BzrDir.__init__."""
734
"""See ControlDir.__init__."""
717
735
super(BzrDirPreSplitOut, self).__init__(_transport, _format)
718
736
self._control_files = lockable_files.LockableFiles(
719
737
self.get_branch_transport(None),
733
751
def clone(self, url, revision_id=None, force_new_repo=False,
734
752
preserve_stacking=False):
735
"""See BzrDir.clone().
753
"""See ControlDir.clone().
737
755
force_new_repo has no effect, since this family of formats always
738
756
require a new repository.
756
774
def create_branch(self, name=None, repository=None,
757
775
append_revisions_only=None):
758
"""See BzrDir.create_branch."""
776
"""See ControlDir.create_branch."""
759
777
if repository is not None:
760
778
raise NotImplementedError(
761
779
"create_branch(repository=<not None>) on %r" % (self,))
763
781
append_revisions_only=append_revisions_only)
765
783
def destroy_branch(self, name=None):
766
"""See BzrDir.destroy_branch."""
784
"""See ControlDir.destroy_branch."""
767
785
raise errors.UnsupportedOperation(self.destroy_branch, self)
769
787
def create_repository(self, shared=False):
770
"""See BzrDir.create_repository."""
788
"""See ControlDir.create_repository."""
772
790
raise errors.IncompatibleFormat('shared repository', self._format)
773
791
return self.open_repository()
775
793
def destroy_repository(self):
776
"""See BzrDir.destroy_repository."""
794
"""See ControlDir.destroy_repository."""
777
795
raise errors.UnsupportedOperation(self.destroy_repository, self)
779
797
def create_workingtree(self, revision_id=None, from_branch=None,
780
798
accelerator_tree=None, hardlink=False):
781
"""See BzrDir.create_workingtree."""
799
"""See ControlDir.create_workingtree."""
782
800
# The workingtree is sometimes created when the bzrdir is created,
783
801
# but not when cloning.
816
834
self.transport, self._control_files._file_mode)
818
836
def destroy_workingtree(self):
819
"""See BzrDir.destroy_workingtree."""
837
"""See ControlDir.destroy_workingtree."""
820
838
raise errors.UnsupportedOperation(self.destroy_workingtree, self)
822
840
def destroy_workingtree_metadata(self):
823
"""See BzrDir.destroy_workingtree_metadata."""
841
"""See ControlDir.destroy_workingtree_metadata."""
824
842
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata,
857
875
raise errors.IncompatibleFormat(workingtree_format, self._format)
859
877
def needs_format_conversion(self, format=None):
860
"""See BzrDir.needs_format_conversion()."""
878
"""See ControlDir.needs_format_conversion()."""
861
879
# if the format is not the same as the system default,
862
880
# an upgrade is needed.
863
881
if format is None:
867
885
return not isinstance(self._format, format.__class__)
869
887
def open_branch(self, name=None, unsupported=False,
870
ignore_fallbacks=False):
871
"""See BzrDir.open_branch."""
888
ignore_fallbacks=False, possible_transports=None):
889
"""See ControlDir.open_branch."""
872
890
from bzrlib.plugins.weave_fmt.branch import BzrBranchFormat4
873
891
format = BzrBranchFormat4()
874
892
format.check_support_status(unsupported)
875
return format.open(self, name, _found=True)
893
return format.open(self, name, _found=True,
894
possible_transports=possible_transports)
877
896
def sprout(self, url, revision_id=None, force_new_repo=False,
878
897
possible_transports=None, accelerator_tree=None,
879
898
hardlink=False, stacked=False, create_tree_if_local=True,
880
899
source_branch=None):
881
"""See BzrDir.sprout()."""
900
"""See ControlDir.sprout()."""
882
901
if source_branch is not None:
883
902
my_branch = self.open_branch()
884
903
if source_branch.base != my_branch.base:
909
928
hardlink=hardlink)
931
def set_branch_reference(self, target_branch, name=None):
932
from bzrlib.branch import BranchReferenceFormat
934
raise errors.NoColocatedBranchSupport(self)
935
raise errors.IncompatibleFormat(BranchReferenceFormat, self._format)
913
938
class BzrDir4(BzrDirPreSplitOut):
914
939
"""A .bzr version 4 control object.
919
944
def create_repository(self, shared=False):
920
"""See BzrDir.create_repository."""
945
"""See ControlDir.create_repository."""
921
946
return self._format.repository_format.initialize(self, shared)
923
948
def needs_format_conversion(self, format=None):
930
955
def open_repository(self):
931
"""See BzrDir.open_repository."""
956
"""See ControlDir.open_repository."""
932
957
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat4
933
958
return RepositoryFormat4().open(self, _found=True)
942
967
def has_workingtree(self):
943
"""See BzrDir.has_workingtree."""
968
"""See ControlDir.has_workingtree."""
946
971
def open_repository(self):
947
"""See BzrDir.open_repository."""
972
"""See ControlDir.open_repository."""
948
973
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat5
949
974
return RepositoryFormat5().open(self, _found=True)
951
def open_workingtree(self, _unsupported=False,
976
def open_workingtree(self, unsupported=False,
952
977
recommend_upgrade=True):
953
"""See BzrDir.create_workingtree."""
978
"""See ControlDir.create_workingtree."""
954
979
from bzrlib.plugins.weave_fmt.workingtree import WorkingTreeFormat2
955
980
wt_format = WorkingTreeFormat2()
956
981
# we don't warn here about upgrades; that ought to be handled for the
967
992
def has_workingtree(self):
968
"""See BzrDir.has_workingtree."""
993
"""See ControlDir.has_workingtree."""
971
996
def open_repository(self):
972
"""See BzrDir.open_repository."""
997
"""See ControlDir.open_repository."""
973
998
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
974
999
return RepositoryFormat6().open(self, _found=True)
976
def open_workingtree(self, _unsupported=False,
977
recommend_upgrade=True):
978
"""See BzrDir.create_workingtree."""
1001
def open_workingtree(self, unsupported=False, recommend_upgrade=True):
1002
"""See ControlDir.create_workingtree."""
979
1003
# we don't warn here about upgrades; that ought to be handled for the
980
1004
# bzrdir as a whole
981
1005
from bzrlib.plugins.weave_fmt.workingtree import WorkingTreeFormat2