47
48
super(TestCaseWithRepository, self).setUp()
49
def make_branch(self, relpath):
50
repo = self.make_repository(relpath)
50
def make_branch(self, relpath, format=None):
51
repo = self.make_repository(relpath, format=None)
51
52
return repo.bzrdir.create_branch()
53
def make_bzrdir(self, relpath):
55
url = self.get_url(relpath)
56
segments = url.split('/')
57
if segments and segments[-1] not in ('', '.'):
58
parent = '/'.join(segments[:-1])
59
t = get_transport(parent)
64
return self.bzrdir_format.initialize(url)
65
except UninitializableFormat:
66
raise TestSkipped("Format %s is not initializable.")
68
def make_repository(self, relpath):
54
def make_repository(self, relpath, format=None):
69
55
made_control = self.make_bzrdir(relpath)
70
56
return self.repository_format.initialize(made_control)
251
237
self.assertRaises(errors.OutSideTransaction, inv.add_lines, 'foo', [], [])
239
def test_format_description(self):
240
repo = self.make_repository('.')
241
text = repo._format.get_format_description()
242
self.failUnless(len(text))
244
def assertMessageRoundtrips(self, message):
245
"""Assert that message roundtrips to a repository and back intact."""
246
tree = self.make_branch_and_tree('.')
247
tree.commit(message, rev_id='a', allow_pointless=True)
248
rev = tree.branch.repository.get_revision('a')
249
# we have to manually escape this as we dont try to
250
# roundtrip xml invalid characters at this point.
251
# when escaping is moved to the serialiser, this test
252
# can check against the literal message rather than
253
# this escaped version.
254
escaped_message, escape_count = re.subn(
255
u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
256
lambda match: match.group(0).encode('unicode_escape'),
258
escaped_message= re.sub('\r', '\n', escaped_message)
259
self.assertEqual(rev.message, escaped_message)
260
# insist the class is unicode no matter what came in for
262
self.assertIsInstance(rev.message, unicode)
264
def test_commit_unicode_message(self):
265
# a siple unicode message should be preserved
266
self.assertMessageRoundtrips(u'foo bar gamm\xae plop')
268
def test_commit_unicode_control_characters(self):
269
# a unicode message with control characters should roundtrip too.
270
self.assertMessageRoundtrips(
271
"All 8-bit chars: " + ''.join([unichr(x) for x in range(256)]))
254
273
class TestCaseWithComplexRepository(TestCaseWithRepository):