mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 07:14:38 +00:00
cli: branch: inline view.remove_branch() in cmd_branch_forget()
This API no longer makes sense, and we'll probably add some flags to forget only tracked remotes for example.
This commit is contained in:
parent
e7ea0d579a
commit
76ff35eba4
3 changed files with 8 additions and 15 deletions
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
use itertools::Itertools as _;
|
||||
use jj_lib::op_store::BranchTarget;
|
||||
use jj_lib::op_store::{BranchTarget, RefTarget, RemoteRef};
|
||||
use jj_lib::str_util::StringPattern;
|
||||
use jj_lib::view::View;
|
||||
|
||||
|
@ -47,8 +47,13 @@ pub fn cmd_branch_forget(
|
|||
let repo = workspace_command.repo().clone();
|
||||
let matched_branches = find_forgettable_branches(repo.view(), &args.names)?;
|
||||
let mut tx = workspace_command.start_transaction();
|
||||
for (name, _) in &matched_branches {
|
||||
tx.mut_repo().remove_branch(name);
|
||||
for (name, branch_target) in &matched_branches {
|
||||
tx.mut_repo()
|
||||
.set_local_branch_target(name, RefTarget::absent());
|
||||
for (remote_name, _) in &branch_target.remote_refs {
|
||||
tx.mut_repo()
|
||||
.set_remote_branch(name, remote_name, RemoteRef::absent());
|
||||
}
|
||||
}
|
||||
tx.finish(
|
||||
ui,
|
||||
|
|
|
@ -1428,10 +1428,6 @@ impl MutableRepo {
|
|||
self.view.mark_dirty();
|
||||
}
|
||||
|
||||
pub fn remove_branch(&mut self, name: &str) {
|
||||
self.view_mut().remove_branch(name);
|
||||
}
|
||||
|
||||
pub fn get_local_branch(&self, name: &str) -> RefTarget {
|
||||
self.view.with_ref(|v| v.get_local_branch(name).clone())
|
||||
}
|
||||
|
|
|
@ -96,14 +96,6 @@ impl View {
|
|||
self.data.head_ids.remove(head_id);
|
||||
}
|
||||
|
||||
// TODO: maybe rename to forget_branch() because this seems unusual operation?
|
||||
pub fn remove_branch(&mut self, name: &str) {
|
||||
self.data.local_branches.remove(name);
|
||||
for remote_view in self.data.remote_views.values_mut() {
|
||||
remote_view.branches.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterates local branch `(name, target)`s in lexicographical order.
|
||||
pub fn local_branches(&self) -> impl Iterator<Item = (&str, &RefTarget)> {
|
||||
self.data
|
||||
|
|
Loading…
Reference in a new issue