/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/xml4.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
19
 
from ...bzr.xml_serializer import (
 
17
from bzrlib.xml_serializer import (
20
18
    Element,
21
19
    SubElement,
22
20
    XMLSerializer,
23
21
    escape_invalid_chars,
24
22
    )
25
 
from ...bzr.inventory import ROOT_ID, Inventory
26
 
from ...bzr import inventory
27
 
from ...revision import Revision
28
 
from ...errors import BzrError
 
23
from bzrlib.inventory import ROOT_ID, Inventory
 
24
import bzrlib.inventory as inventory
 
25
from bzrlib.revision import Revision
 
26
from bzrlib.errors import BzrError
29
27
 
30
28
 
31
29
class _Serializer_v4(XMLSerializer):
42
40
        """Convert InventoryEntry to XML element"""
43
41
        e = Element('entry')
44
42
        e.set('name', ie.name)
45
 
        e.set('file_id', ie.file_id.decode('ascii'))
 
43
        e.set('file_id', ie.file_id)
46
44
        e.set('kind', ie.kind)
47
45
 
48
46
        if ie.text_size is not None:
70
68
 
71
69
        :param revision_id: Ignored parameter used by xml5.
72
70
        """
73
 
        root_id = elt.get('file_id')
74
 
        root_id = (root_id.encode('ascii') if root_id else ROOT_ID)
 
71
        root_id = elt.get('file_id') or ROOT_ID
75
72
        inv = Inventory(root_id)
76
73
        for e in elt:
77
74
            ie = self._unpack_entry(e, entry_cache=entry_cache,
87
84
        ## nodes in the root directory, but it's cleaner to use one
88
85
        ## internally.
89
86
        parent_id = elt.get('parent_id')
90
 
        parent_id = (parent_id.encode('ascii') if parent_id else ROOT_ID)
 
87
        if parent_id is None:
 
88
            parent_id = ROOT_ID
91
89
 
92
 
        file_id = elt.get('file_id').encode('ascii')
93
90
        kind = elt.get('kind')
94
91
        if kind == 'directory':
95
 
            ie = inventory.InventoryDirectory(file_id,
 
92
            ie = inventory.InventoryDirectory(elt.get('file_id'),
96
93
                                              elt.get('name'),
97
94
                                              parent_id)
98
95
        elif kind == 'file':
99
 
            ie = inventory.InventoryFile(file_id,
 
96
            ie = inventory.InventoryFile(elt.get('file_id'),
100
97
                                         elt.get('name'),
101
98
                                         parent_id)
102
99
            ie.text_id = elt.get('text_id')
103
 
            if ie.text_id is not None:
104
 
                ie.text_id = ie.text_id.encode('utf-8')
105
100
            ie.text_sha1 = elt.get('text_sha1')
106
 
            if ie.text_sha1 is not None:
107
 
                ie.text_sha1 = ie.text_sha1.encode('ascii')
108
101
            v = elt.get('text_size')
109
102
            ie.text_size = v and int(v)
110
103
        elif kind == 'symlink':
111
 
            ie = inventory.InventoryLink(file_id,
 
104
            ie = inventory.InventoryLink(elt.get('file_id'),
112
105
                                         elt.get('name'),
113
106
                                         parent_id)
114
107
            ie.symlink_target = elt.get('symlink_target')