~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml_serializer.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-10 18:57:20 UTC
  • mfrom: (1910.2.48 format-bumps)
  • Revision ID: pqm@pqm.ubuntu.com-20060910185720-1bcc17b99fe77687
Add new format to support nested trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
                                              fromstring, tostring)
37
37
    import util.elementtree as elementtree
38
38
 
39
 
from bzrlib.errors import BzrError
 
39
from bzrlib import errors
40
40
 
41
41
 
42
42
class Serializer(object):
50
50
        return tostring(self._pack_inventory(inv)) + '\n'
51
51
 
52
52
    def read_inventory_from_string(self, xml_string):
53
 
        return self._unpack_inventory(fromstring(xml_string))
 
53
        try:
 
54
            return self._unpack_inventory(fromstring(xml_string))
 
55
        except SyntaxError, e:
 
56
            raise errors.UnexpectedInventoryFormat(e)
54
57
 
55
58
    def read_inventory(self, f):
56
 
        return self._unpack_inventory(self._read_element(f))
 
59
        try:
 
60
            return self._unpack_inventory(self._read_element(f))
 
61
        except SyntaxError, e:
 
62
            raise errors.UnexpectedInventoryFormat(e)
57
63
 
58
64
    def write_revision(self, rev, f):
59
65
        self._write_element(self._pack_revision(rev), f)