~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Matthieu Moy
  • Date: 2006-07-08 19:32:30 UTC
  • mfrom: (1845 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1857.
  • Revision ID: Matthieu.Moy@imag.fr-20060708193230-3eb72d871471bd5b
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
 
2
#
1
3
# This program is free software; you can redistribute it and/or modify
2
4
# it under the terms of the GNU General Public License as published by
3
5
# the Free Software Foundation; either version 2 of the License, or
13
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14
16
 
15
17
 
16
 
from bzrlib.xml_serializer import ElementTree, SubElement, Element, Serializer
 
18
from bzrlib.xml_serializer import SubElement, Element, Serializer
17
19
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
18
20
import bzrlib.inventory as inventory
19
 
from bzrlib.revision import Revision        
 
21
from bzrlib.revision import Revision
20
22
from bzrlib.errors import BzrError
21
23
 
22
24
 
41
43
            e.append(self._pack_entry(ie))
42
44
        return e
43
45
 
44
 
 
45
46
    def _pack_entry(self, ie):
46
47
        """Convert InventoryEntry to XML element"""
47
48
        # TODO: should just be a plain assertion
68
69
        if ie.parent_id != ROOT_ID:
69
70
            assert isinstance(ie.parent_id, basestring)
70
71
            e.set('parent_id', ie.parent_id)
71
 
 
72
72
        e.tail = '\n'
73
 
 
74
73
        return e
75
74
 
76
 
 
77
75
    def _pack_revision(self, rev):
78
76
        """Revision object -> xml tree"""
79
77
        root = Element('revision',
201
199
            return
202
200
        for prop_elt in props_elt:
203
201
            assert prop_elt.tag == 'property', \
204
 
                "bad tag under properties list: %r" % p.tag
 
202
                "bad tag under properties list: %r" % prop_elt.tag
205
203
            name = prop_elt.get('name')
206
204
            value = prop_elt.text
207
205
            assert name not in rev.properties, \
208
 
                "repeated property %r" % p.name
 
206
                "repeated property %r" % name
209
207
            rev.properties[name] = value
210
208
 
211
209