~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2005-10-04 03:35:31 UTC
  • mfrom: (1393.1.30)
  • Revision ID: robertc@robertcollins.net-20051004033531-f057603b470ca4a2
merge from mpool

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.errors import BzrCheckError
30
30
from bzrlib.trace import mutter
31
31
 
 
32
class TreeEntry(object):
 
33
    """An entry that implements the minium interface used by commands.
 
34
 
 
35
    This needs further inspection, it may be better to have 
 
36
    InventoryEntries without ids - though that seems wrong. For now,
 
37
    this is a parallel hierarchy to InventoryEntry, and needs to become
 
38
    one of several things: decorates to that hierarchy, children of, or
 
39
    parents of it.
 
40
    Another note is that these objects are currently only used when there is
 
41
    no InventoryEntry available - i.e. for unversioned objects.
 
42
    Perhaps they should be UnversionedEntry et al. ? - RBC 20051003
 
43
    """
 
44
 
 
45
    def __eq__(self, other):
 
46
        # yes, this us ugly, TODO: best practice __eq__ style.
 
47
        return (isinstance(other, TreeEntry)
 
48
                and other.__class__ == self.__class__)
 
49
 
 
50
    def kind_character(self):
 
51
        return "???"
 
52
 
 
53
 
 
54
class TreeDirectory(TreeEntry):
 
55
    """See TreeEntry. This is a directory in a working tree."""
 
56
 
 
57
    def __eq__(self, other):
 
58
        return (isinstance(other, TreeDirectory)
 
59
                and other.__class__ == self.__class__)
 
60
 
 
61
    def kind_character(self):
 
62
        return "/"
 
63
 
 
64
 
 
65
class TreeFile(TreeEntry):
 
66
    """See TreeEntry. This is a regular file in a working tree."""
 
67
 
 
68
    def __eq__(self, other):
 
69
        return (isinstance(other, TreeFile)
 
70
                and other.__class__ == self.__class__)
 
71
 
 
72
    def kind_character(self):
 
73
        return ''
 
74
 
 
75
 
 
76
class TreeLink(TreeEntry):
 
77
    """See TreeEntry. This is a symlink in a working tree."""
 
78
 
 
79
    def __eq__(self, other):
 
80
        return (isinstance(other, TreeLink)
 
81
                and other.__class__ == self.__class__)
 
82
 
 
83
    def kind_character(self):
 
84
        return ''
 
85
 
 
86
 
32
87
class WorkingTree(bzrlib.tree.Tree):
33
88
    """Working copy tree.
34
89
 
185
240
                                            "now of kind %r"
186
241
                                            % (fap, f_ie.kind, f_ie.file_id, fk))
187
242
 
188
 
                yield fp, c, fk, (f_ie and f_ie.file_id)
 
243
                # make a last minute entry
 
244
                if f_ie:
 
245
                    entry = f_ie
 
246
                else:
 
247
                    if fk == 'directory':
 
248
                        entry = TreeDirectory()
 
249
                    elif fk == 'file':
 
250
                        entry = TreeFile()
 
251
                    elif fk == 'symlink':
 
252
                        entry = TreeLink()
 
253
                    else:
 
254
                        entry = TreeEntry()
 
255
                
 
256
                yield fp, c, fk, (f_ie and f_ie.file_id), entry
189
257
 
190
258
                if fk != 'directory':
191
259
                    continue