~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

[merge] fix \t in commit messages

Show diffs side-by-side

added added

removed removed

Lines of Context:
237
237
        else:
238
238
            self.timezone = int(timezone)
239
239
 
240
 
        assert isinstance(message, basestring), type(message)
 
240
        if isinstance(message, str):
 
241
            message = message.decode(bzrlib.user_encoding)
 
242
        assert isinstance(message, unicode), type(message)
241
243
        self.message = message
242
244
        self._escape_commit_message()
243
245
 
297
299
        # represented in well-formed XML; escape characters that
298
300
        # aren't listed in the XML specification
299
301
        # (http://www.w3.org/TR/REC-xml/#NT-Char).
300
 
        if isinstance(self.message, unicode):
301
 
            char_pattern = u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]'
302
 
        else:
303
 
            # Use a regular 'str' as pattern to avoid having re.subn
304
 
            # return 'unicode' results.
305
 
            char_pattern = '[^x09\x0A\x0D\x20-\xFF]'
306
302
        self.message, escape_count = re.subn(
307
 
            char_pattern,
 
303
            u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
308
304
            lambda match: match.group(0).encode('unicode_escape'),
309
305
            self.message)
310
306
        if escape_count: