/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Aaron Bentley
  • Date: 2005-10-03 19:50:36 UTC
  • mfrom: (1399)
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: abentley@panoramicfeedback.com-20051003195036-28dbd56f0e852b08
Merged latest from Robert Collins

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
# it's not predictable when it will be written out.
22
22
 
23
23
import os
24
 
    
 
24
import stat
 
25
import fnmatch
 
26
        
25
27
import bzrlib.tree
26
 
from errors import BzrCheckError
27
 
from trace import mutter
 
28
from bzrlib.osutils import appendpath, file_kind, isdir, splitpath
 
29
from bzrlib.errors import BzrCheckError
 
30
from bzrlib.trace import mutter
28
31
 
29
32
class WorkingTree(bzrlib.tree.Tree):
30
33
    """Working copy tree.
67
70
        """
68
71
        inv = self._inventory
69
72
        for path, ie in inv.iter_entries():
70
 
            if os.path.exists(self.abspath(path)):
 
73
            if bzrlib.osutils.lexists(self.abspath(path)):
71
74
                yield ie.file_id
72
75
 
73
76
 
81
84
        return os.path.join(self.basedir, filename)
82
85
 
83
86
    def has_filename(self, filename):
84
 
        return os.path.exists(self.abspath(filename))
 
87
        return bzrlib.osutils.lexists(self.abspath(filename))
85
88
 
86
89
    def get_file(self, file_id):
87
90
        return self.get_file_byname(self.id2path(file_id))
93
96
        ## XXX: badly named; this isn't in the store at all
94
97
        return self.abspath(self.id2path(file_id))
95
98
 
 
99
 
 
100
    def id2abspath(self, file_id):
 
101
        return self.abspath(self.id2path(file_id))
 
102
 
96
103
                
97
104
    def has_id(self, file_id):
98
105
        # files that have been deleted are excluded
100
107
        if not inv.has_id(file_id):
101
108
            return False
102
109
        path = inv.id2path(file_id)
103
 
        return os.path.exists(self.abspath(path))
 
110
        return bzrlib.osutils.lexists(self.abspath(path))
104
111
 
105
112
 
106
113
    __contains__ = has_id
107
114
    
108
115
 
109
116
    def get_file_size(self, file_id):
110
 
        # is this still called?
111
 
        raise NotImplementedError()
112
 
 
 
117
        return os.path.getsize(self.id2abspath(file_id))
113
118
 
114
119
    def get_file_sha1(self, file_id):
115
120
        path = self._inventory.id2path(file_id)
116
121
        return self._hashcache.get_sha1(path)
117
122
 
118
123
 
 
124
    def is_executable(self, file_id):
 
125
        if os.name == "nt":
 
126
            return self._inventory[file_id].executable
 
127
        else:
 
128
            path = self._inventory.id2path(file_id)
 
129
            mode = os.lstat(self.abspath(path)).st_mode
 
130
            return bool(stat.S_ISREG(mode) and stat.S_IEXEC&mode)
 
131
 
 
132
    def get_symlink_target(self, file_id):
 
133
        return os.readlink(self.id2path(file_id))
 
134
 
119
135
    def file_class(self, filename):
120
136
        if self.path2id(filename):
121
137
            return 'V'
135
151
 
136
152
        Skips the control directory.
137
153
        """
138
 
        from osutils import appendpath, file_kind
139
 
        import os
140
 
 
141
154
        inv = self._inventory
142
155
 
143
156
        def descend(from_dir_relpath, from_dir_id, dp):
205
218
        Currently returned depth-first, sorted by name within directories.
206
219
        """
207
220
        ## TODO: Work from given directory downwards
208
 
        from osutils import isdir, appendpath
209
 
        
210
221
        for path, dir_entry in self.inventory.directories():
211
222
            mutter("search for unknowns in %r" % path)
212
223
            dirabs = self.abspath(path)
269
280
        # Eventually it should be replaced with something more
270
281
        # accurate.
271
282
        
272
 
        import fnmatch
273
 
        from osutils import splitpath
274
 
        
275
283
        for pat in self.get_ignore_list():
276
284
            if '/' in pat or '\\' in pat:
277
285
                
290
298
                    return pat
291
299
        else:
292
300
            return None
293
 
        
 
 
b'\\ No newline at end of file'
 
301