81
81
_committed_inv_v5 = """<inventory>
82
82
<file file_id="bar-20050901064931-73b4b1138abc9cd2"
83
83
name="bar" parent_id="TREE_ROOT"
84
revision="mbp@foo-123123"/>
84
revision="mbp@foo-123123"
85
text_sha1="A" text_size="1"/>
85
86
<directory name="subdir"
86
87
file_id="foo-20050801201819-4139aa4a272f4250"
87
88
parent_id="TREE_ROOT"
88
89
revision="mbp@foo-00"/>
89
90
<file executable="yes" file_id="bar-20050824000535-6bc48cfad47ed134"
90
91
name="bar" parent_id="foo-20050801201819-4139aa4a272f4250"
91
revision="mbp@foo-00"/>
93
text_sha1="B" text_size="0"/>
122
124
# DO NOT REFLOW THIS. Its the exact inventory we want.
123
125
_expected_inv_v5 = """<inventory format="5">
124
<file file_id="bar-20050901064931-73b4b1138abc9cd2" name="bar" revision="mbp@foo-123123" />
126
<file file_id="bar-20050901064931-73b4b1138abc9cd2" name="bar" revision="mbp@foo-123123" text_sha1="A" text_size="1" />
125
127
<directory file_id="foo-20050801201819-4139aa4a272f4250" name="subdir" revision="mbp@foo-00" />
126
<file executable="yes" file_id="bar-20050824000535-6bc48cfad47ed134" name="bar" parent_id="foo-20050801201819-4139aa4a272f4250" revision="mbp@foo-00" />
128
<file executable="yes" file_id="bar-20050824000535-6bc48cfad47ed134" name="bar" parent_id="foo-20050801201819-4139aa4a272f4250" revision="mbp@foo-00" text_sha1="B" text_size="0" />
131
133
_expected_inv_v5_root = """<inventory file_id="f<" format="5" revision_id="mother!">
132
<file file_id="bar-20050901064931-73b4b1138abc9cd2" name="bar" parent_id="f<" revision="mbp@foo-123123" />
134
<file file_id="bar-20050901064931-73b4b1138abc9cd2" name="bar" parent_id="f<" revision="mbp@foo-123123" text_sha1="A" text_size="1" />
133
135
<directory file_id="foo-20050801201819-4139aa4a272f4250" name="subdir" parent_id="f<" revision="mbp@foo-00" />
134
<file executable="yes" file_id="bar-20050824000535-6bc48cfad47ed134" name="bar" parent_id="foo-20050801201819-4139aa4a272f4250" revision="mbp@foo-00" />
136
<file executable="yes" file_id="bar-20050824000535-6bc48cfad47ed134" name="bar" parent_id="foo-20050801201819-4139aa4a272f4250" revision="mbp@foo-00" text_sha1="B" text_size="0" />
137
<symlink file_id="link-1" name="link" parent_id="foo-20050801201819-4139aa4a272f4250" revision="mbp@foo-00" symlink_target="a" />
138
141
_expected_inv_v7 = """<inventory format="7" revision_id="rev_outer">
139
142
<directory file_id="tree-root-321" name="" revision="rev_outer" />
140
143
<directory file_id="dir-id" name="dir" parent_id="tree-root-321" revision="rev_outer" />
141
<file file_id="file-id" name="file" parent_id="tree-root-321" revision="rev_outer" />
142
<symlink file_id="link-id" name="link" parent_id="tree-root-321" revision="rev_outer" />
144
<file file_id="file-id" name="file" parent_id="tree-root-321" revision="rev_outer" text_sha1="A" text_size="1" />
145
<symlink file_id="link-id" name="link" parent_id="tree-root-321" revision="rev_outer" symlink_target="a" />
143
146
<tree-reference file_id="nested-id" name="nested" parent_id="tree-root-321" revision="rev_outer" reference_revision="rev_inner" />
258
261
outp = StringIO()
259
262
bzrlib.xml5.serializer_v5.write_inventory(inv, outp)
260
263
self.assertEqualDiff(xml_string, outp.getvalue())
264
lines = bzrlib.xml5.serializer_v5.write_inventory_to_lines(inv)
266
self.assertEqual(outp.readlines(), lines)
261
267
inv2 = bzrlib.xml5.serializer_v5.read_inventory(StringIO(outp.getvalue()))
262
268
self.assertEqual(inv, inv2)
314
320
inv['tree-root-321'].revision = 'rev_outer'
315
321
inv['dir-id'].revision = 'rev_outer'
316
322
inv['file-id'].revision = 'rev_outer'
323
inv['file-id'].text_sha1 = 'A'
324
inv['file-id'].text_size = 1
317
325
inv['link-id'].revision = 'rev_outer'
326
inv['link-id'].symlink_target = 'a'
318
327
txt = xml7.serializer_v7.write_inventory_to_string(inv)
328
lines = xml7.serializer_v7.write_inventory_to_lines(inv)
329
self.assertEqual(bzrlib.osutils.split_lines(txt), lines)
319
330
self.assertEqualDiff(_expected_inv_v7, txt)
320
331
inv2 = xml7.serializer_v7.read_inventory_from_string(txt)
321
332
self.assertEqual(5, len(inv2))
335
346
s_v5 = bzrlib.xml5.serializer_v5
336
347
s_v6 = bzrlib.xml6.serializer_v6
337
348
s_v7 = xml7.serializer_v7
338
inv = Inventory('tree-root-321')
349
inv = Inventory('tree-root-321', revision_id='rev-outer')
350
inv.root.revision = 'root-rev'
339
351
inv.add(inventory.TreeReference('nested-id', 'nested', 'tree-root-321',
340
352
'rev-outer', 'rev-inner'))
341
self.assertRaises(errors.UnsupportedInventoryKind,
353
self.assertRaises(errors.UnsupportedInventoryKind,
342
354
s_v5.write_inventory_to_string, inv)
343
self.assertRaises(errors.UnsupportedInventoryKind,
355
self.assertRaises(errors.UnsupportedInventoryKind,
344
356
s_v6.write_inventory_to_string, inv)
345
357
txt = s_v7.write_inventory_to_string(inv)
358
lines = s_v7.write_inventory_to_lines(inv)
359
self.assertEqual(bzrlib.osutils.split_lines(txt), lines)
346
360
inv2 = s_v7.read_inventory_from_string(txt)
347
361
self.assertEqual('tree-root-321', inv2['nested-id'].parent_id)
348
362
self.assertEqual('rev-outer', inv2['nested-id'].revision)