72
from bzrlib import symbol_versioning
72
# Explicitly import bzrlib.bzrdir so that the BzrProber
73
# is guaranteed to be registered.
73
79
from bzrlib.decorators import needs_read_lock, needs_write_lock
74
80
from bzrlib.i18n import gettext
75
81
from bzrlib.lock import LogicalLockResult
228
233
"""See `Tree.has_versioned_directories`."""
229
234
return self._format.supports_versioned_directories
236
def _supports_executable(self):
237
if sys.platform == 'win32':
239
# FIXME: Ideally this should check the file system
231
242
def break_lock(self):
232
243
"""Break a lock if one is present from another instance.
259
270
path = osutils.getcwd()
260
control = controldir.ControlDir.open(path, _unsupported)
261
return control.open_workingtree(_unsupported)
271
control = controldir.ControlDir.open(path, _unsupported=_unsupported)
272
return control.open_workingtree(unsupported=_unsupported)
264
275
def open_containing(path=None):
1113
1124
mode = stat_value.st_mode
1114
1125
kind = osutils.file_kind_from_stat_mode(mode)
1115
if not supports_executable():
1126
if not self._supports_executable():
1116
1127
executable = entry is not None and entry.executable
1118
1129
executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
2187
2198
mode = stat_result.st_mode
2188
2199
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
2190
if not supports_executable():
2191
def is_executable(self, file_id, path=None):
2201
def is_executable(self, file_id, path=None):
2202
if not self._supports_executable():
2192
2203
return self._inventory[file_id].executable
2194
_is_executable_from_path_and_stat = \
2195
_is_executable_from_path_and_stat_from_basis
2197
def is_executable(self, file_id, path=None):
2199
2206
path = self.id2path(file_id)
2200
2207
mode = os.lstat(self.abspath(path)).st_mode
2201
2208
return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
2203
_is_executable_from_path_and_stat = \
2204
_is_executable_from_path_and_stat_from_stat
2210
def _is_executable_from_path_and_stat(self, path, stat_result):
2211
if not self._supports_executable():
2212
return self._is_executable_from_path_and_stat_from_basis(path, stat_result)
2214
return self._is_executable_from_path_and_stat_from_stat(path, stat_result)
2206
2216
@needs_tree_write_lock
2207
2217
def _add(self, files, ids, kinds):
2967
2977
if dir[2] == _directory:
2968
2978
pending.append(dir)
2981
def update_feature_flags(self, updated_flags):
2982
"""Update the feature flags for this branch.
2984
:param updated_flags: Dictionary mapping feature names to necessities
2985
A necessity can be None to indicate the feature should be removed
2987
self._format._update_feature_flags(updated_flags)
2988
self.control_transport.put_bytes('format', self._format.as_string())
2971
2991
class WorkingTreeFormatRegistry(controldir.ControlComponentFormatRegistry):
2972
2992
"""Registry for working tree formats."""
3124
3144
return self._matchingbzrdir
3127
class WorkingTreeFormatMetaDir(bzrdir.BzrDirMetaComponentFormat, WorkingTreeFormat):
3147
class WorkingTreeFormatMetaDir(bzrdir.BzrFormat, WorkingTreeFormat):
3128
3148
"""Base class for working trees that live in bzr meta directories."""
3130
3150
def __init__(self):
3131
3151
WorkingTreeFormat.__init__(self)
3132
bzrdir.BzrDirMetaComponentFormat.__init__(self)
3152
bzrdir.BzrFormat.__init__(self)
3135
3155
def find_format_string(klass, controldir):
3147
3167
return klass._find_format(format_registry, 'working tree',
3170
def check_support_status(self, allow_unsupported, recommend_upgrade=True,
3172
WorkingTreeFormat.check_support_status(self,
3173
allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
3175
bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
3176
recommend_upgrade=recommend_upgrade, basedir=basedir)
3151
3179
format_registry.register_lazy("Bazaar Working Tree Format 4 (bzr 0.15)\n",
3152
3180
"bzrlib.workingtree_4", "WorkingTreeFormat4")