~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Jelmer Vernooij
  • Date: 2009-03-31 20:34:33 UTC
  • mto: This revision was merged to the branch mainline in revision 4238.
  • Revision ID: jelmer@samba.org-20090331203433-ncsd0sar9rc7wkqd
Make function for escaping invalid XML characters public.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    revision,
63
63
    trace,
64
64
    tree,
 
65
    xml_serializer,
65
66
    )
66
67
from bzrlib.branch import Branch
67
68
import bzrlib.config
607
608
        # serialiser not by commit. Then we can also add an unescaper
608
609
        # in the deserializer and start roundtripping revision messages
609
610
        # precisely. See repository_implementations/test_repository.py
610
 
 
611
 
        # Python strings can include characters that can't be
612
 
        # represented in well-formed XML; escape characters that
613
 
        # aren't listed in the XML specification
614
 
        # (http://www.w3.org/TR/REC-xml/#NT-Char).
615
 
        self.message, escape_count = re.subn(
616
 
            u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
617
 
            lambda match: match.group(0).encode('unicode_escape'),
 
611
        self.message, escape_count = xml_serializer.escape_invalid_chars(
618
612
            self.message)
619
613
        if escape_count:
620
614
            self.reporter.escaped(escape_count, self.message)