Exemplo n.º 1
0
 def test_rename_file(self):
     wt = self.make_branch_and_tree('.')
     wt.lock_write()
     self.addCleanup(wt.unlock)
     self.build_tree(['foo/', 'foo/bar', 'baz/'])
     wt.add(['foo', 'foo/bar', 'baz'],
            [b'foo-id', b'bar-id', b'baz-id'])
     wt.apply_inventory_delta([('foo/bar', 'baz/bar', b'bar-id',
                                inventory.InventoryFile(b'bar-id', 'bar', b'baz-id'))])
     self.assertEqual('baz/bar', wt.id2path(b'bar-id'))
Exemplo n.º 2
0
 def test_add(self):
     wt = self.make_branch_and_tree('.')
     wt.lock_write()
     self.addCleanup(wt.unlock)
     root_id = wt.path2id('')
     wt.apply_inventory_delta([(None, 'bar/foo', b'foo-id',
                                inventory.InventoryFile(b'foo-id', 'foo', parent_id=b'bar-id')),
                               (None, 'bar', b'bar-id', inventory.InventoryDirectory(b'bar-id',
                                                                                     'bar', parent_id=root_id))])
     self.assertEqual('bar/foo', wt.id2path(b'foo-id'))
     self.assertEqual('bar', wt.id2path(b'bar-id'))
Exemplo n.º 3
0
    def test_child_rename_ordering(self):
        """Test the rename-parent, move child edge case.

        (A naive implementation may move the parent first, and then be
         unable to find the child.)
        """
        wt = self.make_branch_and_tree('.')
        root_id = wt.path2id('')
        self.build_tree(['dir/', 'dir/child', 'other/'])
        wt.add(['dir', 'dir/child', 'other'],
               [b'dir-id', b'child-id', b'other-id'])
        # this delta moves dir-id to dir2 and reparents
        # child-id to a parent of other-id
        wt.apply_inventory_delta([('dir', 'dir2', b'dir-id',
                                   inventory.InventoryDirectory(b'dir-id', 'dir2', root_id)),
                                  ('dir/child', 'other/child', b'child-id',
                                   inventory.InventoryFile(b'child-id', 'child', b'other-id'))])
        self.assertEqual('dir2', wt.id2path(b'dir-id'))
        self.assertEqual('other/child', wt.id2path(b'child-id'))