~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Robert Collins
  • Date: 2005-10-03 14:28:37 UTC
  • mto: (1393.1.30)
  • mto: This revision was merged to the branch mainline in revision 1400.
  • Revision ID: robertc@robertcollins.net-20051003142837-78bf906d4edcbd62
factor out inventory directory logic into 'InventoryDirectory' class

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
 
125
126
        if parent_id == None:
126
127
            parent_id = ROOT_ID
127
128
 
128
 
        ie = InventoryEntry(elt.get('file_id'),
129
 
                            elt.get('name'),
130
 
                            kind,
131
 
                            parent_id)
 
129
        if kind == 'directory':
 
130
            ie = inventory.InventoryDirectory(elt.get('file_id'),
 
131
                                              elt.get('name'),
 
132
                                              parent_id)
 
133
        else:
 
134
            ie = InventoryEntry(elt.get('file_id'),
 
135
                                elt.get('name'),
 
136
                                kind,
 
137
                                parent_id)
 
138
            ie.text_sha1 = elt.get('text_sha1')
 
139
            ie.symlink_target = elt.get('symlink_target')
 
140
            if elt.get('executable') == 'yes':
 
141
                ie.executable = True
 
142
            v = elt.get('text_size')
 
143
            ie.text_size = v and int(v)
132
144
        ie.revision = elt.get('revision')
133
 
        ie.text_sha1 = elt.get('text_sha1')
134
 
        ie.symlink_target = elt.get('symlink_target')
135
 
        if elt.get('executable') == 'yes':
136
 
            ie.executable = True
137
 
        v = elt.get('text_size')
138
 
        ie.text_size = v and int(v)
139
145
 
140
146
        return ie
141
147