~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml4.py

  • Committer: Martin Pool
  • Date: 2005-09-29 05:06:14 UTC
  • mto: (1185.12.2) (1393.1.12)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: mbp@sourcefrog.net-20050929050614-a41e6f72af36bb4c
- better error on failing to import bzrlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
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
15
17
 
16
18
from bzrlib.xml import ElementTree, SubElement, Element, Serializer
17
19
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
18
 
import bzrlib.inventory as inventory
19
20
from bzrlib.revision import Revision        
20
21
from bzrlib.errors import BzrError
21
22
 
52
53
        if ie.text_size != None:
53
54
            e.set('text_size', '%d' % ie.text_size)
54
55
 
55
 
        for f in ['text_id', 'text_sha1', 'symlink_target']:
 
56
        for f in ['text_id', 'text_sha1']:
56
57
            v = getattr(ie, f)
57
58
            if v != None:
58
59
                e.set(f, v)
93
94
        if parent_id == None:
94
95
            parent_id = ROOT_ID
95
96
 
96
 
        kind = elt.get('kind')
97
 
        if kind == 'directory':
98
 
            ie = inventory.InventoryDirectory(elt.get('file_id'),
99
 
                                              elt.get('name'),
100
 
                                              parent_id)
101
 
        elif kind == 'file':
102
 
            ie = inventory.InventoryFile(elt.get('file_id'),
103
 
                                         elt.get('name'),
104
 
                                         parent_id)
105
 
            ie.text_id = elt.get('text_id')
106
 
            ie.text_sha1 = elt.get('text_sha1')
107
 
            v = elt.get('text_size')
108
 
            ie.text_size = v and int(v)
109
 
        elif kind == 'symlink':
110
 
            ie = inventory.InventoryLink(elt.get('file_id'),
111
 
                                         elt.get('name'),
112
 
                                         parent_id)
113
 
            ie.symlink_target = elt.get('symlink_target')
114
 
        else:
115
 
            raise BzrError("unknown kind %r" % kind)
116
 
 
117
 
        ## mutter("read inventoryentry: %r", elt.attrib)
 
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
 
 
104
        ## mutter("read inventoryentry: %r" % (elt.attrib))
 
105
 
 
106
        v = elt.get('text_size')
 
107
        ie.text_size = v and int(v)
118
108
 
119
109
        return ie
120
110