Exemple #1
0
 def commit_conf(block_holder):
     new_resource = block_holder.commit_config()
     if new_resource:
         processor_changes = ProcessorChanges()
         processor_changes.upsert(new_resource.name, new_resource.content, blob_changed=True)
         hive.update(processor_changes)
         editionapi.save_hive_changes(hive, processor_changes)
Exemple #2
0
 def test_hive_num_files_reject(self):
     with self.assertRaises(BiiException):
         hive = Hive()
         changes = ProcessorChanges()
         for i in xrange(BII_HIVE_NUMFILES_LIMIT + 1):
             name = "user/block/file%d" % i
             changes.upsert(name, Content(id_=name, load=Blob()))
         hive.update(changes)
         changevalidator.check_hive_num_cells(hive)
Exemple #3
0
def make_simple_cell(block_cell_name, hive=None):
    if isinstance(block_cell_name, basestring):
        block_cell_name = BlockCellName(block_cell_name)
    cell = SimpleCell(block_cell_name)
    cell.type = BiiType.from_extension(block_cell_name.extension)
    if hive:
        changes = ProcessorChanges()
        changes.upsert(cell.name, cell, None)
        hive.update(changes)
    return cell
Exemple #4
0
def make_simple_cell(block_cell_name, hive=None):
    if isinstance(block_cell_name, basestring):
        block_cell_name = BlockCellName(block_cell_name)
    cell = SimpleCell(block_cell_name)
    cell.type = BiiType.from_extension(block_cell_name.extension)
    if hive:
        changes = ProcessorChanges()
        changes.upsert(cell.name, cell, None)
        hive.update(changes)
    return cell
Exemple #5
0
def _process_resources(block_holder):
    processor_changes = ProcessorChanges()
    for (cell, content) in block_holder.simple_resources:
        # Cell from server has the CellID as ID, we need BlockCellName
        cell.ID = cell.name
        if content:
            # content.ID = cell.name hive.add_resource does it
            content._is_parsed = False  # It is necessary to parse it
            content.ID = cell.name  # It is edition, should have ID=BlockCellName
        r = Resource(cell, content)
        block_holder.add_resource(r)
        processor_changes.upsert(r.name, r.content, blob_changed=True)
    return processor_changes
Exemple #6
0
    def update(self, block_name=None, time=None):
        """ a block is outdated, because someone has published from another location,
        and parent is not the last one in the block anymore.
        update is able to merge with the given time
        param time: Can be None=> means the last one
        param block_name: The block to be updated
        """
        from biicode.common.diffmerge.update import update

        hive_holder = self.hive_holder
        # TODO: Copied from publish: refactor
        if block_name is None:
            blocks = hive_holder.blocks
            if len(blocks) == 1:
                block_name = iter(blocks).next()
            else:
                raise BiiException('More than one block in this project %s\n'
                                   'Please specify block to update\n'
                                   'with "$ bii update my_user/my_block"')
        try:
            block_holder = hive_holder[block_name]
        except KeyError:
            raise BiiException("Block %s is not open" % block_name)

        files, other_version = update(block_holder, time, self._biiapi, self._biiout)

        # Extra "process" after the update
        proc_changes = ProcessorChanges()
        checkin_block_files(hive_holder, block_name, files, proc_changes, self._biiout)
        blocks_process(hive_holder, proc_changes, self._biiout)
        deps_process(self._biiapi, hive_holder, proc_changes, self._biiout)
        block_holder = hive_holder[block_name]
        block_holder.parent = other_version
        new_config = block_holder.commit_config()
        if new_config:
            proc_changes.upsert(new_config.name, new_config.content, True)
        self._edition.save_hive_changes(hive_holder.hive, proc_changes)
        return block_name