/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-01 06:48:01 UTC
  • mto: (1185.12.13)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: aaron.bentley@utoronto.ca-20051001064801-7400c2ed0fe26080
Made iter_conflicts a WorkingTree method

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 fnmatch
 
25
        
25
26
import bzrlib.tree
26
 
from errors import BzrCheckError
27
 
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
28
30
 
29
31
class WorkingTree(bzrlib.tree.Tree):
30
32
    """Working copy tree.
93
95
        ## XXX: badly named; this isn't in the store at all
94
96
        return self.abspath(self.id2path(file_id))
95
97
 
 
98
 
 
99
    def id2abspath(self, file_id):
 
100
        return self.abspath(self.id2path(file_id))
 
101
 
96
102
                
97
103
    def has_id(self, file_id):
98
104
        # files that have been deleted are excluded
107
113
    
108
114
 
109
115
    def get_file_size(self, file_id):
110
 
        # is this still called?
111
 
        raise NotImplementedError()
 
116
        return os.path.getsize(self.id2abspath(file_id))
112
117
 
113
118
 
114
119
    def get_file_sha1(self, file_id):
135
140
 
136
141
        Skips the control directory.
137
142
        """
138
 
        from osutils import appendpath, file_kind
139
 
        import os
140
 
 
141
143
        inv = self._inventory
142
144
 
143
145
        def descend(from_dir_relpath, from_dir_id, dp):
194
196
            if not self.is_ignored(subp):
195
197
                yield subp
196
198
 
 
199
    def iter_conflicts(self):
 
200
        conflicted = set()
 
201
        for path in (s[0] for s in self.list_files()):
 
202
            stem = get_conflicted_stem(path)
 
203
            if stem is None:
 
204
                continue
 
205
            if stem not in conflicted:
 
206
                conflicted.add(stem)
 
207
                yield stem
197
208
 
198
209
    def extras(self):
199
210
        """Yield all unknown files in this WorkingTree.
205
216
        Currently returned depth-first, sorted by name within directories.
206
217
        """
207
218
        ## TODO: Work from given directory downwards
208
 
        from osutils import isdir, appendpath
209
 
        
210
219
        for path, dir_entry in self.inventory.directories():
211
220
            mutter("search for unknowns in %r" % path)
212
221
            dirabs = self.abspath(path)
269
278
        # Eventually it should be replaced with something more
270
279
        # accurate.
271
280
        
272
 
        import fnmatch
273
 
        from osutils import splitpath
274
 
        
275
281
        for pat in self.get_ignore_list():
276
282
            if '/' in pat or '\\' in pat:
277
283
                
290
296
                    return pat
291
297
        else:
292
298
            return None
293
 
        
 
 
b'\\ No newline at end of file'
 
299
 
 
300
CONFLICT_SUFFIXES = ('.THIS', '.BASE', '.OTHER')
 
301
def get_conflicted_stem(path):
 
302
    for suffix in CONFLICT_SUFFIXES:
 
303
        if path.endswith(suffix):
 
304
            return path[:-len(suffix)]