Skip to content

Commit 7693b7b

Browse files
committed
removes the legacy bool indicatin a vbranch is applied
1 parent 49dd543 commit 7693b7b

File tree

8 files changed

+8
-66
lines changed

8 files changed

+8
-66
lines changed

crates/gitbutler-branch-actions/src/base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ pub(crate) fn set_base_branch(
248248
order: 0,
249249
selected_for_changes: None,
250250
allow_rebasing: ctx.project().ok_with_force_push.into(),
251-
applied: true,
252251
in_workspace: true,
253252
not_in_workspace_wip_change_id: None,
254253
references: vec![],

crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ impl BranchManager<'_> {
110110
order,
111111
selected_for_changes,
112112
allow_rebasing: self.ctx.project().ok_with_force_push.into(),
113-
applied: true,
114113
in_workspace: true,
115114
not_in_workspace_wip_change_id: None,
116115
source_refname: None,
@@ -237,7 +236,6 @@ impl BranchManager<'_> {
237236
branch.order = order;
238237
branch.selected_for_changes = selected_for_changes;
239238
branch.allow_rebasing = self.ctx.project().ok_with_force_push.into();
240-
branch.applied = true;
241239
branch.in_workspace = true;
242240

243241
branch
@@ -257,7 +255,6 @@ impl BranchManager<'_> {
257255
order,
258256
selected_for_changes,
259257
allow_rebasing: self.ctx.project().ok_with_force_push.into(),
260-
applied: true,
261258
in_workspace: true,
262259
not_in_workspace_wip_change_id: None,
263260
references: vec![],

crates/gitbutler-branch-actions/src/integration.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ pub(crate) fn get_workspace_head(ctx: &CommandContext) -> Result<git2::Oid> {
6161
} else {
6262
// This branch should have already been unapplied during the "update" command but for some reason that failed
6363
tracing::warn!("Merge conflict between base and {:?}", branch.name);
64-
branch.applied = false;
6564
branch.in_workspace = false;
6665
vb_state.set_branch(branch.clone())?;
6766
}

crates/gitbutler-branch-actions/src/virtual.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::{
2-
branch_manager::BranchManagerExt,
32
commit::{commit_to_vbranch_commit, VirtualBranchCommit},
43
conflicts::{self, RepoConflictsExt},
54
file::VirtualBranchFile,
@@ -224,33 +223,6 @@ fn find_base_tree<'a>(
224223
Ok(base_tree)
225224
}
226225

227-
/// Resolves the "old_applied" state of branches
228-
///
229-
/// This should only ever be called by `list_virtual_branches
230-
///
231-
/// This checks for the case where !branch.old_applied && branch.in_workspace
232-
/// If this is the case, we ought to unapply the branch as it has been carried
233-
/// over from the old style of unapplying
234-
fn fixup_old_applied_state(
235-
ctx: &CommandContext,
236-
vb_state: &VirtualBranchesHandle,
237-
perm: &mut WorktreeWritePermission,
238-
) -> Result<()> {
239-
let branches = vb_state.list_all_branches()?;
240-
241-
let branch_manager = ctx.branch_manager();
242-
243-
for mut branch in branches {
244-
if branch.is_old_unapplied() {
245-
branch_manager.convert_to_real_branch(branch.id, perm)?;
246-
} else if branch.applied != branch.in_workspace {
247-
branch.applied = branch.in_workspace;
248-
vb_state.set_branch(branch)?;
249-
}
250-
}
251-
252-
Ok(())
253-
}
254226
pub fn list_virtual_branches(
255227
ctx: &CommandContext,
256228
perm: &mut WorktreeWritePermission,
@@ -275,8 +247,6 @@ pub fn list_virtual_branches_cached(
275247

276248
let vb_state = ctx.project().virtual_branches();
277249

278-
fixup_old_applied_state(ctx, &vb_state, perm)?;
279-
280250
let default_target = vb_state
281251
.get_default_target()
282252
.context("failed to get default target")?;

crates/gitbutler-branch/src/branch.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ pub struct Branch {
5252
pub selected_for_changes: Option<i64>,
5353
#[serde(default = "default_true")]
5454
pub allow_rebasing: bool,
55-
/// This is the old metric for determining whether the branch is in the workspace
56-
/// This is kept in sync with in_workspace
57-
/// There should only be one condition where `applied` is false and `in_workspace`
58-
/// true.
59-
///
60-
/// This is after updating, the `in_workspace` property will have defaulted to true
61-
/// but the old `applied` property will have remained false.
62-
#[serde(default = "default_true")]
63-
pub applied: bool,
6455
/// This is the new metric for determining whether the branch is in the workspace, which means it's applied
6556
/// and its effects are available to the user.
6657
#[serde(default = "default_true")]
@@ -95,19 +86,6 @@ impl Branch {
9586
pub fn refname(&self) -> anyhow::Result<VirtualRefname> {
9687
self.try_into()
9788
}
98-
99-
/// self.applied and self.in_workspace are kept in sync by the application
100-
///
101-
/// There is only once case where this might not be the case which is when
102-
/// the user has upgraded to the new version for the fisrt time.
103-
///
104-
/// In this state, the `in_workspace` property will have defaulted to true
105-
/// but the old `applied` property will have remained false.
106-
///
107-
/// This function indicates this state
108-
pub fn is_old_unapplied(&self) -> bool {
109-
!self.applied && self.in_workspace
110-
}
11189
}
11290

11391
impl TryFrom<&Branch> for VirtualRefname {

crates/gitbutler-branch/src/state.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl VirtualBranches {
4343
self.list_all_branches().map(|branches| {
4444
branches
4545
.into_iter()
46-
.filter(|branch| branch.in_workspace && !branch.is_old_unapplied())
46+
.filter(|branch| branch.in_workspace)
4747
.collect()
4848
})
4949
}
@@ -110,7 +110,6 @@ impl VirtualBranchesHandle {
110110
pub fn mark_as_not_in_workspace(&self, id: BranchId) -> Result<()> {
111111
let mut branch = self.get_branch(id)?;
112112
branch.in_workspace = false;
113-
branch.applied = false;
114113
self.set_branch(branch)?;
115114
Ok(())
116115
}
@@ -152,9 +151,7 @@ impl VirtualBranchesHandle {
152151
/// Gets the state of the given virtual branch returning `Some(branch)` or `None`
153152
/// if that branch doesn't exist.
154153
pub fn try_branch_in_workspace(&self, id: BranchId) -> Result<Option<Branch>> {
155-
Ok(self
156-
.try_branch(id)?
157-
.filter(|branch| branch.in_workspace && !branch.is_old_unapplied()))
154+
Ok(self.try_branch(id)?.filter(|branch| branch.in_workspace))
158155
}
159156

160157
/// Gets the state of the given virtual branch returning `Some(branch)` or `None`
@@ -180,7 +177,7 @@ impl VirtualBranchesHandle {
180177
self.list_all_branches().map(|branches| {
181178
branches
182179
.into_iter()
183-
.filter(|branch| branch.in_workspace && !branch.is_old_unapplied())
180+
.filter(|branch| branch.in_workspace)
184181
.collect()
185182
})
186183
}

crates/gitbutler-branch/tests/ownership.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ fn reconcile_ownership_simple() {
3535
order: usize::default(),
3636
selected_for_changes: None,
3737
allow_rebasing: true,
38-
applied: true,
3938
in_workspace: true,
4039
not_in_workspace_wip_change_id: None,
4140
source_refname: None,
@@ -64,7 +63,6 @@ fn reconcile_ownership_simple() {
6463
order: usize::default(),
6564
selected_for_changes: None,
6665
allow_rebasing: true,
67-
applied: true,
6866
in_workspace: true,
6967
not_in_workspace_wip_change_id: None,
7068
source_refname: None,

crates/gitbutler-cli/src/command/vbranch.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ pub fn list(project: Project) -> Result<()> {
3232
for vbranch in branches {
3333
println!(
3434
"{active} {id} {name} {upstream} {default}",
35-
active = if vbranch.applied { "✔️" } else { "⛌" },
35+
active = if vbranch.in_workspace {
36+
"✔️"
37+
} else {
38+
"⛌"
39+
},
3640
id = vbranch.id,
3741
name = vbranch.name,
3842
upstream = vbranch

0 commit comments

Comments
 (0)