~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml4.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:
17
17
 
18
18
from bzrlib.xml import ElementTree, SubElement, Element, Serializer
19
19
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
 
20
import bzrlib.inventory as inventory
20
21
from bzrlib.revision import Revision        
21
22
from bzrlib.errors import BzrError
22
23
 
94
95
        if parent_id == None:
95
96
            parent_id = ROOT_ID
96
97
 
97
 
        ie = InventoryEntry(elt.get('file_id'),
98
 
                            elt.get('name'),
99
 
                            elt.get('kind'),
100
 
                            parent_id)
101
 
        ie.text_id = elt.get('text_id')
102
 
        ie.text_sha1 = elt.get('text_sha1')
103
 
        ie.symlink_target = elt.get('symlink_target')
 
98
        kind = elt.get('kind')
 
99
        if kind == 'directory':
 
100
            ie = inventory.InventoryDirectory(elt.get('file_id'),
 
101
                                              elt.get('name'),
 
102
                                              parent_id)
 
103
        elif kind == 'file':
 
104
            ie = inventory.InventoryFile(elt.get('file_id'),
 
105
                                         elt.get('name'),
 
106
                                         parent_id)
 
107
            ie.text_id = elt.get('text_id')
 
108
            ie.text_sha1 = elt.get('text_sha1')
 
109
            v = elt.get('text_size')
 
110
            ie.text_size = v and int(v)
 
111
        elif kind == 'symlink':
 
112
            ie = inventory.InventoryLink(elt.get('file_id'),
 
113
                                         elt.get('name'),
 
114
                                         parent_id)
 
115
            ie.symlink_target = elt.get('symlink_target')
 
116
        else:
 
117
            raise BzrError("unknown kind %r" % kind)
104
118
 
105
119
        ## mutter("read inventoryentry: %r" % (elt.attrib))
106
120
 
107
 
        v = elt.get('text_size')
108
 
        ie.text_size = v and int(v)
109
 
 
110
121
        return ie
111
122
 
112
123