~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to contrib/newinventory.py

  • Committer: Robert Collins
  • Date: 2005-10-16 00:22:17 UTC
  • mto: This revision was merged to the branch mainline in revision 1457.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016002217-aa38f9c1eb13ee48
Plugins are now loaded under bzrlib.plugins, not bzrlib.plugin.

Plugins are also made available for other plugins to use by making them 
accessible via import bzrlib.plugins.NAME. You should not import other
plugins during the __init__ of your plugin though, as no ordering is
guaranteed, and the plugins directory is not on the python path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from cElementTree import Element, ElementTree, SubElement
 
17
from bzrlib.xml import ElementTree, Element
18
18
 
19
19
 
20
20
def write_inventory(inv, f):
21
21
    el = Element('inventory', {'version': '2'})
22
22
    el.text = '\n'
23
 
    
 
23
 
24
24
    root = Element('root_directory', {'id': inv.root.file_id})
25
25
    root.tail = root.text = '\n'
26
26
    el.append(root)
38
38
            if ie.text_size != None:
39
39
                el.set('text_size', ('%d' % ie.text_size))
40
40
        elif kind != 'directory':
41
 
            bailout('unknown InventoryEntry kind %r' % kind)
 
41
            raise BzrError('unknown InventoryEntry kind %r' % kind)
42
42
 
43
43
        el.tail = '\n'
44
44
        parent_el.append(el)
97
97
 
98
98
            f.write('</directory>\n')
99
99
        else:
100
 
            bailout('unknown InventoryEntry kind %r' % kind)
 
100
            raise BzrError('unknown InventoryEntry kind %r' % kind)
101
101
 
102
102
    f.write('<inventory>\n')
103
103
    f.write('<root_directory id="%s">\n' % escape_attr(inv.root.file_id))
132
132
            ie.text_size = v and int(v)
133
133
            ie.text_sha1 = el.get('text_sha1')
134
134
        else:
135
 
            bailout("unknown inventory entry %r" % kind)
 
135
            raise BzrError("unknown inventory entry %r" % kind)
136
136
 
137
137
    inv_el = ElementTree().parse(f)
138
138
    assert inv_el.tag == 'inventory'
139
139
    root_el = inv_el[0]
140
140
    assert root_el.tag == 'root_directory'
141
141
 
142
 
    inv = Inventory()
 
142
    inv = Inventory(inv_el.get('file_id'))
143
143
    for el in root_el:
144
144
        descend(inv.root, el)