/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 breezy/tests/per_repository/test_commit_builder.py

Allow surrogateescape in revprops.

Merged from https://code.launchpad.net/~jelmer/brz/surrogateescape/+merge/385402

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    revision as _mod_revision,
27
27
    tests,
28
28
    )
 
29
from breezy.sixish import PY3
29
30
from breezy.tree import TreeChange
30
31
from breezy.bzr import (
31
32
    inventorytree,
821
822
                          branch, [], branch.get_config_stack(),
822
823
                          revprops={'invalid': u'property\rwith\r\ninvalid chars'})
823
824
 
 
825
    def test_get_commit_builder_with_surrogateescape(self):
 
826
        if not PY3:
 
827
            self.skipTest('python 2 does not have surrogateescape')
 
828
        tree = self.make_branch_and_tree(".")
 
829
        with tree.lock_write():
 
830
            builder = tree.branch.get_commit_builder([], revprops={
 
831
                'invalid': u'property' + b'\xc0'.decode('utf-8', 'surrogateescape')})
 
832
            list(builder.record_iter_changes(tree, tree.last_revision(),
 
833
                                             tree.iter_changes(tree.basis_tree())))
 
834
            builder.finish_inventory()
 
835
            try:
 
836
                rev_id = builder.commit('foo bar blah')
 
837
            except NotImplementedError:
 
838
                raise tests.TestNotApplicable(
 
839
                    'Format does not support revision properties')
 
840
        rev = tree.branch.repository.get_revision(rev_id)
 
841
        self.assertEqual('foo bar blah', rev.message)
 
842
 
824
843
    def test_commit_builder_commit_with_invalid_message(self):
825
844
        branch = self.make_branch('.')
826
845
        branch.repository.lock_write()