~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_3.py

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
"""
20
20
 
21
 
import errno
22
 
 
23
21
from bzrlib import (
24
22
    bzrdir,
25
23
    errors,
26
 
    hashcache,
27
24
    inventory,
28
25
    revision as _mod_revision,
29
 
    trace,
30
26
    transform,
31
27
    )
32
28
from bzrlib.decorators import (
40
36
    WorkingTreeFormat,
41
37
    )
42
38
 
43
 
 
44
 
class PreDirStateWorkingTree(InventoryWorkingTree):
45
 
 
46
 
    def __init__(self, basedir='.', *args, **kwargs):
47
 
        super(PreDirStateWorkingTree, self).__init__(basedir, *args, **kwargs)
48
 
        # update the whole cache up front and write to disk if anything changed;
49
 
        # in the future we might want to do this more selectively
50
 
        # two possible ways offer themselves : in self._unlock, write the cache
51
 
        # if needed, or, when the cache sees a change, append it to the hash
52
 
        # cache file, and have the parser take the most recent entry for a
53
 
        # given path only.
54
 
        wt_trans = self.bzrdir.get_workingtree_transport(None)
55
 
        cache_filename = wt_trans.local_abspath('stat-cache')
56
 
        self._hashcache = hashcache.HashCache(basedir, cache_filename,
57
 
            self.bzrdir._get_file_mode(),
58
 
            self._content_filter_stack_provider())
59
 
        hc = self._hashcache
60
 
        hc.read()
61
 
        # is this scan needed ? it makes things kinda slow.
62
 
        #hc.scan()
63
 
 
64
 
        if hc.needs_write:
65
 
            trace.mutter("write hc")
66
 
            hc.write()
67
 
 
68
 
    def _write_hashcache_if_dirty(self):
69
 
        """Write out the hashcache if it is dirty."""
70
 
        if self._hashcache.needs_write:
71
 
            try:
72
 
                self._hashcache.write()
73
 
            except OSError, e:
74
 
                if e.errno not in (errno.EPERM, errno.EACCES):
75
 
                    raise
76
 
                # TODO: jam 20061219 Should this be a warning? A single line
77
 
                #       warning might be sufficient to let the user know what
78
 
                #       is going on.
79
 
                trace.mutter('Could not write hashcache for %s\nError: %s',
80
 
                              self._hashcache.cache_file_name(), e)
81
 
 
82
 
    @needs_read_lock
83
 
    def get_file_sha1(self, file_id, path=None, stat_value=None):
84
 
        if not path:
85
 
            path = self._inventory.id2path(file_id)
86
 
        return self._hashcache.get_sha1(path, stat_value)
87
 
 
88
 
 
89
 
class WorkingTree3(PreDirStateWorkingTree):
 
39
class WorkingTree3(InventoryWorkingTree):
90
40
    """This is the Format 3 working tree.
91
41
 
92
42
    This differs from the base WorkingTree by:
152
102
 
153
103
    missing_parent_conflicts = True
154
104
 
155
 
    supports_versioned_directories = True
156
 
 
157
105
    def get_format_string(self):
158
106
        """See WorkingTreeFormat.get_format_string()."""
159
107
        return "Bazaar-NG Working Tree format 3"