556
556
"""See BzrDir.clone()."""
557
557
from bzrlib.workingtree import WorkingTreeFormat2
558
558
self._make_tail(url)
559
result = self._format._initialize_for_clone(url)
559
result = self._format.initialize(url, _cloning=True)
560
560
basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
561
561
self.open_repository().clone(result, revision_id=revision_id, basis=basis_repo)
562
562
self.open_branch().clone(result, revision_id=revision_id)
644
644
"""See BzrDir.sprout()."""
645
645
from bzrlib.workingtree import WorkingTreeFormat2
646
646
self._make_tail(url)
647
result = self._format._initialize_for_clone(url)
647
result = self._format.initialize(url, _cloning=True)
648
648
basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
650
650
self.open_repository().clone(result, revision_id=revision_id, basis=basis_repo)
870
870
"""Return the ASCII format string that identifies this format."""
871
871
raise NotImplementedError(self.get_format_string)
873
def get_format_description(self):
874
"""Return the short description for this format."""
875
raise NotImplementedError(self.get_format_description)
877
873
def get_converter(self, format=None):
878
874
"""Return the converter to use to convert bzrdirs needing converts.
889
885
raise NotImplementedError(self.get_converter)
891
887
def initialize(self, url):
892
"""Create a bzr control dir at this url and return an opened copy.
894
Subclasses should typically override initialize_on_transport
895
instead of this method.
897
return self.initialize_on_transport(get_transport(url))
899
def initialize_on_transport(self, transport):
900
"""Initialize a new bzrdir in the base directory of a Transport."""
901
# Since we don'transport have a .bzr directory, inherit the
888
"""Create a bzr control dir at this url and return an opened copy."""
889
# Since we don't have a .bzr directory, inherit the
902
890
# mode from the root directory
903
temp_control = LockableFiles(transport, '', TransportLock)
891
t = get_transport(url)
892
temp_control = LockableFiles(t, '', TransportLock)
904
893
temp_control._transport.mkdir('.bzr',
905
894
# FIXME: RBC 20060121 dont peek under
907
896
mode=temp_control._dir_mode)
908
897
file_mode = temp_control._file_mode
910
mutter('created control directory in ' + transport.base)
911
control = transport.clone('.bzr')
899
mutter('created control directory in ' + t.base)
900
control = t.clone('.bzr')
912
901
utf8_files = [('README',
913
902
"This is a Bazaar-NG control directory.\n"
914
903
"Do not change any files in this directory.\n"),
915
904
('branch-format', self.get_format_string()),
917
906
# NB: no need to escape relative paths that are url safe.
918
control_files = LockableFiles(control, self._lock_file_name,
907
control_files = LockableFiles(control, self._lock_file_name, self._lock_class)
920
908
control_files.create_lock()
921
909
control_files.lock_write()
924
912
control_files.put_utf8(file, content)
926
914
control_files.unlock()
927
return self.open(transport, _found=True)
915
return self.open(t, _found=True)
929
917
def is_supported(self):
930
918
"""Is this format supported?
989
977
"""See BzrDirFormat.get_format_string()."""
990
978
return "Bazaar-NG branch, format 0.0.4\n"
992
def get_format_description(self):
993
"""See BzrDirFormat.get_format_description()."""
994
return "All-in-one format 4"
996
980
def get_converter(self, format=None):
997
981
"""See BzrDirFormat.get_converter()."""
998
982
# there is one and only one upgrade path here.
999
983
return ConvertBzrDir4To5()
1001
def initialize_on_transport(self, transport):
985
def initialize(self, url):
1002
986
"""Format 4 branches cannot be created."""
1003
987
raise errors.UninitializableFormat(self)
1039
1023
"""See BzrDirFormat.get_format_string()."""
1040
1024
return "Bazaar-NG branch, format 5\n"
1042
def get_format_description(self):
1043
"""See BzrDirFormat.get_format_description()."""
1044
return "All-in-one format 5"
1046
1026
def get_converter(self, format=None):
1047
1027
"""See BzrDirFormat.get_converter()."""
1048
1028
# there is one and only one upgrade path here.
1049
1029
return ConvertBzrDir5To6()
1051
def _initialize_for_clone(self, url):
1052
return self.initialize_on_transport(get_transport(url), _cloning=True)
1054
def initialize_on_transport(self, transport, _cloning=False):
1031
def initialize(self, url, _cloning=False):
1055
1032
"""Format 5 dirs always have working tree, branch and repository.
1057
1034
Except when they are being cloned.
1059
1036
from bzrlib.branch import BzrBranchFormat4
1060
1037
from bzrlib.repository import RepositoryFormat5
1061
1038
from bzrlib.workingtree import WorkingTreeFormat2
1062
result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
1039
result = super(BzrDirFormat5, self).initialize(url)
1063
1040
RepositoryFormat5().initialize(result, _internal=True)
1064
1041
if not _cloning:
1065
1042
BzrBranchFormat4().initialize(result)
1093
1070
"""See BzrDirFormat.get_format_string()."""
1094
1071
return "Bazaar-NG branch, format 6\n"
1096
def get_format_description(self):
1097
"""See BzrDirFormat.get_format_description()."""
1098
return "All-in-one format 6"
1100
1073
def get_converter(self, format=None):
1101
1074
"""See BzrDirFormat.get_converter()."""
1102
1075
# there is one and only one upgrade path here.
1103
1076
return ConvertBzrDir6ToMeta()
1105
def _initialize_for_clone(self, url):
1106
return self.initialize_on_transport(get_transport(url), _cloning=True)
1108
def initialize_on_transport(self, transport, _cloning=False):
1078
def initialize(self, url, _cloning=False):
1109
1079
"""Format 6 dirs always have working tree, branch and repository.
1111
1081
Except when they are being cloned.
1113
1083
from bzrlib.branch import BzrBranchFormat4
1114
1084
from bzrlib.repository import RepositoryFormat6
1115
1085
from bzrlib.workingtree import WorkingTreeFormat2
1116
result = super(BzrDirFormat6, self).initialize_on_transport(transport)
1086
result = super(BzrDirFormat6, self).initialize(url)
1117
1087
RepositoryFormat6().initialize(result, _internal=True)
1118
1088
if not _cloning:
1119
1089
BzrBranchFormat4().initialize(result)
1162
1132
"""See BzrDirFormat.get_format_string()."""
1163
1133
return "Bazaar-NG meta directory, format 1\n"
1165
def get_format_description(self):
1166
"""See BzrDirFormat.get_format_description()."""
1167
return "Meta directory format 1"
1169
1135
def _open(self, transport):
1170
1136
"""See BzrDirFormat._open."""
1171
1137
return BzrDirMeta1(transport, self)
1579
1545
return BzrDir.open(self.bzrdir.root_transport.base)
1581
1547
def _convert_to_prefixed(self):
1582
from bzrlib.store import TransportStore
1548
from bzrlib.store import hash_prefix
1583
1549
self.bzrdir.transport.delete('branch-format')
1584
1550
for store_name in ["weaves", "revision-store"]:
1585
self.pb.note("adding prefixes to %s" % store_name)
1551
self.pb.note("adding prefixes to %s" % store_name)
1586
1552
store_transport = self.bzrdir.transport.clone(store_name)
1587
store = TransportStore(store_transport, prefixed=True)
1588
1553
for urlfilename in store_transport.list_dir('.'):
1589
1554
filename = urlunescape(urlfilename)
1590
1555
if (filename.endswith(".weave") or
1593
1558
file_id = os.path.splitext(filename)[0]
1595
1560
file_id = filename
1596
prefix_dir = store.hash_prefix(file_id)
1561
prefix_dir = hash_prefix(file_id)
1597
1562
# FIXME keep track of the dirs made RBC 20060121
1599
1564
store_transport.move(filename, prefix_dir + '/' + filename)