656
656
# directories and files are read-write for this user. This is
657
657
# mostly a workaround for filesystems which lie about being able to
658
658
# write to a directory (cygwin & win32)
659
self._dir_mode = (st.st_mode & 07777) | 00700
660
# Remove the sticky and execute bits for files
661
self._file_mode = self._dir_mode & ~07111
659
if (st.st_mode & 07777 == 00000):
660
# FTP allows stat but does not return dir/file modes
661
self._dir_mode = None
662
self._file_mode = None
664
self._dir_mode = (st.st_mode & 07777) | 00700
665
# Remove the sticky and execute bits for files
666
self._file_mode = self._dir_mode & ~07111
663
668
def _get_file_mode(self):
664
669
"""Return Unix mode for newly created files, or None.
1011
1017
result_format.workingtree_format = tree._format.__class__()
1012
1018
return result_format, source_repository
1014
def cloning_metadir(self):
1020
def cloning_metadir(self, require_stacking=False):
1015
1021
"""Produce a metadir suitable for cloning or sprouting with.
1017
1023
These operations may produce workingtrees (yes, even though they're
1018
1024
"cloning" something that doesn't have a tree), so a viable workingtree
1019
1025
format must be selected.
1027
:require_stacking: If True, non-stackable formats will be upgraded
1028
to similar stackable formats.
1021
1029
:returns: a BzrDirFormat with all component formats either set
1022
appropriately or set to None if that component should not be
1030
appropriately or set to None if that component should not be
1025
1033
format, repository = self._cloning_metadir()
1029
1037
tree_format = repository._format._matchingbzrdir.workingtree_format
1030
1038
format.workingtree_format = tree_format.__class__()
1039
if (require_stacking and not
1040
format.get_branch_format().supports_stacking()):
1041
# We need to make a stacked branch, but the default format for the
1042
# target doesn't support stacking. So force a branch that *can*
1044
from bzrlib.branch import BzrBranchFormat7
1045
format._branch_format = BzrBranchFormat7()
1046
mutter("using %r for stacking" % (format._branch_format,))
1047
from bzrlib.repofmt import pack_repo
1048
if format.repository_format.rich_root_data:
1049
repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
1051
repo_format = pack_repo.RepositoryFormatKnitPack5()
1052
format.repository_format = repo_format
1033
1055
def checkout_metadir(self):
1060
1082
target_transport = get_transport(url, possible_transports)
1061
1083
target_transport.ensure_base()
1062
cloning_format = self.cloning_metadir()
1084
cloning_format = self.cloning_metadir(stacked)
1085
# Create/update the result branch
1063
1086
result = cloning_format.initialize_on_transport(target_transport)
1065
1088
source_branch = self.open_branch()
1081
1104
force_new_repo, stacked_branch_url, require_stacking=stacked)
1082
1105
result_repo = repository_policy.acquire_repository()
1083
1106
if source_repository is not None:
1084
# XXX: Isn't this redundant with the copy_content_into used below
1085
# after creating the branch? -- mbp 20080724
1107
# Fetch while stacked to prevent unstacked fetch from
1086
1109
result_repo.fetch(source_repository, revision_id=revision_id)
1088
# Create/update the result branch
1089
format_forced = False
1091
or repository_policy._require_stacking
1092
or repository_policy._stack_on)
1093
and not result._format.get_branch_format().supports_stacking()):
1094
# We need to make a stacked branch, but the default format for the
1095
# target doesn't support stacking. So force a branch that *can*
1097
from bzrlib.branch import BzrBranchFormat7
1098
format = BzrBranchFormat7()
1099
result_branch = format.initialize(result)
1100
mutter("using %r for stacking" % (format,))
1101
format_forced = True
1102
elif source_branch is None:
1111
if source_branch is None:
1103
1112
# this is for sprouting a bzrdir without a branch; is that
1104
1113
# actually useful?
1114
# Not especially, but it's part of the contract.
1105
1115
result_branch = result.create_branch()
1117
# Force NULL revision to avoid using repository before stacking
1107
1119
result_branch = source_branch.sprout(
1108
result, revision_id=revision_id)
1120
result, revision_id=_mod_revision.NULL_REVISION)
1121
parent_location = result_branch.get_parent()
1109
1122
mutter("created new branch %r" % (result_branch,))
1110
1123
repository_policy.configure_branch(result_branch)
1111
if source_branch is not None and format_forced:
1112
# XXX: this duplicates Branch.sprout(); it probably belongs on an
1113
# InterBranch method? -- mbp 20080724
1114
source_branch.copy_content_into(result_branch,
1115
revision_id=revision_id)
1116
result_branch.set_parent(self.root_transport.base)
1124
if source_branch is not None:
1125
source_branch.copy_content_into(result_branch, revision_id)
1126
# Override copy_content_into
1127
result_branch.set_parent(parent_location)
1118
1129
# Create/update the result working tree
1119
1130
if isinstance(target_transport, LocalTransport) and (
1172
1183
"""Pre-splitout bzrdirs do not suffer from stale locks."""
1173
1184
raise NotImplementedError(self.break_lock)
1175
def cloning_metadir(self):
1186
def cloning_metadir(self, require_stacking=False):
1176
1187
"""Produce a metadir suitable for cloning with."""
1188
if require_stacking:
1189
return format_registry.make_bzrdir('1.6')
1177
1190
return self._format.__class__()
1179
1192
def clone(self, url, revision_id=None, force_new_repo=False,
1853
1866
"""See BzrDirFormat.get_format_string()."""
1854
1867
return "Bazaar-NG branch, format 5\n"
1869
def get_branch_format(self):
1870
from bzrlib import branch
1871
return branch.BzrBranchFormat4()
1856
1873
def get_format_description(self):
1857
1874
"""See BzrDirFormat.get_format_description()."""
1858
1875
return "All-in-one format 5"
1916
1933
"""See BzrDirFormat.get_format_description()."""
1917
1934
return "All-in-one format 6"
1936
def get_branch_format(self):
1937
from bzrlib import branch
1938
return branch.BzrBranchFormat4()
1919
1940
def get_converter(self, format=None):
1920
1941
"""See BzrDirFormat.get_converter()."""
1921
1942
# there is one and only one upgrade path here.
2892
2913
Creates the desired repository in the bzrdir we already have.
2894
if self._stack_on or self._require_stacking:
2895
# we may be coming from a format that doesn't support stacking,
2896
# but we require it in the destination, so force creation of a new
2899
# TODO: perhaps this should be treated as a distinct repository
2900
# acquisition policy?
2901
repository_format = self._bzrdir._format.repository_format
2902
if not repository_format.supports_external_lookups:
2903
# should possibly be controlled by the registry rather than
2905
from bzrlib.repofmt import pack_repo
2906
if repository_format.rich_root_data:
2907
repository_format = \
2908
pack_repo.RepositoryFormatKnitPack5RichRoot()
2910
repository_format = pack_repo.RepositoryFormatKnitPack5()
2911
note("using %r for stacking" % (repository_format,))
2912
repository = repository_format.initialize(self._bzrdir,
2916
repository = self._bzrdir.create_repository(shared=shared)
2915
repository = self._bzrdir.create_repository(shared=shared)
2917
2916
self._add_fallback(repository)
2918
2917
if make_working_trees is not None:
2919
2918
repository.set_make_working_trees(make_working_trees)
3033
3032
branch_format='bzrlib.branch.BzrBranchFormat7',
3034
3033
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3036
format_registry.register_metadir('1.6-rich-root',
3035
format_registry.register_metadir('1.6.1-rich-root',
3037
3036
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
3038
3037
help='A branch and pack based repository that supports stacking '
3039
3038
'and rich root data (needed for bzr-svn). ',