135
135
:param empty_tree: A working tree with no content and no parents to
138
empty_tree.set_root_id('empty-root-id')
138
if empty_tree.supports_setting_file_ids():
139
empty_tree.set_root_id(b'empty-root-id')
139
140
return self._convert_tree(empty_tree, converter)
141
142
def _make_abc_tree(self, tree):
143
144
files = ['a', 'b/', 'b/c']
144
145
self.build_tree(files, line_endings='binary',
145
146
transport=tree.controldir.root_transport)
146
tree.set_root_id('root-id')
147
tree.add(files, ['a-id', 'b-id', 'c-id'])
149
149
def get_tree_no_parents_abc_content(self, tree, converter=None):
150
150
"""return a test tree with a, b/, b/c contents."""
221
221
self._make_abc_tree(tree)
222
222
self.build_tree(['d/'], transport=tree.controldir.root_transport)
223
tree.add(['d'], ['d-id'])
224
224
tt = transform.TreeTransform(tree)
225
225
trans_id = tt.trans_id_tree_path('b')
226
226
parent_trans_id = tt.trans_id_tree_path('d')
246
246
by breezy.osutils.has_symlinks() function.
248
248
The returned tree has the following inventory:
249
[('', inventory.ROOT_ID),
251
('1top-dir', '1top-dir'),
252
(u'2utf\u1234file', u'0utf\u1234file'),
253
('symlink', 'symlink'), # only if symlinks arg is True
254
('1top-dir/0file-in-1topdir', '1file-in-1topdir'),
255
('1top-dir/1dir-in-1topdir', '0dir-in-1topdir')]
253
'symlink', # only if symlinks arg is True
254
'1top-dir/0file-in-1topdir',
255
'1top-dir/1dir-in-1topdir']
256
256
where each component has the type of its name -
257
257
i.e. '1file..' is afile.
267
267
'1top-dir/0file-in-1topdir',
268
268
'1top-dir/1dir-in-1topdir/'
273
u'0utf\u1234file'.encode('utf8'),
277
270
self.build_tree(paths)
279
272
tt = transform.TreeTransform(tree)
281
274
root_transaction_id = tt.trans_id_tree_path('')
285
278
return self.workingtree_to_test_tree(tree)
287
def get_tree_with_utf8(self, tree):
288
"""Generate a tree with a utf8 revision and unicode paths."""
289
self._create_tree_with_utf8(tree)
290
return self.workingtree_to_test_tree(tree)
292
def _create_tree_with_utf8(self, tree):
293
"""Generate a tree with a utf8 revision and unicode paths."""
294
self.requireFeature(features.UnicodeFilenameFeature)
295
# We avoid combining characters in file names here, normalization
296
# checks (as performed by some file systems (OSX) are outside the scope
297
# of these tests). We use the euro sign \N{Euro Sign} or \u20ac in
298
# unicode strings or '\xe2\x82\ac' (its utf-8 encoding) in raw strings.
301
u'ba\N{Euro Sign}r/',
302
u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
304
# bzr itself does not create unicode file ids, but we want them for
306
file_ids = ['TREE_ROOT',
307
'fo\xe2\x82\xaco-id',
308
'ba\xe2\x82\xacr-id',
309
'ba\xe2\x82\xacz-id',
311
self.build_tree(paths[1:])
312
if tree.get_root_id() is None:
313
# Some trees do not have a root yet.
314
tree.add(paths, file_ids)
316
# Some trees will already have a root
317
tree.set_root_id(file_ids[0])
318
tree.add(paths[1:], file_ids[1:])
320
tree.commit(u'in\xedtial', rev_id=u'r\xe9v-1'.encode('utf8'))
321
except errors.NonAsciiRevisionId:
322
raise tests.TestSkipped('non-ascii revision ids not supported')
324
def get_tree_with_merged_utf8(self, tree):
325
"""Generate a tree with utf8 ancestors."""
326
self._create_tree_with_utf8(tree)
327
tree2 = tree.controldir.sprout('tree2').open_workingtree()
328
self.build_tree([u'tree2/ba\N{Euro Sign}r/qu\N{Euro Sign}x'])
329
tree2.add([u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'],
330
[u'qu\N{Euro Sign}x-id'.encode('utf-8')])
331
tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8'))
333
tree.merge_from_branch(tree2.branch)
334
tree.commit(u'm\xe9rge', rev_id=u'r\xe9v-3'.encode('utf8'))
335
return self.workingtree_to_test_tree(tree)
338
281
def make_scenarios(transport_server, transport_readonly_server, formats):
339
282
"""Generate test suites for each Tree implementation in breezy.