~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Martin Packman
  • Date: 2012-01-05 10:44:12 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6427.
  • Revision ID: martin.packman@canonical.com-20120105104412-z03fi9m43h946fvs
Merge bzr.dev to resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
WorkingTree.open(dir).
30
30
"""
31
31
 
 
32
from __future__ import absolute_import
32
33
 
33
34
from cStringIO import StringIO
34
35
import os
46
47
 
47
48
from bzrlib import (
48
49
    branch,
49
 
    bzrdir,
50
50
    conflicts as _mod_conflicts,
51
51
    controldir,
52
52
    errors,
69
69
    )
70
70
""")
71
71
 
72
 
from bzrlib import symbol_versioning
 
72
# Explicitly import bzrlib.bzrdir so that the BzrProber
 
73
# is guaranteed to be registered.
 
74
from bzrlib import (
 
75
    bzrdir,
 
76
    symbol_versioning,
 
77
    )
 
78
 
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
84
90
    realpath,
85
91
    safe_unicode,
86
92
    splitpath,
87
 
    supports_executable,
88
93
    )
89
94
from bzrlib.trace import mutter, note
90
95
from bzrlib.revision import CURRENT_REVISION
228
233
        """See `Tree.has_versioned_directories`."""
229
234
        return self._format.supports_versioned_directories
230
235
 
 
236
    def _supports_executable(self):
 
237
        if sys.platform == 'win32':
 
238
            return False
 
239
        # FIXME: Ideally this should check the file system
 
240
        return True
 
241
 
231
242
    def break_lock(self):
232
243
        """Break a lock if one is present from another instance.
233
244
 
257
268
        """
258
269
        if path is None:
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)
262
273
 
263
274
    @staticmethod
264
275
    def open_containing(path=None):
1112
1123
        else:
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
1117
1128
            else:
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)
2189
2200
 
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
2193
 
 
2194
 
        _is_executable_from_path_and_stat = \
2195
 
            _is_executable_from_path_and_stat_from_basis
2196
 
    else:
2197
 
        def is_executable(self, file_id, path=None):
 
2204
        else:
2198
2205
            if not path:
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)
2202
2209
 
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)
 
2213
        else:
 
2214
            return self._is_executable_from_path_and_stat_from_stat(path, stat_result)
2205
2215
 
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)
2969
2979
 
 
2980
    @needs_write_lock
 
2981
    def update_feature_flags(self, updated_flags):
 
2982
        """Update the feature flags for this branch.
 
2983
 
 
2984
        :param updated_flags: Dictionary mapping feature names to necessities
 
2985
            A necessity can be None to indicate the feature should be removed
 
2986
        """
 
2987
        self._format._update_feature_flags(updated_flags)
 
2988
        self.control_transport.put_bytes('format', self._format.as_string())
 
2989
 
2970
2990
 
2971
2991
class WorkingTreeFormatRegistry(controldir.ControlComponentFormatRegistry):
2972
2992
    """Registry for working tree formats."""
3124
3144
        return self._matchingbzrdir
3125
3145
 
3126
3146
 
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."""
3129
3149
 
3130
3150
    def __init__(self):
3131
3151
        WorkingTreeFormat.__init__(self)
3132
 
        bzrdir.BzrDirMetaComponentFormat.__init__(self)
 
3152
        bzrdir.BzrFormat.__init__(self)
3133
3153
 
3134
3154
    @classmethod
3135
3155
    def find_format_string(klass, controldir):
3147
3167
        return klass._find_format(format_registry, 'working tree',
3148
3168
                format_string)
3149
3169
 
 
3170
    def check_support_status(self, allow_unsupported, recommend_upgrade=True,
 
3171
            basedir=None):
 
3172
        WorkingTreeFormat.check_support_status(self,
 
3173
            allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
 
3174
            basedir=basedir)
 
3175
        bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
 
3176
            recommend_upgrade=recommend_upgrade, basedir=basedir)
 
3177
 
3150
3178
 
3151
3179
format_registry.register_lazy("Bazaar Working Tree Format 4 (bzr 0.15)\n",
3152
3180
    "bzrlib.workingtree_4", "WorkingTreeFormat4")