~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
WorkingTree.open(dir).
23
23
"""
24
24
 
 
25
from __future__ import absolute_import
 
26
 
25
27
from cStringIO import StringIO
26
28
import os
27
29
import sys
55
57
from bzrlib.lock import LogicalLockResult
56
58
from bzrlib.lockable_files import LockableFiles
57
59
from bzrlib.lockdir import LockDir
58
 
from bzrlib.mutabletree import needs_tree_write_lock
 
60
from bzrlib.mutabletree import (
 
61
    MutableTree,
 
62
    needs_tree_write_lock,
 
63
    )
59
64
from bzrlib.osutils import (
60
65
    file_kind,
61
66
    isdir,
71
76
from bzrlib.workingtree import (
72
77
    InventoryWorkingTree,
73
78
    WorkingTree,
74
 
    WorkingTreeFormat,
 
79
    WorkingTreeFormatMetaDir,
75
80
    )
76
81
 
77
82
 
476
481
            return False # Missing entries are not executable
477
482
        return entry[1][0][3] # Executable?
478
483
 
479
 
    if not osutils.supports_executable():
480
 
        def is_executable(self, file_id, path=None):
481
 
            """Test if a file is executable or not.
 
484
    def is_executable(self, file_id, path=None):
 
485
        """Test if a file is executable or not.
482
486
 
483
 
            Note: The caller is expected to take a read-lock before calling this.
484
 
            """
 
487
        Note: The caller is expected to take a read-lock before calling this.
 
488
        """
 
489
        if not self._supports_executable():
485
490
            entry = self._get_entry(file_id=file_id, path=path)
486
491
            if entry == (None, None):
487
492
                return False
488
493
            return entry[1][0][3]
489
 
 
490
 
        _is_executable_from_path_and_stat = \
491
 
            _is_executable_from_path_and_stat_from_basis
492
 
    else:
493
 
        def is_executable(self, file_id, path=None):
494
 
            """Test if a file is executable or not.
495
 
 
496
 
            Note: The caller is expected to take a read-lock before calling this.
