~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml4.py

- improved handling of non-ascii branch names and test
  patch from Joel Rosdahl

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
2
 
#
 
1
#! /usr/bin/env python
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
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 bzrlib.xml_serializer import ElementTree, SubElement, Element, Serializer
 
17
 
 
18
from bzrlib.xml import ElementTree, SubElement, Element, Serializer
18
19
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
19
20
import bzrlib.inventory as inventory
20
21
from bzrlib.revision import Revision        
21
22
from bzrlib.errors import BzrError
22
23
 
23
24
 
 
25
 
 
26
 
 
27
 
 
28
 
24
29
class _Serializer_v4(Serializer):
25
30
    """Version 0.0.4 serializer
26
31
 
27
 
    You should use the serializer_v4 singleton."""
 
32
    You should use the serialzer_v4 singleton."""
28
33
    
29
34
    __slots__ = []
30
35
    
31
36
    def _pack_inventory(self, inv):
32
37
        """Convert to XML Element"""
33
 
        # v4 serialization is not used any more.
34
 
        raise NotImplementedError(self._pack_inventory)
35
38
        e = Element('inventory')
36
39
        e.text = '\n'
37
40
        if inv.root.file_id not in (None, ROOT_ID):
48
51
        e.set('file_id', ie.file_id)
49
52
        e.set('kind', ie.kind)
50
53
 
51
 
        if ie.text_size is not None:
 
54
        if ie.text_size != None:
52
55
            e.set('text_size', '%d' % ie.text_size)
53
56
 
54
57
        for f in ['text_id', 'text_sha1', 'symlink_target']:
55
58
            v = getattr(ie, f)
56
 
            if v is not None:
 
59
            if v != None:
57
60
                e.set(f, v)
58
61
 
59
62
        # to be conservative, we don't externalize the root pointers
89
92
        ## nodes in the root directory, but it's cleaner to use one
90
93
        ## internally.
91
94
        parent_id = elt.get('parent_id')
92
 
        if parent_id is None:
 
95
        if parent_id == None:
93
96
            parent_id = ROOT_ID
94
97
 
95
98
        kind = elt.get('kind')
113
116
        else:
114
117
            raise BzrError("unknown kind %r" % kind)
115
118
 
116
 
        ## mutter("read inventoryentry: %r", elt.attrib)
 
119
        ## mutter("read inventoryentry: %r" % (elt.attrib))
117
120
 
118
121
        return ie
119
122