176
176
# This reads basis from the repo and puts it into the tree's local
177
177
# cache, if it has one.
178
178
tree.set_parent_ids(['basis'])
181
for old, new, id, entry in delta:
182
if None in (new, entry):
184
paths[new] = (entry.file_id, entry.kind)
185
parents.add(osutils.dirname(new))
186
parents = osutils.minimum_path_selection(parents)
188
# Put place holders in the tree to permit adding the other entries.
189
for pos, parent in enumerate(parents):
190
if not tree.path2id(parent):
191
# add a synthetic directory in the tree so we can can put the
192
# tree0 entries in place for dirstate.
193
tree.add([parent], ["id%d" % pos], ["directory"])
195
# Many deltas may cause this mini-apply to fail, but we want to see what
196
# the delta application code says, not the prep that we do to deal with
197
# limitations of dirstate's update_basis code.
198
for path, (file_id, kind) in sorted(paths.items()):
200
tree.add([path], [file_id], [kind])
201
except (KeyboardInterrupt, SystemExit):
207
181
# Fresh lock, reads disk again.
586
560
self.assertRaises(errors.InconsistentDelta, self.apply_delta, self,
590
class TestInventory(TestCase):
563
def test_add_file(self):
564
inv = self.get_empty_inventory()
565
file1 = inventory.InventoryFile('file-id', 'path', inv.root.file_id)
566
file1.revision = 'result'
569
delta = [(None, u'path', 'file-id', file1)]
570
res_inv = self.apply_delta(self, inv, delta)
571
self.assertEqual('file-id', res_inv['file-id'].file_id)
573
def test_remove_file(self):
574
inv = self.get_empty_inventory()
575
file1 = inventory.InventoryFile('file-id', 'path', inv.root.file_id)
576
file1.revision = 'result'
580
delta = [(u'path', None, 'file-id', None)]
581
res_inv = self.apply_delta(self, inv, delta)
582
self.assertEqual(None, res_inv.path2id('path'))
583
self.assertRaises(errors.NoSuchId, res_inv.id2path, 'file-id')
585
def test_rename_file(self):
586
inv = self.get_empty_inventory()
587
file1 = inventory.InventoryFile('file-id', 'path', inv.root.file_id)
588
file1.revision = 'result'
594
delta = [(u'path', 'path2', 'file-id', file2)]
595
res_inv = self.apply_delta(self, inv, delta)
596
self.assertEqual(None, res_inv.path2id('path'))
597
self.assertEqual('file-id', res_inv.path2id('path2'))
592
599
def test_is_root(self):
593
600
"""Ensure our root-checking code is accurate."""