Exemplo n.º 1
0
 def test_unbecome_executable(self):
     tree = self.MockTree("myfileid", "file", "name", True)
     ie2 = InventoryFile("myfileid", "name", "theroot")
     ie2.executable = False
     editor = SendPropChangesTests.RecordingFileEditor()
     file_editor_send_prop_changes(tree, "myfileid", ie2, editor)
     self.assertEquals(editor._props, {"svn:executable": None})
Exemplo n.º 2
0
 def make_file(self, file_id, name, parent_id, content=b'content\n',
               revision=b'new-test-rev'):
     ie = InventoryFile(file_id, name, parent_id)
     ie.text_sha1 = osutils.sha_string(content)
     ie.text_size = len(content)
     ie.revision = revision
     return ie
Exemplo n.º 3
0
def read_inventory(inv_file):
    """Read inventory object from rio formatted inventory file"""
    from breezy.bzr.inventory import Inventory, InventoryFile
    s = read_stanza(inv_file)
    assert s['inventory_version'] == 7
    inv = Inventory()
    for s in read_stanzas(inv_file):
        kind, file_id = s.items[0]
        parent_id = None
        if 'parent_id' in s:
            parent_id = s['parent_id']
        if kind == 'file':
            ie = InventoryFile(file_id, s['name'], parent_id)
            ie.text_sha1 = s['text_sha1']
            ie.text_size = s['text_size']
        else:
            raise NotImplementedError()
        inv.add(ie)
    return inv
Exemplo n.º 4
0
    def make_one_file_inventory(self,
                                repo,
                                revision,
                                parents,
                                inv_revision=None,
                                root_revision=None,
                                file_contents=None,
                                make_file_version=True):
        """Make an inventory containing a version of a file with ID 'a-file'.

        The file's ID will be 'a-file', and its filename will be 'a file name',
        stored at the tree root.

        :param repo: a repository to add the new file version to.
        :param revision: the revision ID of the new inventory.
        :param parents: the parents for this revision of 'a-file'.
        :param inv_revision: if not None, the revision ID to store in the
            inventory entry.  Otherwise, this defaults to revision.
        :param root_revision: if not None, the inventory's root.revision will
            be set to this.
        :param file_contents: if not None, the contents of this file version.
            Otherwise a unique default (based on revision ID) will be
            generated.
        """
        inv = Inventory(revision_id=revision)
        if root_revision is not None:
            inv.root.revision = root_revision
        file_id = b'a-file-id'
        entry = InventoryFile(file_id, 'a file name', b'TREE_ROOT')
        if inv_revision is not None:
            entry.revision = inv_revision
        else:
            entry.revision = revision
        entry.text_size = 0
        if file_contents is None:
            file_contents = b'%sline\n' % entry.revision
        entry.text_sha1 = osutils.sha_string(file_contents)
        inv.add(entry)
        if make_file_version:
            repo.texts.add_lines((file_id, revision),
                                 [(file_id, parent) for parent in parents],
                                 [file_contents])
        return inv
Exemplo n.º 5
0
 def test_nothing_changes(self):
     tree = self.MockTree("myfileid", "file", "name", False)
     ie2 = InventoryFile("myfileid", "name", "theroot")
     editor = SendPropChangesTests.RecordingFileEditor()
     file_editor_send_prop_changes(tree, "myfileid",ie2, editor)
     self.assertEquals(editor._props, {})