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

  • Committer: Ian Clatworthy
  • Date: 2009-02-18 01:09:34 UTC
  • mto: (0.64.117 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090218010934-dn6xdnq78u1egdf7
move escape_commit_message into helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
        for path in paths[2:]:
101
101
            common = common_path(common, path)
102
102
        return get_dir_with_slash(common)
 
103
 
 
104
 
 
105
def escape_commit_message(message):
 
106
    """Replace xml-incompatible control characters."""
 
107
    # This really ought to be provided by bzrlib.
 
108
    # Code copied from bzrlib.commit.
 
109
    
 
110
    # Python strings can include characters that can't be
 
111
    # represented in well-formed XML; escape characters that
 
112
    # aren't listed in the XML specification
 
113
    # (http://www.w3.org/TR/REC-xml/#NT-Char).
 
114
    import re
 
115
    message, _ = re.subn(
 
116
        u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
 
117
        lambda match: match.group(0).encode('unicode_escape'),
 
118
        message)
 
119
    return message