summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/app.rs35
-rw-r--r--src/components/blame_file.rs2
-rw-r--r--src/components/branchlist.rs39
-rw-r--r--src/components/changes.rs55
-rw-r--r--src/components/commit.rs46
-rw-r--r--src/components/create_branch.rs15
-rw-r--r--src/components/diff.rs29
-rw-r--r--src/components/filetree.rs12
-rw-r--r--src/components/inspect_commit.rs6
-rw-r--r--src/components/pull.rs17
-rw-r--r--src/components/push.rs9
-rw-r--r--src/components/push_tags.rs9
-rw-r--r--src/components/rename_branch.rs23
-rw-r--r--src/components/reset.rs4
-rw-r--r--src/components/revision_files.rs14
-rw-r--r--src/components/stashmsg.rs10
-rw-r--r--src/components/tag_commit.rs15
-rw-r--r--src/components/taglist.rs4
-rw-r--r--src/components/utils/mod.rs10
-rw-r--r--src/queue.rs27
-rw-r--r--src/tabs/files.rs2
-rw-r--r--src/tabs/revlog.rs21
-rw-r--r--src/tabs/stashing.rs6
-rw-r--r--src/tabs/stashlist.rs42
-rw-r--r--src/tabs/status.rs47
25 files changed, 209 insertions, 290 deletions
diff --git a/src/app.rs b/src/app.rs
index c5d3b29c..6b181aed 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -83,7 +83,7 @@ impl App {
theme: Theme,
key_config: KeyConfig,
) -> Self {
- let queue = Queue::default();
+ let queue = Queue::new();
let theme = Rc::new(theme);
let key_config = Rc::new(key_config);
@@ -544,14 +544,14 @@ impl App {
let mut flags = NeedsUpdate::empty();
loop {
- let front = self.queue.borrow_mut().pop_front();
+ let front = self.queue.pop();
if let Some(e) = front {
flags.insert(self.process_internal_event(e)?);
} else {
break;
}
}
- self.queue.borrow_mut().clear();
+ self.queue.clear();
Ok(flags)
}
@@ -609,11 +609,9 @@ impl App {
}
InternalEvent::SelectCommitInRevlog(id) => {
if let Err(error) = self.revlog.select_commit(id) {
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(
- error.to_string(),
- ),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ error.to_string(),
+ ));
} else {
self.tags_popup.hide();
flags.insert(NeedsUpdate::ALL);
@@ -677,9 +675,9 @@ impl App {
Action::DeleteBranch(branch_ref) => {
if let Err(e) = sync::delete_branch(CWD, &branch_ref)
{
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(e.to_string()),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ e.to_string(),
+ ));
} else {
flags.insert(NeedsUpdate::ALL);
self.select_branch_popup.update_branches()?;
@@ -687,20 +685,17 @@ impl App {
}
Action::DeleteTag(tag_name) => {
if let Err(error) = sync::delete_tag(CWD, &tag_name) {
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(
- error.to_string(),
- ),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ error.to_string(),
+ ));
} else {
flags.insert(NeedsUpdate::ALL);
self.tags_popup.update_tags()?;
}
}
- Action::ForcePush(branch, force) => self
- .queue
- .borrow_mut()
- .push_back(InternalEvent::Push(branch, force)),
+ Action::ForcePush(branch, force) => {
+ self.queue.push(InternalEvent::Push(branch, force))
+ }
Action::PullMerge { rebase, .. } => {
self.pull_popup.try_conflict_free_merge(rebase);
flags.insert(NeedsUpdate::ALL);
diff --git a/src/components/blame_file.rs b/src/components/blame_file.rs
index b560d301..45f308fd 100644
--- a/src/components/blame_file.rs
+++ b/src/components/blame_file.rs
@@ -209,7 +209,7 @@ impl Component for BlameFileComponent {
return self.selected_commit().map_or(
Ok(EventState::NotConsumed),
|id| {
- self.queue.borrow_mut().push_back(
+ self.queue.push(
InternalEvent::InspectCommit(
id, None,
),
diff --git a/src/components/branchlist.rs b/src/components/branchlist.rs
index 8dc2d69b..f2ba49cc 100644
--- a/src/components/branchlist.rs
+++ b/src/components/branchlist.rs
@@ -199,36 +199,29 @@ impl Component for BranchListComponent {
} else if e == self.key_config.create_branch
&& self.local
{
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::CreateBranch);
+ self.queue.push(InternalEvent::CreateBranch);
} else if e == self.key_config.rename_branch
&& self.valid_selection()
{
let cur_branch =
&self.branches[self.selection as usize];
- self.queue.borrow_mut().push_back(
- InternalEvent::RenameBranch(
- cur_branch.reference.clone(),
- cur_branch.name.clone(),
- ),
- );
+ self.queue.push(InternalEvent::RenameBranch(
+ cur_branch.reference.clone(),
+ cur_branch.name.clone(),
+ ));
self.update_branches()?;
} else if e == self.key_config.delete_branch
&& !self.selection_is_cur_branch()
&& self.valid_selection()
{
- self.queue.borrow_mut().push_back(
- InternalEvent::ConfirmAction(
- Action::DeleteBranch(
- self.branches
- [self.selection as usize]
- .reference
- .clone(),
- ),
+ self.queue.push(InternalEvent::ConfirmAction(
+ Action::DeleteBranch(
+ self.branches[self.selection as usize]
+ .reference
+ .clone(),
),
- );
+ ));
} else if e == self.key_config.merge_branch
&& !self.selection_is_cur_branch()
&& self.valid_selection()
@@ -239,9 +232,9 @@ impl Component for BranchListComponent {
self.merge_branch()
);
self.hide();
- self.queue.borrow_mut().push_back(
- InternalEvent::Update(NeedsUpdate::ALL),
- );
+ self.queue.push(InternalEvent::Update(
+ NeedsUpdate::ALL,
+ ));
} else if e == self.key_config.tab_toggle {
self.local = !self.local;
self.update_branches()?;
@@ -506,9 +499,7 @@ impl BranchListComponent {
self.update_branches()?;
}
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::Update(NeedsUpdate::ALL));
+ self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
Ok(())
}
diff --git a/src/components/changes.rs b/src/components/changes.rs
index de381326..c50d3b24 100644
--- a/src/components/changes.rs
+++ b/src/components/changes.rs
@@ -88,9 +88,8 @@ impl ChangesComponent {
};
if self.is_empty() {
- self.queue.borrow_mut().push_back(
- InternalEvent::StatusLastFileMoved,
- );
+ self.queue
+ .push(InternalEvent::StatusLastFileMoved);
}
return Ok(true);
@@ -116,9 +115,7 @@ impl ChangesComponent {
fn index_add_all(&mut self) -> Result<()> {
sync::stage_add_all(CWD, "*")?;
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::Update(NeedsUpdate::ALL));
+ self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
Ok(())
}
@@ -126,9 +123,7 @@ impl ChangesComponent {
fn stage_remove_all(&mut self) -> Result<()> {
sync::reset_stage(CWD, "*")?;
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::Update(NeedsUpdate::ALL));
+ self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
Ok(())
}
@@ -137,14 +132,12 @@ impl ChangesComponent {
if let Some(tree_item) = self.selection() {
let is_folder =
matches!(tree_item.kind, FileTreeItemKind::Path(_));
- self.queue.borrow_mut().push_back(
- InternalEvent::ConfirmAction(Action::Reset(
- ResetItem {
- path: tree_item.info.full_path,
- is_folder,
- },
- )),
- );
+ self.queue.push(InternalEvent::ConfirmAction(
+ Action::Reset(ResetItem {
+ path: tree_item.info.full_path,
+ is_folder,
+ }),
+ ));
return true;
}
@@ -156,16 +149,15 @@ impl ChangesComponent {
if let Err(e) =
sync::add_to_ignore(CWD, &tree_item.info.full_path)
{
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ format!(
"ignore error:\n{}\nfile:\n{:?}",
e, tree_item.info.full_path
- )),
- );
+ ),
+ ));
} else {
- self.queue.borrow_mut().push_back(
- InternalEvent::Update(NeedsUpdate::ALL),
- );
+ self.queue
+ .push(InternalEvent::Update(NeedsUpdate::ALL));
return true;
}
@@ -253,9 +245,7 @@ impl Component for ChangesComponent {
&& !self.is_working_dir
&& !self.is_empty()
{
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::OpenCommit);
+ self.queue.push(InternalEvent::OpenCommit);
Ok(EventState::Consumed)
} else if e == self.key_config.enter {
try_or_popup!(
@@ -264,9 +254,9 @@ impl Component for ChangesComponent {
self.index_add_remove()
);
- self.queue.borrow_mut().push_back(
- InternalEvent::Update(NeedsUpdate::ALL),
- );
+ self.queue.push(InternalEvent::Update(
+ NeedsUpdate::ALL,
+ ));
Ok(EventState::Consumed)
} else if e == self.key_config.status_stage_all
&& !self.is_empty()
@@ -280,9 +270,8 @@ impl Component for ChangesComponent {
} else {
self.stage_remove_all()?;
}
- self.queue.borrow_mut().push_back(
- InternalEvent::StatusLastFileMoved,
- );
+ self.queue
+ .push(InternalEvent::StatusLastFileMoved);
Ok(EventState::Consumed)
} else if e == self.key_config.status_reset_item
&& self.is_working_dir
diff --git a/src/components/commit.rs b/src/components/commit.rs
index f065e79e..1b7788bd 100644
--- a/src/components/commit.rs
+++ b/src/components/commit.rs
@@ -187,12 +187,10 @@ impl CommitComponent {
fn commit_with_msg(&mut self, msg: String) -> Result<()> {
if let HookResult::NotOk(e) = sync::hooks_pre_commit(CWD)? {
log::error!("pre-commit hook error: {}", e);
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "pre-commit hook error:\n{}",
- e
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(format!(
+ "pre-commit hook error:\n{}",
+ e
+ )));
return Ok(());
}
let mut msg = msg;
@@ -200,12 +198,10 @@ impl CommitComponent {
sync::hooks_commit_msg(CWD, &mut msg)?
{
log::error!("commit-msg hook error: {}", e);
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "commit-msg hook error:\n{}",
- e
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(format!(
+ "commit-msg hook error:\n{}",
+ e
+ )));
return Ok(());
}
@@ -217,30 +213,24 @@ impl CommitComponent {
if let Err(e) = res {
log::error!("commit error: {}", &e);
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "commit failed:\n{}",
- &e
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(format!(
+ "commit failed:\n{}",
+ &e
+ )));
return Ok(());
}
if let HookResult::NotOk(e) = sync::hooks_post_commit(CWD)? {
log::error!("post-commit hook error: {}", e);
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "post-commit hook error:\n{}",
- e
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(format!(
+ "post-commit hook error:\n{}",
+ e
+ )));
}
self.hide();
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::Update(NeedsUpdate::ALL));
+ self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
Ok(())
}
@@ -349,7 +339,7 @@ impl Component for CommitComponent {
{
self.amend()?;
} else if e == self.key_config.open_commit_editor {
- self.queue.borrow_mut().push_back(
+ self.queue.push(
InternalEvent::OpenExternalEditor(None),
);
self.hide();
diff --git a/src/components/create_branch.rs b/src/components/create_branch.rs
index 68498290..434e6abb 100644
--- a/src/components/create_branch.rs
+++ b/src/components/create_branch.rs
@@ -122,18 +122,15 @@ impl CreateBranchComponent {
match res {
Ok(_) => {
- self.queue.borrow_mut().push_back(
- InternalEvent::Update(NeedsUpdate::BRANCHES),
- );
+ self.queue.push(InternalEvent::Update(
+ NeedsUpdate::BRANCHES,
+ ));
}
Err(e) => {
log::error!("create branch: {}", e,);
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "create branch error:\n{}",
- e,
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ format!("create branch error:\n{}", e,),
+ ));
}
}
}
diff --git a/src/components/diff.rs b/src/components/diff.rs
index 5f19478a..8b715599 100644
--- a/src/components/diff.rs
+++ b/src/components/diff.rs
@@ -491,10 +491,7 @@ impl DiffComponent {
}
fn queue_update(&self) {
- self.queue
- .as_ref()
- .borrow_mut()
- .push_back(InternalEvent::Update(NeedsUpdate::ALL));
+ self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
}
fn reset_hunk(&self) {
@@ -502,23 +499,23 @@ impl DiffComponent {
if let Some(hunk) = self.selected_hunk {
let hash = diff.hunks[hunk].header_hash;
- self.queue.as_ref().borrow_mut().push_back(
- InternalEvent::ConfirmAction(Action::ResetHunk(
+ self.queue.push(InternalEvent::ConfirmAction(
+ Action::ResetHunk(
self.current.path.clone(),
hash,
- )),
- );
+ ),
+ ));
}
}
}
fn reset_lines(&self) {
- self.queue.as_ref().borrow_mut().push_back(
- InternalEvent::ConfirmAction(Action::ResetLines(
+ self.queue.push(InternalEvent::ConfirmAction(
+ Action::ResetLines(
self.current.path.clone(),
self.selected_lines(),
- )),
- );
+ ),
+ ));
}
fn stage_lines(&self) {
@@ -569,12 +566,12 @@ impl DiffComponent {
}
fn reset_untracked(&self) {
- self.queue.as_ref().borrow_mut().push_back(
- InternalEvent::ConfirmAction(Action::Reset(ResetItem {
+ self.queue.push(InternalEvent::ConfirmAction(Action::Reset(
+ ResetItem {
path: self.current.path.clone(),
is_folder: false,
- })),
- );
+ },
+ )));
}
fn stage_unstage_hunk(&mut self) -> Result<()> {
diff --git a/src/components/filetree.rs b/src/components/filetree.rs
index 656fcba4..fc8059bd 100644
--- a/src/components/filetree.rs
+++ b/src/components/filetree.rs
@@ -129,9 +129,7 @@ impl FileTreeComponent {
if changed {
if let Some(ref queue) = self.queue {
- queue.borrow_mut().push_back(InternalEvent::Update(
- NeedsUpdate::DIFF,
- ));
+ queue.push(InternalEvent::Update(NeedsUpdate::DIFF));
}
}
@@ -409,11 +407,9 @@ impl Component for FileTreeComponent {
return if e == self.key_config.blame {
match (&self.queue, self.selection_file()) {
(Some(queue), Some(status_item)) => {
- queue.borrow_mut().push_back(
- InternalEvent::BlameFile(
- status_item.path,
- ),
- );
+ queue.push(InternalEvent::BlameFile(
+ status_item.path,
+ ));
Ok(EventState::Consumed)
}
diff --git a/src/components/inspect_commit.rs b/src/components/inspect_commit.rs
index c7536ce8..ff596fa8 100644
--- a/src/components/inspect_commit.rs
+++ b/src/components/inspect_commit.rs
@@ -138,9 +138,9 @@ impl Component for InspectCommitComponent {
self.diff.focus(false);
} else if e == self.key_config.open_file_tree {
if let Some(commit) = self.commit_id {
- self.queue.borrow_mut().push_back(
- InternalEvent::OpenFileTree(commit),
- );
+ self.queue.push(InternalEvent::OpenFileTree(
+ commit,
+ ));
self.hide();
}
} else if e == self.key_config.focus_left {
diff --git a/src/components/pull.rs b/src/components/pull.rs
index 7c4f5de1..a041edbe 100644
--- a/src/components/pull.rs
+++ b/src/components/pull.rs
@@ -136,12 +136,9 @@ impl PullComponent {
} else {
self.pending = false;
self.hide();
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "fetch failed:\n{}",
- err
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ format!("fetch failed:\n{}", err),
+ ));
}
}
}
@@ -186,13 +183,13 @@ impl PullComponent {
}
fn confirm_merge(&mut self, incoming: usize) {
- self.queue.borrow_mut().push_back(
- InternalEvent::ConfirmAction(Action::PullMerge {
+ self.queue.push(InternalEvent::ConfirmAction(
+ Action::PullMerge {
incoming,
rebase: sync::config_is_pull_rebase(CWD)
.unwrap_or_default(),
- }),
- );
+ },
+ ));
self.hide();
}
}
diff --git a/src/components/push.rs b/src/components/push.rs
index 29fad53d..4ea025f1 100644
--- a/src/components/push.rs
+++ b/src/components/push.rs
@@ -148,12 +148,9 @@ impl PushComponent {
if !self.pending {
if let Some(err) = self.git_push.last_result()? {
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "push failed:\n{}",
- err
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ format!("push failed:\n{}", err),
+ ));
}
self.hide();
}
diff --git a/src/components/push_tags.rs b/src/components/push_tags.rs
index 2e67ad04..9ea4ca68 100644
--- a/src/components/push_tags.rs
+++ b/src/components/push_tags.rs
@@ -117,12 +117,9 @@ impl PushTagsComponent {
if !self.pending {
if let Some(err) = self.git_push.last_result()? {
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "push tags failed:\n{}",
- err
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ format!("push tags failed:\n{}", err),
+ ));
}
self.hide();
}
diff --git a/src/components/rename_branch.rs b/src/components/rename_branch.rs
index 0963e0d6..4e6991a1 100644
--- a/src/components/rename_branch.rs
+++ b/src/components/rename_branch.rs
@@ -135,29 +135,22 @@ impl RenameBranchComponent {
match res {
Ok(_) => {
- self.queue.borrow_mut().push_back(
- InternalEvent::Update(NeedsUpdate::ALL),
- );
+ self.queue.push(InternalEvent::Update(
+ NeedsUpdate::ALL,
+ ));
self.hide();
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::SelectBranch);
+ self.queue.push(InternalEvent::SelectBranch);
}
Err(e) => {
log::error!("create branch: {}", e,);
- self.queue.borrow_mut().push_back(
- InternalEvent::ShowErrorMsg(format!(
- "rename branch error:\n{}",
- e,
- )),
- );
+ self.queue.push(InternalEvent::ShowErrorMsg(
+ format!("rename branch error:\n{}", e,),
+ ));
}
}
} else {
log::error!("create branch: No branch selected");
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::ShowErrorMsg(
+ self.queue.push(InternalEvent::ShowErrorMsg(
"rename branch error: No branch selected to rename"
.to_string(),
));
diff --git a/src/components/reset.rs b/src/components/reset.rs
index 1aa094d2..24cb0f43 100644
--- a/src/components/reset.rs
+++ b/src/components/reset.rs
@@ -126,9 +126,7 @@ impl ResetComponent {
///
pub fn confirm(&mut self) {
if let Some(a) = self.target.take() {
- self.queue
- .borrow_mut()
- .push_back(InternalEvent::ConfirmedAction(a));
+ self.queue.push(InternalEvent::ConfirmedAction(a));
}
self.hide();
diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs
index 32199eda..8f009a0c 100644
--- a/src/components/revision_files.rs
+++ b/src/components/revision_files.rs
@@ -130,14 +130,12 @@ impl RevisionFilesComponent {
fn blame(&self) -> bool {
self.tree.selected_file().map_or(false, |file| {
- self.queue.borrow_mut().push_back(
- InternalEvent::BlameFile(
- file.full_path_str()
- .strip_prefix("./")
- .unwrap_or_default()
- .to_string(),
- ),
- );
+ self.queue.push(InternalEvent::BlameFile(
+ file.full_path_str()
+ .strip_prefix("./")
+ .unwrap_or_default()
+ .to_string(),
+ ));
true
})
}
diff --git a/src/components/stashmsg.rs b/src/components/stashmsg.rs
index 9d428bad..d7710c74 100644
--- a/src/components/stashmsg.rs
+++ b/src/components/stashmsg.rs
@@ -77,11 +77,9 @@ impl Component for StashMsgComponent {
self.input.clear();
self.hide();
- self.queue.borrow_mut().push_back(
- InternalEvent::Update(
- NeedsUpdate::ALL,
- ),
- );
+ self.queue.push(InternalEvent::Update(
+ NeedsUpdate::ALL,
+ ));
}
Err(e) => {
self.hide();
@@ -90,7 +88,7 @@ impl Component for StashMsgComponent {
e,
self.options
);
- self.queue.borrow_mut().push_back(
+ self.queue.push(
InternalEvent::ShowErrorMsg(format!(
"stash error:\n{}\noptions:\n{:?}",
e, self.options
diff --git a/src/components/tag_commit.rs b/src/components/tag_commit.rs
index 7beec95f..d06263f0 100644
--- a/src/components/tag_commit.rs
+++ b/src/components/tag_commit.rs
@@ -126,19 +126,16 @@ impl TagCommitComponent {
self.input.clear();
self.hide();
- self.queue.borrow_mut().push_back(
- InternalEvent::Update(Nee