/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 __init__.py

  • Committer: Jelmer Vernooij
  • Date: 2008-11-05 20:14:28 UTC
  • mto: (0.205.17 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20081105201428-wdna6mc47zdeb0w6
Import escape commit message function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
    suite.addTest(loader.loadTestsFromModuleNames(testmod_names))
173
173
    return suite
174
174
 
 
175
def escape_commit_message(message):
 
176
    """Replace xml-incompatible control characters."""
 
177
    if message is None:
 
178
        return None
 
179
    import re
 
180
    # FIXME: RBC 20060419 this should be done by the revision
 
181
    # serialiser not by commit. Then we can also add an unescaper
 
182
    # in the deserializer and start roundtripping revision messages
 
183
    # precisely. See repository_implementations/test_repository.py
 
184
    
 
185
    # Python strings can include characters that can't be
 
186
    # represented in well-formed XML; escape characters that
 
187
    # aren't listed in the XML specification
 
188
    # (http://www.w3.org/TR/REC-xml/#NT-Char).
 
189
    message, _ = re.subn(
 
190
        u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
 
191
        lambda match: match.group(0).encode('unicode_escape'),
 
192
        message)
 
193
    return message
 
194
 
 
195
 
 
196