~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

(gz) Fix deprecations of win32utils path function unicode wrappers (Martin
 Packman)

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
34
36
from bzrlib import (
35
37
    bzrdir,
36
38
    cache_utf8,
 
39
    config,
37
40
    conflicts as _mod_conflicts,
38
41
    debug,
39
42
    dirstate,
70
73
from bzrlib.workingtree import (
71
74
    InventoryWorkingTree,
72
75
    WorkingTree,
73
 
    WorkingTreeFormat,
 
76
    WorkingTreeFormatMetaDir,
74
77
    )
75
78
 
76
79
 
77
80
class DirStateWorkingTree(InventoryWorkingTree):
78
81
 
79
 
    _DEFAULT_WORTH_SAVING_LIMIT = 10
80
 
 
81
82
    def __init__(self, basedir,
82
83
                 branch,
83
84
                 _control_files=None,
251
252
 
252
253
        :return: an integer. -1 means never save.
253
254
        """
254
 
        config = self.branch.get_config()
255
 
        val = config.get_user_option('bzr.workingtree.worth_saving_limit')
256
 
        if val is None:
257
 
            val = self._DEFAULT_WORTH_SAVING_LIMIT
258
 
        else:
259
 
            try:
260
 
                val = int(val)
261
 
            except ValueError, e:
262
 
                trace.warning('Invalid config value for'
263
 
                              ' "bzr.workingtree.worth_saving_limit"'
264
 
                              ' value %r is not an integer.'
265
 
                              % (val,))
266
 
                val = self._DEFAULT_WORTH_SAVING_LIMIT
267
 
        return val
 
255
        # FIXME: We want a WorkingTreeStack here -- vila 20110812
 
256
        conf = config.BranchStack(self.branch)
 
257
        return conf.get('bzr.workingtree.worth_saving_limit')
268
258
 
269
259
    def filter_unversioned_files(self, paths):
270
260
        """Filter out paths that are versioned.
488
478
            return False # Missing entries are not executable
489
479
        return entry[1][0][3] # Executable?
490
480
 
491
 
    if not osutils.supports_executable():
492
 
        def is_executable(self, file_id, path=None):
493
 
            """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.
494
483
 
495
 
            Note: The caller is expected to take a read-lock before calling this.
496
 
            """
 
484
        Note: The caller is expected to take a read-lock before calling this.
 
485
        """
 
486
        if not self._supports_executable():
497
487
            entry = self._get_entry(file_id=file_id, path=path)
498
488
            if entry == (None, None):
499
489
                return False
500
490
            return entry[1][0][3]
501
 
 
502
 
        _is_executable_from_path_and_stat = \
503
 
            _is_executable_from_path_and_stat_from_basis
504
 
    else:
505
 
        def is_executable(self, file_id, path=None):
506
 
            """Test if a file is executable or not.
507
 
 
508
 
            Note: The caller is expected to take a read-lock before calling this.
509
 
            """
 
491
        else:
510
492
            self._must_be_locked()
511
493
            if not path:
512
494
                path = self.id2path(file_id)
981
963
                    all_versioned = False
982
964
                    break
983
965
            if not all_versioned:
984
 
                raise errors.PathsNotVersionedError(paths)
 
966
                raise errors.PathsNotVersionedError(
 
967
                    [p.decode('utf-8') for p in paths])
985
968
        # -- remove redundancy in supplied paths to prevent over-scanning --
986
969
        search_paths = osutils.minimum_path_selection(paths)
987
970
        # sketch:
1036
1019
            found_dir_names = set(dir_name_id[:2] for dir_name_id in found)
1037
1020
            for dir_name in split_paths:
1038
1021
                if dir_name not in found_dir_names:
1039
 
                    raise errors.PathsNotVersionedError(paths)
 
1022
                    raise errors.PathsNotVersionedError(
 
1023
                        [p.decode('utf-8') for p in paths])
1040
1024
 
1041
1025
        for dir_name_id, trees_info in found.iteritems():
1042
1026
            for index in search_indexes:
1458
1442
        return views.PathBasedViews(self)
1459
1443
 
1460
1444
 
1461
 
class DirStateWorkingTreeFormat(WorkingTreeFormat):
 
1445
class DirStateWorkingTreeFormat(WorkingTreeFormatMetaDir):
1462
1446
 
1463
1447
    missing_parent_conflicts = True
1464
1448
 
1620
1604
    This format:
1621
1605
        - exists within a metadir controlling .bzr
1622
1606
        - includes an explicit version marker for the workingtree control
1623
 
          files, separate from the BzrDir format
 
1607
          files, separate from the ControlDir format
1624
1608
        - modifies the hash cache format
1625
1609
        - is new in bzr 0.15
1626
1610
        - uses a LockDir to guard access to it.
1630
1614
 
1631
1615
    _tree_class = WorkingTree4
1632
1616
 
1633
 
    def get_format_string(self):
 
1617
    @classmethod
 
1618
    def get_format_string(cls):
1634
1619
        """See WorkingTreeFormat.get_format_string()."""
1635
1620
        return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
1636
1621
 
1647
1632
 
1648
1633
    _tree_class = WorkingTree5
1649
1634
 
1650
 
    def get_format_string(self):
 
1635
    @classmethod
 
1636
    def get_format_string(cls):
1651
1637
        """See WorkingTreeFormat.get_format_string()."""
1652
1638
        return "Bazaar Working Tree Format 5 (bzr 1.11)\n"
1653
1639
 
1667
1653
 
1668
1654
    _tree_class = WorkingTree6
1669
1655
 
1670
 
    def get_format_string(self):
 
1656
    @classmethod
 
1657
    def get_format_string(cls):
1671
1658
        """See WorkingTreeFormat.get_format_string()."""
1672
1659
        return "Bazaar Working Tree Format 6 (bzr 1.14)\n"
1673
1660
 
1861
1848
        # Make sure the file exists
1862
1849
        entry = self._get_entry(file_id, path=path)
1863
1850
        if entry == (None, None): # do we raise?
1864
 
            return None
 
1851
            raise errors.NoSuchId(self, file_id)
1865
1852
        parent_index = self._get_parent_index()
1866
1853
        last_changed_revision = entry[1][parent_index][4]
1867
1854
        try:
2186
2173
                path_entries = state._entries_for_path(path)
2187
2174
                if not path_entries:
2188
2175
                    # this specified path is not present at all: error
2189
 
                    not_versioned.append(path)
 
2176
                    not_versioned.append(path.decode('utf-8'))
2190
2177
                    continue
2191
2178
                found_versioned = False
2192
2179
                # for each id at this path
2200
2187
                if not found_versioned:
2201
2188
                    # none of the indexes was not 'absent' at all ids for this
2202
2189
                    # path.
2203
 
                    not_versioned.append(path)
 
2190
                    not_versioned.append(path.decode('utf-8'))
2204
2191
            if len(not_versioned) > 0:
2205
2192
                raise errors.PathsNotVersionedError(not_versioned)
2206
2193
        # -- remove redundancy in supplied specific_files to prevent over-scanning --