109
110
source_repo_format.check_conversion_target(target_repo_format)
112
def _check_supported(format, allow_unsupported):
113
"""Check whether format is a supported format.
115
If allow_unsupported is True, this is a no-op.
113
def _check_supported(format, allow_unsupported,
114
recommend_upgrade=True,
116
"""Give an error or warning on old formats.
118
:param format: may be any kind of format - workingtree, branch,
121
:param allow_unsupported: If true, allow opening
122
formats that are strongly deprecated, and which may
123
have limited functionality.
125
:param recommend_upgrade: If true (default), warn
126
the user through the ui object that they may wish
127
to upgrade the object.
129
# TODO: perhaps move this into the format itself.
117
131
if not allow_unsupported and not format.is_supported():
118
132
# see open_downlevel to open legacy branches.
119
133
raise errors.UnsupportedFormatError(format=format)
134
if recommend_upgrade \
135
and getattr(format, 'upgrade_recommended', False):
136
ui.ui_factory.recommend_upgrade(
137
format.get_format_description(),
121
140
def clone(self, url, revision_id=None, basis=None, force_new_repo=False):
122
141
"""Clone this bzrdir and its contents to url verbatim.
527
546
:param _unsupported: private.
529
548
format = BzrDirFormat.find_format(transport)
530
BzrDir._check_supported(format, _unsupported)
549
BzrDir._check_supported(format, _unsupported,
550
basedir=transport.base)
531
551
return format.open(transport, _found=True)
533
553
def open_branch(self, unsupported=False):
844
864
def create_workingtree(self, revision_id=None):
845
865
"""See BzrDir.create_workingtree."""
846
866
# this looks buggy but is not -really-
867
# because this format creates the workingtree when the bzrdir is
847
869
# clone and sprout will have set the revision_id
848
870
# and that will have set it for us, its only
849
871
# specific uses of create_workingtree in isolation
850
872
# that can do wonky stuff here, and that only
851
873
# happens for creating checkouts, which cannot be
852
874
# done on this format anyway. So - acceptable wart.
853
result = self.open_workingtree()
875
result = self.open_workingtree(recommend_upgrade=False)
854
876
if revision_id is not None:
855
877
if revision_id == _mod_revision.NULL_REVISION:
856
878
result.set_parent_ids([])
962
984
from bzrlib.repofmt.weaverepo import RepositoryFormat5
963
985
return RepositoryFormat5().open(self, _found=True)
965
def open_workingtree(self, _unsupported=False):
987
def open_workingtree(self, _unsupported=False,
988
recommend_upgrade=True):
966
989
"""See BzrDir.create_workingtree."""
967
990
from bzrlib.workingtree import WorkingTreeFormat2
968
return WorkingTreeFormat2().open(self, _found=True)
991
wt_format = WorkingTreeFormat2()
992
# we don't warn here about upgrades; that ought to be handled for the
994
return wt_format.open(self, _found=True)
971
997
class BzrDir6(BzrDirPreSplitOut):
979
1005
from bzrlib.repofmt.weaverepo import RepositoryFormat6
980
1006
return RepositoryFormat6().open(self, _found=True)
982
def open_workingtree(self, _unsupported=False):
1008
def open_workingtree(self, _unsupported=False,
1009
recommend_upgrade=True):
983
1010
"""See BzrDir.create_workingtree."""
1011
# we don't warn here about upgrades; that ought to be handled for the
984
1013
from bzrlib.workingtree import WorkingTreeFormat2
985
1014
return WorkingTreeFormat2().open(self, _found=True)
1014
1043
def destroy_workingtree(self):
1015
1044
"""See BzrDir.destroy_workingtree."""
1016
wt = self.open_workingtree()
1045
wt = self.open_workingtree(recommend_upgrade=False)
1017
1046
repository = wt.branch.repository
1018
1047
empty = repository.revision_tree(_mod_revision.NULL_REVISION)
1019
1048
wt.revert([], old_tree=empty)
1093
1122
except errors.NotBranchError:
1096
if not isinstance(self.open_workingtree()._format,
1125
my_wt = self.open_workingtree(recommend_upgrade=False)
1126
if not isinstance(my_wt._format,
1097
1127
format.workingtree_format.__class__):
1098
1128
# the workingtree needs an upgrade.
1115
1145
self._check_supported(format, unsupported)
1116
1146
return format.open(self, _found=True)
1118
def open_workingtree(self, unsupported=False):
1148
def open_workingtree(self, unsupported=False,
1149
recommend_upgrade=True):
1119
1150
"""See BzrDir.open_workingtree."""
1120
1151
from bzrlib.workingtree import WorkingTreeFormat
1121
1152
format = WorkingTreeFormat.find_format(self)
1122
self._check_supported(format, unsupported)
1153
self._check_supported(format, unsupported,
1155
basedir=self.transport.base)
1123
1156
return format.open(self, _found=True)
2109
2142
branch_converter = _mod_branch.Converter5to6()
2110
2143
branch_converter.convert(branch)
2112
tree = self.bzrdir.open_workingtree()
2145
tree = self.bzrdir.open_workingtree(recommend_upgrade=False)
2113
2146
except (errors.NoWorkingTree, errors.NotLocalUrl):