Ejemplo n.º 1
0
 def create_ui(self):
     super(LogView, self).create_ui()
     with busy_cursor():
         self.graph_model = LogGraphModel(self.repo, paths=self.paths,
             revs=self.revs, all=self.all, parent=self)
     self.graph_table.setItemDelegate(LogGraphDelegate())
     self.log_filter.source_model = self.graph_model
     self.log_filter.viewer = self.graph_table
Ejemplo n.º 2
0
 def show_revs(self, *revs):
     action = self._find_rev_action(revs)
     if not action:
         action = self.create_rev_action(self.source_model.repo, *revs)
         self.revs_menu.insertAction(self.revs_separator, action)
     self._select_action(action)
     with busy_cursor():
         self.source_model.revs = revs
         self.source_model.all = False
         self.source_model.refresh()
Ejemplo n.º 3
0
 def commit_selection(self):
     repo = self.selection_repo
     dialog = CommitDialog(repo=repo, selected_items=self.selected_items, parent=self)
     if dialog.exec_() == dialog.Rejected:
         return
     with busy_cursor():
         if dialog.use_staged_changes:
             files = ()
         else:
             files = tuple(dialog.selected_local_changes)
             to_add = filter(lambda f: f.index_status == git_api.UNTRACKED, files)
             if to_add:
                 repo.stage(to_add)
         repo.commit(message=dialog.message, paths=files, amend=dialog.amend)
Ejemplo n.º 4
0
 def open_repository(self):
     dir_path = QFileDialog.getExistingDirectory(self, self.tr("Open Repository"))
     if not dir_path:
         return
     kwargs = dict(git=self.app.workspace.git, parent=self)
     if self.app.workspace.git.is_git_dir(dir_path):
         kwargs["git_dir"] = dir_path
     else:
         kwargs["work_tree_dir"] = dir_path
     dialog = OpenRepositoryDialog(**kwargs)
     if dialog.exec_() == dialog.Accepted:
         with busy_cursor():
             repo = Repo(work_tree_dir=dialog.work_tree_dir, git_dir=dialog.git_dir)
             self.app.workspace.add_repo(repo)
Ejemplo n.º 5
0
 def __init__(self, repo, selected_items, parent=None):
     super(CommitDialog, self).__init__(parent=parent)
     self.repo = repo
     self.dialog_buttons.button(QDialogButtonBox.Ok).setEnabled(False)
     self.selected_items = selected_items
     if len(selected_items) == 1 and isinstance(selected_items[0],
             WorkspaceDirectory):
         self.root_dir = selected_items[0]
     else:
         self.root_dir = None
     fixed_font = QFont('Courier', self.message_text.font().pointSize())
     fixed_font.setStyleHint(QFont.Monospace)
     self.message_text.setFont(fixed_font)
     self.text_pos_label.setFont(fixed_font)
     with busy_cursor():
         self.staged_changes_model = StagedChangesModel(repo, self.root_dir,
             parent=self)
         self.local_changes_model = LocalChangesModel(repo.workspace,
             parent=self)
         self.local_changes_model.file_source = lambda: tuple(deep_item
             for selected_item in selected_items
             for deep_item in deep_file_list(selected_item)
             if exclude_unmodified(deep_item) and exclude_ignored(deep_item))
         if self.root_dir:
             self.staged_changes_button.setChecked(True)
             self.show_staged_changes()
         else:
             self.local_changes_button.setChecked(True)
             self.show_local_changes()
         if self.repo.head_ref:
             (self.last_commit,) = self.repo.log(max_commits=1)
         else:
             self.last_commit = None
             self.action_reuse_last_msg.setEnabled(False)
             self.action_reuse_log_msg.setEnabled(False)
             self.amend_checkbox.setEnabled(False)
     self.staged_changes_button.clicked.connect(self.show_staged_changes)
     self.local_changes_button.clicked.connect(self.show_local_changes)
     self.local_changes_model.dataChanged.connect(self.local_change_toggled)
     self.message_text.cursorPositionChanged.connect(self.text_pos_changed)
     self.message_text.textChanged.connect(self.message_text_changed)
     reuse_menu = QMenu()
     reuse_menu.addAction(self.action_reuse_last_msg)
     reuse_menu.addAction(self.action_reuse_log_msg)
     self.reuse_msg_button.setDefaultAction(self.action_reuse_last_msg)
     self.reuse_msg_button.setMenu(reuse_menu)
     self.action_reuse_last_msg.triggered.connect(self.reuse_last_message)
     self.action_reuse_log_msg.triggered.connect(self.select_old_message)
     self.amend_checkbox.toggled.connect(self.amend_toggled)
Ejemplo n.º 6
0
 def __init__(self, repo, files=(), revs=(), all=True, parent=None):
     super(SelectCommitDialog, self).__init__(parent=parent)
     self.repo = repo
     self.files = files
     self.revs = revs
     self.all = all
     with busy_cursor():
         self.graph_model = LogGraphModel(self.repo,
             paths=[f.path for f in self.files], revs=self.revs,
             all=self.all, parent=self)
     self.graph_table.setItemDelegate(LogGraphDelegate())
     self.log_filter.source_model = self.graph_model
     self.log_filter.viewer = self.graph_table
     self.dialog_buttons.button(QDialogButtonBox.Ok).setEnabled(False)
     # We must assign the selection model to a variable, to avoid triggering
     # a segfault bug (temporary PyObject* destroyed prematurely)
     # see https://bugreports.qt-project.org/browse/PYSIDE-79
     selection_model = self.graph_table.selectionModel()
     selection_model.currentChanged.connect(self.commit_clicked)
Ejemplo n.º 7
0
 def create_repository(self):
     dir_path = QFileDialog.getExistingDirectory(self, self.tr("Create Repository"))
     if not dir_path:
         return
     dialog = CreateRepositoryDialog(git=self.app.workspace.git, repo_dir=dir_path, parent=self)
     if dialog.exec_() == dialog.Accepted:
         with busy_cursor():
             self.app.workspace.git.init(
                 dialog.repo_dir,
                 bare=dialog.bare,
                 shared=dialog.shared,
                 template_dir=dialog.template_dir,
                 separate_git_dir=dialog.git_dir,
             )
             if dialog.bare:
                 repo = Repo(work_tree_dir=None, git_dir=dialog.repo_dir)
             else:
                 repo = Repo(work_tree_dir=dialog.repo_dir)
             self.app.workspace.add_repo(repo)
Ejemplo n.º 8
0
 def unstage_selection(self):
     with busy_cursor():
         self.selection_repo.unstage(self.selected_items)
     self.update_selection_actions()
     self.update_current_item_actions()
Ejemplo n.º 9
0
 def _revs_action_triggered(self):
     self._select_action(self.sender())
     with busy_cursor():
         self.source_model.revs = self.sender().revs
         self.source_model.all = False
         self.source_model.refresh()
Ejemplo n.º 10
0
 def show_all_refs(self):
     self._select_action(self.action_all_refs)
     with busy_cursor():
         self.source_model.revs = ()
         self.source_model.all = True
         self.source_model.refresh()