497
 
            """
 
494
        else:
498
495
            self._must_be_locked()
499
496
            if not path:
500
497
                path = self.id2path(file_id)
969
966
                    all_versioned = False
970
967
                    break
971
968
            if not all_versioned:
972
 
                raise errors.PathsNotVersionedError(paths)
 
969
                raise errors.PathsNotVersionedError(
 
970
                    [p.decode('utf-8') for p in paths])
973
971
        # -- remove redundancy in supplied paths to prevent over-scanning --
974
972
        search_paths = osutils.minimum_path_selection(paths)
975
973
        # sketch:
1024
1022
            found_dir_names = set(dir_name_id[:2] for dir_name_id in found)
1025
1023
            for dir_name in split_paths:
1026
1024
                if dir_name not in found_dir_names:
1027
 
                    raise errors.PathsNotVersionedError(paths)
 
1025
                    raise errors.PathsNotVersionedError(
 
1026
                        [p.decode('utf-8') for p in paths])
1028
1027
 
1029
1028
        for dir_name_id, trees_info in found.iteritems():
1030
1029
            for index in search_indexes:
1446
1445
        return views.PathBasedViews(self)
1447
1446
 
1448
1447
 
1449
 
class DirStateWorkingTreeFormat(WorkingTreeFormat):
 
1448
class DirStateWorkingTreeFormat(WorkingTreeFormatMetaDir):
1450
1449
 
1451
1450
    missing_parent_conflicts = True
1452
1451
 
1482
1481
        control_files = self._open_control_files(a_bzrdir)
1483
1482
        control_files.create_lock()
1484
1483
        control_files.lock_write()
1485
 
        transport.put_bytes('format', self.get_format_string(),
 
1484
        transport.put_bytes('format', self.as_string(),
1486
1485
            mode=a_bzrdir._get_file_mode())
1487
1486
        if from_branch is not None:
1488
1487
            branch = from_branch
1548
1547
                transform.build_tree(basis, wt, accelerator_tree,
1549
1548
                                     hardlink=hardlink,
1550
1549
                                     delta_from_tree=delta_from_tree)
 
1550
                for hook in MutableTree.hooks['post_build_tree']:
 
1551
                    hook(wt)
1551
1552
            finally:
1552
1553
                basis.unlock()
1553
1554
        finally:
1608
1609
    This format:
1609
1610
        - exists within a metadir controlling .bzr
1610
1611
        - includes an explicit version marker for the workingtree control
1611
 
          files, separate from the BzrDir format
 
1612
          files, separate from the ControlDir format
1612
1613
        - modifies the hash cache format
1613
1614
        - is new in bzr 0.15
1614
1615
        - uses a LockDir to guard access to it.
1618
1619
 
1619
1620
    _tree_class = WorkingTree4
1620
1621
 
1621
 
    def get_format_string(self):
 
1622
    @classmethod
 
1623
    def get_format_string(cls):
1622
1624
        """See WorkingTreeFormat.get_format_string()."""
1623
1625
        return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
1624
1626
 
1635
1637
 
1636
1638
    _tree_class = WorkingTree5
1637
1639
 
1638
 
    def get_format_string(self):
 
1640
    @classmethod
 
1641
    def get_format_string(cls):
1639
1642
        """See WorkingTreeFormat.get_format_string()."""
1640
1643
        return "Bazaar Working Tree Format 5 (bzr 1.11)\n"
1641
1644
 
1655
1658
 
1656
1659
    _tree_class = WorkingTree6
1657
1660
 
1658
 
    def get_format_string(self):
 
1661
    @classmethod
 
1662
    def get_format_string(cls):
1659
1663
        """See WorkingTreeFormat.get_format_string()."""
1660
1664
        return "Bazaar Working Tree Format 6 (bzr 1.14)\n"
1661
1665
 
1849
1853
        # Make sure the file exists
1850
1854
        entry = self._get_entry(file_id, path=path)
1851
1855
        if entry == (None, None): # do we raise?
1852
 
            return None
 
1856
            raise errors.NoSuchId(self, file_id)
1853
1857
        parent_index = self._get_parent_index()
1854
1858
        last_changed_revision = entry[1][parent_index][4]
1855
1859
        try:
2174
2178
                path_entries = state._entries_for_path(path)
2175
2179
                if not path_entries:
2176
2180
                    # this specified path is not present at all: error
2177
 
                    not_versioned.append(path)
 
2181
                    not_versioned.append(path.decode('utf-8'))
2178
2182
                    continue
2179
2183
                found_versioned = False
2180
2184
                # for each id at this path
2188
2192
                if not found_versioned:
2189
2193
                    # none of the indexes was not 'absent' at all ids for this
2190
2194
                    # path.
2191
 
                    not_versioned.append(path)
 
2195
                    not_versioned.append(path.decode('utf-8'))
2192
2196
            if len(not_versioned) > 0:
2193
2197
                raise errors.PathsNotVersionedError(not_versioned)
2194
2198
        # -- remove redundancy in supplied specific_files to prevent over-scanning --
2261
2265
    def update_format(self, tree):
2262
2266
        """Change the format marker."""
2263
2267
        tree._transport.put_bytes('format',
2264
 
            self.target_format.get_format_string(),
 
2268
            self.target_format.as_string(),
2265
2269
            mode=tree.bzrdir._get_file_mode())
2266
2270
 
2267
2271
 
2284
2288
    def update_format(self, tree):
2285
2289
        """Change the format marker."""
2286
2290
        tree._transport.put_bytes('format',
2287
 
            self.target_format.get_format_string(),
 
2291
            self.target_format.as_string(),
2288
2292
            mode=tree.bzrdir._get_file_mode())
2289
2293
 
2290
2294
 
2313
2317
    def update_format(self, tree):
2314
2318
        """Change the format marker."""
2315
2319
        tree._transport.put_bytes('format',
2316
 
            self.target_format.get_format_string(),
 
2320
            self.target_format.as_string(),
2317
2321
            mode=tree.bzrdir._get_file_mode())