~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
# TODO: Don't allow WorkingTrees to be constructed for remote branches.
18
18
 
 
19
# FIXME: I don't know if writing out the cache from the destructor is really a
 
20
# good idea, because destructors are considered poor taste in Python, and
 
21
# it's not predictable when it will be written out.
 
22
 
19
23
import os
20
 
    
 
24
import fnmatch
 
25
        
21
26
import bzrlib.tree
22
 
from errors import BzrCheckError
23
 
from trace import mutter
 
27
from bzrlib.osutils import appendpath, file_kind, isdir, splitpath
 
28
from bzrlib.errors import BzrCheckError
 
29
from bzrlib.trace import mutter
24
30
 
25
31
class WorkingTree(bzrlib.tree.Tree):
26
32
    """Working copy tree.
43
49
        # in the future we might want to do this more selectively
44
50
        hc = self._hashcache = HashCache(basedir)
45
51
        hc.read()
46
 
        for path, ie in inv.iter_entries():
47
 
            hc.get_sha1(path)
 
52
        hc.scan()
48
53
 
49
54
        if hc.needs_write:
50
55
            mutter("write hc")
51
56
            hc.write()
52
 
 
 
57
            
 
58
            
 
59
    def __del__(self):
 
60
        if self._hashcache.needs_write:
 
61
            self._hashcache.write()
53
62
 
54
63
 
55
64
    def __iter__(self):
66
75
 
67
76
    def __repr__(self):
68
77
        return "<%s of %s>" % (self.__class__.__name__,
69
 
                               self.basedir)
 
78
                               getattr(self, 'basedir', None))
70
79
 
71
80
 
72
81
 
128
137
 
129
138
        Skips the control directory.
130
139
        """
131
 
        from osutils import appendpath, file_kind
132
 
        import os
133
 
 
134
140
        inv = self._inventory
135
141
 
136
142
        def descend(from_dir_relpath, from_dir_id, dp):
198
204
        Currently returned depth-first, sorted by name within directories.
199
205
        """
200
206
        ## TODO: Work from given directory downwards
201
 
        from osutils import isdir, appendpath
202
 
        
203
207
        for path, dir_entry in self.inventory.directories():
204
208
            mutter("search for unknowns in %r" % path)
205
209
            dirabs = self.abspath(path)
262
266
        # Eventually it should be replaced with something more
263
267
        # accurate.
264
268
        
265
 
        import fnmatch
266
 
        from osutils import splitpath
267
 
        
268
269
        for pat in self.get_ignore_list():
269
270
            if '/' in pat or '\\' in pat:
270
271
                
284
285
        else:
285
286
            return None
286
287
        
287
 
 
288
 
        
289
 
        
290