Exemple #1
0
    def close(self, block_name, settings=None, force=False):
        from biicode.common.edition.open_close import close_block
        assert isinstance(block_name, BlockName)

        if block_name not in self.hive_holder.blocks:
            raise BiiException("Block %s is not in your project, you cannot close it"
                               % str(block_name))

        parent = self.hive_holder[block_name].parent
        if parent.time == -1:
            raise BiiException("Block %s is not published, you cannot close it."
                               "\nIf you want to delete it, delete the folder in the filesystem."
                               % str(block_name))

        remote_block_holder = self._biiapi.get_block_holder(parent)
        from biicode.common.diffmerge.compare import compare
        changes = compare(remote_block_holder.resources, self.hive_holder[block_name].resources)
        if block_changed(changes, self.hive_holder[block_name], remote_block_holder) and not force:
            raise BiiException("Block %s has unpublished changes.\n%s\n"
                               "Execute with --force to ignore them or publish it first."
                               % (str(block_name), str(changes)))

        processor_changes = close_block(self.hive_holder, block_name)
        blocks_process(self.hive_holder, processor_changes, self._biiout)
        deps_process(self._biiapi, self.hive_holder, processor_changes, self._biiout, settings)
        self._edition.save_hive_changes(self.hive_holder.hive, processor_changes)
Exemple #2
0
 def process(self, settings, files):
     hive_holder = self.hive_holder
     delete_migration = migrate_bii_config(files, self._biiout)
     processor_changes = checkin_files(hive_holder, settings, files, self._biiout)
     blocks_process(hive_holder, processor_changes, self._biiout)
     deps_process(self._biiapi, hive_holder, processor_changes, self._biiout, settings)
     self._edition.save_hive_changes(hive_holder.hive, processor_changes)
     return delete_migration
Exemple #3
0
    def apply_find_result(self, find_result):
        from biicode.common.find import find_manager

        if find_result:
            hive_holder = self.hive_holder
            find_manager.update_hive_with_find_result(hive_holder, find_result)
            blocks_process(hive_holder, self._biiout)
            deps_process(self._biiapi, hive_holder, self._biiout)
            self._edition.save_hive_changes(hive_holder)
    def apply_find_result(self, find_result):
        from biicode.common.find import find_manager

        if find_result:
            hive_holder = self.hive_holder
            find_manager.update_hive_with_find_result(hive_holder, find_result)
            blocks_process(hive_holder, self._biiout)
            deps_process(self._biiapi, hive_holder, self._biiout)
            self._edition.save_hive_changes(hive_holder)
Exemple #5
0
    def open(self, block_name, track, time, version_tag):
        '''
        Opens a block
        Params:
            block_version: If time is None last version is retrieved
        Returns:
            block_version actually opened
        '''
        from biicode.common.edition.open_close import open_block

        hive_holder = self.hive_holder
        block_version = select_version(hive_holder, self._biiapi, self._biiout, block_name,
                                       track, time, version_tag)
        processor_changes = open_block(hive_holder, block_version, self._biiapi, self._biiout)
        try:
            blocks_process(hive_holder, processor_changes, self._biiout)
            deps_process(self._biiapi, hive_holder, processor_changes, self._biiout)
        finally:
            self._edition.save_hive_changes(hive_holder.hive, processor_changes)
        return block_version
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
        checkin_block_files(hive_holder, block_name, files, self._biiout)
        # TODO: It seems that this is the same pattern as _process_resources from open_close.py
        #       Factorize accordingly
        # Extra thing: we have to force them to be saved
        for (_, content) in hive_holder[block_name].simple_resources:
            content._blob_updated = True  # FIXME: Do not access private
        blocks_process(hive_holder, self._biiout)
        deps_process(self._biiapi, hive_holder, self._biiout)
        block_holder = hive_holder[block_name]
        block_holder.parent = other_version
        block_holder.commit_config()
        self._edition.save_hive_changes(hive_holder)
        return block_name
    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
        checkin_block_files(hive_holder, block_name, files, self._biiout)
        # TODO: It seems that this is the same pattern as _process_resources from open_close.py
        #       Factorize accordingly
        # Extra thing: we have to force them to be saved
        for (_, content) in hive_holder[block_name].simple_resources:
            content._blob_updated = True  # FIXME: Do not access private
        blocks_process(hive_holder, self._biiout)
        deps_process(self._biiapi, hive_holder, self._biiout)
        block_holder = hive_holder[block_name]
        block_holder.parent = other_version
        block_holder.commit_config()
        self._edition.save_hive_changes(hive_holder)
        return block_name
Exemple #8
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