diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-27 20:50:30 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-27 21:51:07 +1000 |
commit | 40bec49de8428be4e771f2ded1e8ffecbd0c4fd5 (patch) | |
tree | f97d7d748bb2441d867e5b81c3a9a9323dde0aa6 /pkg/gui | |
parent | f99d5f74d49109c19f7701005e636a38c9a70fdb (diff) |
more efficient refreshing of rebase commits
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 25 | ||||
-rw-r--r-- | pkg/gui/gui.go | 1 | ||||
-rw-r--r-- | pkg/gui/sub_commits_panel.go | 2 |
3 files changed, 23 insertions, 5 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 200fea7af..950149c6e 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -97,7 +97,10 @@ func (gui *Gui) refreshCommits() error { } func (gui *Gui) refreshCommitsWithLimit() error { - builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr, gui.State.Modes.CherryPicking.CherryPickedCommits) + gui.State.BranchCommitsMutex.Lock() + defer gui.State.BranchCommitsMutex.Unlock() + + builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr) commits, err := builder.GetCommits( commands.GetCommitsOptions{ @@ -115,6 +118,21 @@ func (gui *Gui) refreshCommitsWithLimit() error { return gui.postRefreshUpdate(gui.Contexts.BranchCommits.Context) } +func (gui *Gui) refreshRebaseCommits() error { + gui.State.BranchCommitsMutex.Lock() + defer gui.State.BranchCommitsMutex.Unlock() + + builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr) + + updatedCommits, err := builder.MergeRebasingCommits(gui.State.Commits) + if err != nil { + return err + } + gui.State.Commits = updatedCommits + + return gui.postRefreshUpdate(gui.Contexts.BranchCommits.Context) +} + // specific functions func (gui *Gui) handleCommitSquashDown(g *gocui.Gui, v *gocui.View) error { @@ -256,9 +274,8 @@ func (gui *Gui) handleMidRebaseCommand(action string) (bool, error) { if err := gui.GitCommand.EditRebaseTodo(gui.State.Panels.Commits.SelectedLineIdx, action); err != nil { return false, gui.surfaceError(err) } - // TODO: consider doing this in a way that is less expensive. We don't actually - // need to reload all the commits, just the TODO commits. - return true, gui.refreshSidePanels(refreshOptions{scope: []int{COMMITS}}) + + return true, gui.refreshRebaseCommits() } func (gui *Gui) handleCommitDelete(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index e95ef1e99..858bbef5f 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -297,6 +297,7 @@ type guiState struct { RefreshingFilesMutex sync.Mutex RefreshingStatusMutex sync.Mutex FetchMutex sync.Mutex + BranchCommitsMutex sync.Mutex Searching searchingState ScreenMode int SideView *gocui.View diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go index 571df1820..06793680f 100644 --- a/pkg/gui/sub_commits_panel.go +++ b/pkg/gui/sub_commits_panel.go @@ -77,7 +77,7 @@ func (gui *Gui) handleViewSubCommitFiles() error { func (gui *Gui) switchToSubCommitsContext(refName string) error { // need to populate my sub commits - builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr, gui.State.Modes.CherryPicking.CherryPickedCommits) + builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr) commits, err := builder.GetCommits( commands.GetCommitsOptions{ |