~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml4.py

  • Committer: Robert Collins
  • Date: 2005-10-03 05:54:35 UTC
  • mto: (1393.1.30)
  • mto: This revision was merged to the branch mainline in revision 1400.
  • Revision ID: robertc@robertcollins.net-20051003055434-c8ebd30d1de10247
move exporting functionality into inventory.py - uncovers bug in symlink support

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
21
20
from bzrlib.revision import Revision        
22
21
from bzrlib.errors import BzrError
23
22
 
95
94
        if parent_id == None:
96
95
            parent_id = ROOT_ID
97
96
 
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)
 
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')
118
104
 
119
105
        ## mutter("read inventoryentry: %r" % (elt.attrib))
120
106
 
 
107
        v = elt.get('text_size')
 
108
        ie.text_size = v and int(v)
 
109
 
121
110
        return ie
122
111
 
123
112