Esempio n. 1
0
    def apply_models(self, models, log, force_committed_date):
        """
            Applies the given models.
        """
        write_results = {}

        self.apply_started()
        for model in models:
            def write_wait(log, force_committed_date, dont_populate=True):
                """
                    This is like write(), except we wait for the write to
                    finish.
                """
                model.write(log, force_committed_date, dont_populate)

                while not(model.is_finished_writing()):
                    time.sleep(1)

                return model.is_write_success()

            args = (log, force_committed_date)
            kwargs = {"dont_populate": True}
            result = run_long_operation("Applying %s" % model.name_to_display(),
                                        write_wait, args, kwargs,
                                        progress_method=model.progress,
                                        parent=self)

            write_results[model] = result

        self.apply_finished(write_results)
Esempio n. 2
0
    def apply(self):
        """
            Write the modifications to the git repository.
        """
        if self._applying:
            # Can't apply if we're already applying
            return

        self._applying = True

        def get_to_write_models():
            return [model for model in self._models.values()
                    if model.should_be_written()]

        to_write_models = run_long_operation("Counting modifications",
                                             get_to_write_models,
                                             parent=self)

        if to_write_models:
            msgBox = ConfirmDialog(to_write_models)
            ret = msgBox.exec_()

            if ret and msgBox.checked_models():
                log = msgBox.log_checked()
                force_committed_date = msgBox.force_checked()

                self.apply_models(msgBox.checked_models(), log,
                                  force_committed_date)

        self._applying = False
Esempio n. 3
0
    def __init__(self, models):
        QDialog.__init__(self)

        self._ui = Ui_Dialog()
        self._ui.setupUi(self)

        self._model_checkboxes = []

        row = 1
        for model in models:
            branch_name = model.get_new_branch_name() or \
                          model.get_current_branch().name
            mod_count = model.get_modified_count()
            del_count = model.get_deleted_count()
            to_rewrite = run_long_operation("Calculating dependencies",
                                            model.get_to_rewrite_count,
                                            parent=self)
            is_name_modified = model.is_name_modified()

            display_string = ""
            if model.is_fake_model():
                display_string += "New branch."
            else:
                if is_name_modified:
                    display_string += "New name %s." % is_name_modified

                if mod_count:
                    display_string += "%d modified, %d to rewrite." % \
                                      (mod_count, to_rewrite)
                elif del_count:
                    display_string += "%d deleted, %d to rewrite." % \
                                      (del_count, to_rewrite)

            if display_string:
                count_label = QLabel(QString(display_string))
                count_label.setAlignment(Qt.AlignRight)

                checkbox = QCheckBox(self)
                checkbox.setText(QString(branch_name))
                self._ui.branchCountLayout.addWidget(checkbox, row, 0, 1, 2)
                self._ui.branchCountLayout.addWidget(count_label, row, 1, 1, 2)

                self._model_checkboxes.append((checkbox, model))

                row += 1