def copy_versions(self):
        """copies versions from one task to another
        """
        # get from task
        from_task = self.get_task_from_tree_view(self.from_task_tree_view)

        # get logged in user
        logged_in_user = self.get_logged_in_user()

        if not from_task:
            QtGui.QMessageBox.critical(
                self,
                'Error',
                'Please select a task from <b>From Task</b> list'
            )
            return

        # get to task
        to_task = self.get_task_from_tree_view(self.to_task_tree_view)

        if not to_task:
            QtGui.QMessageBox.critical(
                self,
                'Error',
                'Please select a task from <b>To Task</b> list'
            )
            return

        # check if tasks are the same
        if from_task == to_task:
            QtGui.QMessageBox.critical(
                self,
                'Error',
                'Please select two different tasks'
            )
            return

        # get take names and related versions
        # get distinct take names
        from_take_names = map(
            lambda x: x[0],
            db.DBSession.query(distinct(Version.take_name))
            .filter(Version.task == from_task)
            .order_by(Version.take_name)
            .all()
        )

        # create versions for each take
        answer = QtGui.QMessageBox.question(
            self,
            'Info',
            "Will copy %s versions from take names:<br><br>"
            "%s"
            "<br><br>"
            "Is that Ok?" % (
                len(from_take_names),
                '<br>'.join(from_take_names)
            ),
            QtGui.QMessageBox.Yes,
            QtGui.QMessageBox.No
        )

        if answer == QtGui.QMessageBox.Yes:
            for take_name in from_take_names:
                latest_version = Version.query\
                    .filter_by(task=from_task)\
                    .filter_by(take_name=take_name)\
                    .order_by(Version.version_number.desc())\
                    .first()

                # create a new version
                new_version = Version(
                    task=to_task,
                    take_name=take_name
                )
                new_version.created_by = logged_in_user
                new_version.extension = latest_version.extension
                new_version.description = \
                    'Moved from another task (id=%s) with Version Mover' % \
                    latest_version.task.id
                new_version.created_with = latest_version.created_with
                db.DBSession.add(new_version)
                db.DBSession.commit()

                # update path
                new_version.update_paths()
                db.DBSession.add(new_version)
                db.DBSession.commit()

                # now copy the last_version file to the new_version path
                try:
                    os.makedirs(new_version.absolute_path)
                except __HOLE__:  # path exists
                    pass

                # move the file there
                shutil.copyfile(
                    latest_version.absolute_full_path,
                    new_version.absolute_full_path
                )

            # inform the user
            QtGui.QMessageBox.information(
                self,
                'Success',
                'Successfully copied %s versions' % len(from_take_names)
            )
dataset/ETHPy150Open eoyilmaz/anima/anima/ui/version_mover.py/VersionMover.copy_versions