~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2005-10-03 02:54:29 UTC
  • mto: (1393.1.30)
  • mto: This revision was merged to the branch mainline in revision 1400.
  • Revision ID: robertc@robertcollins.net-20051003025429-a9a2b4544b48cdd4
push kind character creation into InventoryEntry and TreeEntry

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
    """
 
41
 
 
42
    def __eq__(self, other):
 
43
        # yes, this us ugly, TODO: best practice __eq__ style.
 
44
        return (isinstance(other, TreeEntry)
 
45
                and other.__class__ == self.__class__)
 
46
 
 
47
    def kind_character(self):
 
48
        return "???"
 
49
 
 
50
 
 
51
class TreeDirectory(TreeEntry):
 
52
    """See TreeEntry. This is a directory in a working tree."""
 
53
 
 
54
    def __eq__(self, other):
 
55
        return (isinstance(other, TreeDirectory)
 
56
                and other.__class__ == self.__class__)
 
57
 
 
58
    def kind_character(self):
 
59
        return "/"
 
60
 
 
61
 
 
62
class TreeFile(TreeEntry):
 
63
    """See TreeEntry. This is a regular file in a working tree."""
 
64
 
 
65
    def __eq__(self, other):
 
66
        return (isinstance(other, TreeFile)
 
67
                and other.__class__ == self.__class__)
 
68
 
 
69
    def kind_character(self):
 
70
        return ''
 
71
 
 
72
 
 
73
class TreeLink(TreeEntry):
 
74
    """See TreeEntry. This is a symlink in a working tree."""
 
75
 
 
76
    def __eq__(self, other):
 
77
        return (isinstance(other, TreeLink)
 
78
                and other.__class__ == self.__class__)
 
79
 
 
80
    def kind_character(self):
 
81
        return ''
 
82
 
 
83
 
32
84
class WorkingTree(bzrlib.tree.Tree):
33
85
    """Working copy tree.
34
86
 
185
237
                                            "now of kind %r"
186
238
                                            % (fap, f_ie.kind, f_ie.file_id, fk))
187
239
 
188
 
                yield fp, c, fk, (f_ie and f_ie.file_id)
 
240
                # make a last minute entry
 
241
                if f_ie:
 
242
                    entry = f_ie
 
243
                else:
 
244
                    if fk == 'directory':
 
245
                        entry = TreeDirectory()
 
246
                    elif fk == 'file':
 
247
                        entry = TreeFile()
 
248
                    elif fk == 'symlink':
 
249
                        entry = TreeLink()
 
250
                    else:
 
251
                        entry = TreeEntry()
 
252
                
 
253
                yield fp, c, fk, (f_ie and f_ie.file_id), entry
189
254
 
190
255
                if fk != 'directory':
191
256
                    continue