~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml8.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import cStringIO
18
18
import re
24
24
    revision as _mod_revision,
25
25
    trace,
26
26
    )
27
 
from bzrlib.xml_serializer import SubElement, Element, Serializer
 
27
from bzrlib.xml_serializer import (
 
28
    Element,
 
29
    SubElement,
 
30
    XMLSerializer,
 
31
    )
28
32
from bzrlib.inventory import ROOT_ID, Inventory, InventoryEntry
29
33
from bzrlib.revision import Revision
30
34
from bzrlib.errors import BzrError
92
96
    # to check if None, rather than try/KeyError
93
97
    text = _map.get(unicode_or_utf8_str)
94
98
    if text is None:
95
 
        if unicode_or_utf8_str.__class__ == unicode:
 
99
        if unicode_or_utf8_str.__class__ is unicode:
96
100
            # The alternative policy is to do a regular UTF8 encoding
97
101
            # and then escape only XML meta characters.
98
102
            # Performance is equivalent once you use cache_utf8. *However*
128
132
    # This is fairly optimized because we know what cElementTree does, this is
129
133
    # not meant as a generic function for all cases. Because it is possible for
130
134
    # an 8-bit string to not be ascii or valid utf8.
131
 
    if a_str.__class__ == unicode:
 
135
    if a_str.__class__ is unicode:
132
136
        return _encode_utf8(a_str)
133
137
    else:
134
 
        return _get_cached_ascii(a_str)
 
138
        return intern(a_str)
135
139
 
136
140
 
137
141
def _clear_cache():
139
143
    _to_escaped_map.clear()
140
144
 
141
145
 
142
 
class Serializer_v8(Serializer):
 
146
class Serializer_v8(XMLSerializer):
143
147
    """This serialiser adds rich roots.
144
148
 
145
149
    Its revision format number matches its inventory number.
211
215
 
212
216
    def write_inventory(self, inv, f, working=False):
213
217
        """Write inventory to a file.
214
 
        
 
218
 
215
219
        :param inv: the inventory to write.
216
220
        :param f: the file to write. (May be None if the lines are the desired
217
221
            output).