Пример #1
0
    def create_new_branch_from_model(self, indexes, name=False):
        """
            This method creates a new branch from a given set of indexes.
            The first row of the index set will be used.
        """
        if not name:
            msgBox = BranchNameDialog(self)
            ret = msgBox.exec_()

            if ret:
                new_name = msgBox.get_new_name()
            else:
                return
        else:
            new_name = name

        from_model = indexes[0].model()

        selected_rows = set([index.row() for index in indexes])
        from_row = min(selected_rows)

        model = QEditableGitModel(self._models, directory=self._directory,
                                  fake_branch_name=new_name,
                                  from_model_row=(from_model, from_row),
                                  parent=self)
        model.populate()
        self.add_new_model(model)

        self.enable_modifications_buttons(True)
Пример #2
0
    def set_current_directory(self, directory, reset_all=False):
        """
            Sets the current directory.

            :param directory:
                The git directory.
        """
        self._models = {}
        a_model = QGitModel(directory)
        self.current_branch = a_model.get_current_branch()

        for branch in a_model.get_branches():
            model = QEditableGitModel(self._models, directory=directory,
                                      parent=self)
            model.set_current_branch(branch)
            model.setMerge(False)
            model.enable_option("filters")
            model.populate()
            self._models[branch] = model

            QObject.connect(model, SIGNAL("newHistoryEvent"),
                            self.new_history_event)

        if reset_all:
            self.rebase_main_class.reset_interface(self._models)
            self.filter_main_class.reset_interface(self._models)
Пример #3
0
    def apply_finished(self, write_results):
        """
            This method is called when the progress thread is finished.
        """
        self._applying = False
        self._ui.applyButton.setEnabled(True)

        a_repo = Repo(self._directory)

        for model, success in write_results.items():
            if success and model.is_fake_model():
                # If the applied models were fake, rebuild them.
                branch_name = model.name_to_display()
                new_branch = [branch for branch in a_repo.branches
                              if branch.name == branch_name][0]
                new_model = QEditableGitModel(self._models,
                                              directory=self._directory,
                                              parent=self)
                new_model.set_current_branch(new_branch)
                new_model.populate()
                self.remove_model(model)
                self.add_new_model(new_model)

            elif not success:
                if model.write_errors():
                    for error in model.write_errors():
                        print error
                else:
                    model.reset()
                    conflicting_index = model.get_conflicting_index()
                    self.rebase_main_class.commit_clicked(conflicting_index)
            elif success:
                model.populate()

        if True in write_results.values():
            # Reset history
            self.reset_history()