~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml5.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-31 04:52:48 UTC
  • mfrom: (1897.1.2 fix os.walkdirs)
  • Revision ID: pqm@pqm.ubuntu.com-20060731045248-d2a1c838e7fcfc6a
(robertc) Add current-directory information to osutils.walkdirs.

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
4
6
# (at your option) any later version.
5
 
 
 
7
#
6
8
# This program is distributed in the hope that it will be useful,
7
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9
11
# GNU General Public License for more details.
10
 
 
 
12
#
11
13
# You should have received a copy of the GNU General Public License
12
14
# along with this program; if not, write to the Free Software
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
 
30
32
    
31
33
    def _pack_inventory(self, inv):
32
34
        """Convert to XML Element"""
 
35
        entries = inv.iter_entries()
33
36
        e = Element('inventory',
34
37
                    format='5')
35
38
        e.text = '\n'
36
 
        if inv.root.file_id not in (None, ROOT_ID):
37
 
            e.set('file_id', inv.root.file_id)
 
39
        path, root = entries.next()
 
40
        if root.file_id not in (None, ROOT_ID):
 
41
            e.set('file_id', root.file_id)
38
42
        if inv.revision_id is not None:
39
43
            e.set('revision_id', inv.revision_id)
40
 
        for path, ie in inv.iter_entries():
 
44
        for path, ie in entries:
41
45
            e.append(self._pack_entry(ie))
42
46
        return e
43
47
 
197
201
            return
198
202
        for prop_elt in props_elt:
199
203
            assert prop_elt.tag == 'property', \
200
 
                "bad tag under properties list: %r" % p.tag
 
204
                "bad tag under properties list: %r" % prop_elt.tag
201
205
            name = prop_elt.get('name')
202
206
            value = prop_elt.text
203
207
            assert name not in rev.properties, \
204
 
                "repeated property %r" % p.name
 
208
                "repeated property %r" % name
205
209
            rev.properties[name] = value
206
210
 
207
211