~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

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
71
73
from bzrlib.workingtree import (
72
74
    InventoryWorkingTree,
73
75
    WorkingTree,
74
 
    WorkingTreeFormat,
 
76
    WorkingTreeFormatMetaDir,
75
77
    )
76
78
 
77
79
 
476
478
            return False # Missing entries are not executable
477
479
        return entry[1][0][3] # Executable?
478
480
 
479
 
    if not osutils.supports_executable():
480
 
        def is_executable(self, file_id, path=None):
481
 
            """Test if a file is executable or not.
 
481
    def is_executable(self, file_id, path=None):
 
482
        """Test if a file is executable or not.
482
483
 
483
 
            Note: The caller is expected to take a read-lock before calling this.
484
 
            """
 
484
        Note: The caller is expected to take a read-lock before calling this.
 
485
        """
 
486
        if not self._supports_executable():
485
487
            entry = self._get_entry(file_id=file_id, path=path)
486
488
            if entry == (None, None):
487
489
                return False
488
490
            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
 
            """
 
491
        else:
498
492
            self._must_be_locked()
499
493
            if not path:
500
494
                path = self.id2path(file_id)
969
963
                    all_versioned = False
970
964
                    break
971
965
            if not all_versioned:
972
 
                raise errors.PathsNotVersionedError(paths)
 
966
                raise errors.PathsNotVersionedError(
 
967
                    [p.decode('utf-8') for p in paths])
973
968
        # -- remove redundancy in supplied paths to prevent over-scanning --
974
969
        search_paths = osutils.minimum_path_selection(paths)
975
970
        # sketch:
1024
1019
            found_dir_names = set(dir_name_id[:2] for dir_name_id in found)
1025
1020
            for dir_name in split_paths:
1026
1021
                if dir_name not in found_dir_names:
1027
 
                    raise errors.PathsNotVersionedError(paths)
 
1022
                    raise errors.PathsNotVersionedError(
 
1023
                        [p.decode('utf-8') for p in paths])
1028
1024
 
1029
1025
        for dir_name_id, trees_info in found.iteritems():
1030
1026
            for index in search_indexes:
1446
1442
        return views.PathBasedViews(self)
1447
1443
 
1448
1444
 
1449
 
class DirStateWorkingTreeFormat(WorkingTreeFormat):
 
1445
class DirStateWorkingTreeFormat(WorkingTreeFormatMetaDir):
1450
1446
 
1451
1447
    missing_parent_conflicts = True
1452
1448
 
1482
1478
        control_files = self._open_control_files(a_bzrdir)
1483
1479
        control_files.create_lock()
1484
1480
        control_files.lock_write()
1485
 
        transport.put_bytes('format', self.get_format_string(),
 
1481
        transport.put_bytes('format', self.as_string(),
1486
1482
            mode=a_bzrdir._get_file_mode())
1487
1483
        if from_branch is not None:
1488
1484
            branch = from_branch
1608
1604
    This format:
1609
1605
        - exists within a metadir controlling .bzr
1610
1606
        - includes an explicit version marker for the workingtree control
1611
 
          files, separate from the BzrDir format
 
1607
          files, separate from the ControlDir format
1612
1608
        - modifies the hash cache format
1613
1609
        - is new in bzr 0.15
1614
1610
        - uses a LockDir to guard access to it.
1618
1614
 
1619
1615
    _tree_class = WorkingTree4
1620
1616
 
1621
 
    def get_format_string(self):
 
1617
    @classmethod
 
1618
    def get_format_string(cls):
1622
1619
        """See WorkingTreeFormat.get_format_string()."""
1623
1620
        return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
1624
1621
 
1635
1632
 
1636
1633
    _tree_class = WorkingTree5
1637
1634
 
1638
 
    def get_format_string(self):
 
1635
    @classmethod
 
1636
    def get_format_string(cls):
1639
1637
        """See WorkingTreeFormat.get_format_string()."""
1640
1638
        return "Bazaar Working Tree Format 5 (bzr 1.11)\n"
1641
1639
 
1655
1653
 
1656
1654
    _tree_class = WorkingTree6
1657
1655
 
1658
 
    def get_format_string(self):
 
1656
    @classmethod
 
1657
    def get_format_string(cls):
1659
1658
        """See WorkingTreeFormat.get_format_string()."""
1660
1659
        return "Bazaar Working Tree Format 6 (bzr 1.14)\n"
1661
1660
 
1849
1848
        # Make sure the file exists
1850
1849
        entry = self._get_entry(file_id, path=path)
1851
1850
        if entry == (None, None): # do we raise?
1852
 
            return None
 
1851
            raise errors.NoSuchId(self, file_id)
1853
1852
        parent_index = self._get_parent_index()
1854
1853
        last_changed_revision = entry[1][parent_index][4]
1855
1854
        try:
2174
2173
                path_entries = state._entries_for_path(path)
2175
2174
                if not path_entries:
2176
2175
                    # this specified path is not present at all: error
2177
 
                    not_versioned.append(path)
 
2176
                    not_versioned.append(path.decode('utf-8'))
2178
2177
                    continue
2179
2178
                found_versioned = False
2180
2179
                # for each id at this path
2188
2187
                if not found_versioned:
2189
2188
                    # none of the indexes was not 'absent' at all ids for this
2190
2189
                    # path.
2191
 
                    not_versioned.append(path)
 
2190
                    not_versioned.append(path.decode('utf-8'))
2192
2191
            if len(not_versioned) > 0:
2193
2192
                raise errors.PathsNotVersionedError(not_versioned)
2194
2193
        # -- remove redundancy in supplied specific_files to prevent over-scanning --
2261
2260
    def update_format(self, tree):
2262
2261
        """Change the format marker."""
2263
2262
        tree._transport.put_bytes('format',
2264
 
            self.target_format.get_format_string(),
 
2263
            self.target_format.as_string(),
2265
2264
            mode=tree.bzrdir._get_file_mode())
2266
2265
 
2267
2266
 
2284
2283
    def update_format(self, tree):
2285
2284
        """Change the format marker."""
2286
2285
        tree._transport.put_bytes('format',
2287
 
            self.target_format.get_format_string(),
 
2286
            self.target_format.as_string(),
2288
2287
            mode=tree.bzrdir._get_file_mode())
2289
2288
 
2290
2289
 
2313
2312
    def update_format(self, tree):
2314
2313
        """Change the format marker."""
2315
2314
        tree._transport.put_bytes('format',
2316
 
            self.target_format.get_format_string(),
 
2315
            self.target_format.as_string(),
2317
2316
            mode=tree.bzrdir._get_file_mode())