Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/but-testing/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use but_workspace::{
DiffSpec, HunkHeader,
branch::{
OnWorkspaceMergeConflict,
apply::{IntegrationMode, WorkspaceReferenceNaming},
apply::{WorkspaceMerge, WorkspaceReferenceNaming},
checkout::UncommitedWorktreeChanges,
create_reference::{Anchor, Position},
},
Expand Down Expand Up @@ -709,7 +709,7 @@ pub fn apply(args: &super::Args, short_name: &str, order: Option<usize>) -> anyh
&repo,
&mut *meta,
but_workspace::branch::apply::Options {
integration_mode: IntegrationMode::AlwaysMerge,
workspace_merge: WorkspaceMerge::AlwaysMerge,
on_workspace_conflict: OnWorkspaceMergeConflict::MaterializeAndReportConflictingStacks,
workspace_reference_naming: WorkspaceReferenceNaming::Default,
uncommitted_changes: UncommitedWorktreeChanges::KeepAndAbortOnConflict,
Expand Down
24 changes: 12 additions & 12 deletions crates/but-workspace/src/branch/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ impl std::fmt::Debug for Outcome<'_> {
}
}

/// How the newly applied branch should be integrated into the workspace.
/// How the newly applied branch should be merged into the workspace commit.
#[derive(Default, Debug, Copy, Clone)]
pub enum IntegrationMode {
pub enum WorkspaceMerge {
/// Do nothing but to merge it into the workspace commit, *even* if it's not needed as the workspace reference
/// can connect directly with the *one* workspace base.
/// This also ensures that there is a workspace merge commit.
/// This also ensures that there is a workspace merge commit, even if it is none-sensical.
#[default]
AlwaysMerge,
/// Only create a merge commit if a new commit is effectively merged in. This avoids *unnecessary* merge commits,
Expand All @@ -89,8 +89,8 @@ pub enum WorkspaceReferenceNaming {
/// Options for [function::apply()].
#[derive(Default, Debug, Clone)]
pub struct Options {
/// how the branch should be brought into the workspace.
pub integration_mode: IntegrationMode,
/// How the branch should be brought into the workspace.
pub workspace_merge: WorkspaceMerge,
/// Decide how to deal with conflicts when creating the workspace merge commit to bring in each stack.
pub on_workspace_conflict: OnWorkspaceMergeConflict,
/// How the workspace reference should be named should it be created.
Expand Down Expand Up @@ -132,7 +132,7 @@ pub(crate) mod function {
};
use tracing::instrument;

use super::{IntegrationMode, Options, Outcome, WorkspaceReferenceNaming};
use super::{Options, Outcome, WorkspaceMerge, WorkspaceReferenceNaming};
use crate::{WorkspaceCommit, branch::checkout, ext::ObjectStorageExt, ref_info::WorkspaceExt};

/// Apply `branch` to the given `workspace`, and possibly create the workspace reference in `repo`
Expand Down Expand Up @@ -162,7 +162,7 @@ pub(crate) mod function {
repo: &gix::Repository,
meta: &mut impl RefMetadata,
Options {
integration_mode,
workspace_merge: integration_mode,
on_workspace_conflict,
workspace_reference_naming,
uncommitted_changes,
Expand Down Expand Up @@ -390,7 +390,7 @@ pub(crate) mod function {
&ws_md,
local_tracking_config_and_ref_info,
)?;
let ws_commit_with_new_message = WorkspaceCommit::from_graph_workspace(
let ws_commit_with_new_message = WorkspaceCommit::from_graph_workspace_and_tree(
&workspace,
repo,
head_id.object()?.peel_to_tree()?.id,
Expand Down Expand Up @@ -635,7 +635,7 @@ pub(crate) mod function {
/// Setup `local_tracking_ref` to track `remote_tracking_ref` using the typical pattern, and prepare the configuration file
/// so that it can replace `.git/config` of `repo` when written back, with everything the same but the branch configuration added.
/// We also return the commit at which `local_tracking_ref` should be placed, which is assumed to not exist, and `repo` will be used
/// for computing the merge-base with `ws_ref_name`, traditionally, without a graph, as forcing the graph here wouldn't buy us anything.
/// for computing the merge-base with `ws_ref_id`, traditionally, without a graph, as forcing the graph here wouldn't buy us anything.
/// Merge-base computations can still be done with `repo` IF the graph isn't up to date.
fn setup_local_tracking_configuration(
repo: &gix::Repository,
Expand Down Expand Up @@ -827,18 +827,18 @@ pub(crate) mod function {

fn needs_workspace_commit_without_remerge(
ws: &but_graph::projection::Workspace<'_>,
integration_mode: IntegrationMode,
integration_mode: WorkspaceMerge,
) -> bool {
match integration_mode {
IntegrationMode::AlwaysMerge => match ws.kind {
WorkspaceMerge::AlwaysMerge => match ws.kind {
WorkspaceKind::Managed { .. } => false,
WorkspaceKind::AdHoc => {
// If it's still ad-hoc, there must be a reason, and we don't try to create a managed commit
false
}
WorkspaceKind::ManagedMissingWorkspaceCommit { .. } => true,
},
IntegrationMode::MergeIfNeeded => false,
WorkspaceMerge::MergeIfNeeded => false,
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/but-workspace/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl<'repo> WorkspaceCommit<'repo> {
/// A way to create a commit from `workspace` stacks, with the `tree` being used as the tree of the workspace commit.
/// It's supposed to be the legitimate merge of the stacks contained in `workspace`.
/// Note that it will be written to `repo` immediately for persistence, with its object id returned.
pub fn from_graph_workspace(
pub fn from_graph_workspace_and_tree(
workspace: &but_graph::projection::Workspace,
repo: &'repo gix::Repository,
tree: gix::ObjectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use but_testsupport::{
};
use but_workspace::branch::{
OnWorkspaceMergeConflict,
apply::{IntegrationMode, WorkspaceReferenceNaming},
apply::{WorkspaceMerge, WorkspaceReferenceNaming},
checkout::UncommitedWorktreeChanges,
};
use gix::refs::Category;
Expand Down Expand Up @@ -372,7 +372,7 @@ fn no_ws_ref_no_ws_commit_two_stacks_on_same_commit_ad_hoc_workspace_without_tar
&repo,
&mut meta,
but_workspace::branch::apply::Options {
integration_mode: IntegrationMode::AlwaysMerge,
workspace_merge: WorkspaceMerge::AlwaysMerge,
..default_options()
},
)?;
Expand All @@ -396,7 +396,7 @@ fn no_ws_ref_no_ws_commit_two_stacks_on_same_commit_ad_hoc_workspace_without_tar
&repo,
&mut meta,
but_workspace::branch::apply::Options {
integration_mode: IntegrationMode::AlwaysMerge,
workspace_merge: WorkspaceMerge::AlwaysMerge,
..default_options()
},
)?;
Expand Down Expand Up @@ -1540,7 +1540,7 @@ fn unborn_apply_needs_base() -> anyhow::Result<()> {

fn default_options() -> but_workspace::branch::apply::Options {
but_workspace::branch::apply::Options {
integration_mode: IntegrationMode::MergeIfNeeded,
workspace_merge: WorkspaceMerge::MergeIfNeeded,
on_workspace_conflict: OnWorkspaceMergeConflict::AbortAndReportConflictingStacks,
workspace_reference_naming: WorkspaceReferenceNaming::Default,
uncommitted_changes: UncommitedWorktreeChanges::KeepAndAbortOnConflict,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Context, Result, anyhow, bail};
use but_workspace::{
branch::{
OnWorkspaceMergeConflict,
apply::{IntegrationMode, WorkspaceReferenceNaming},
apply::{WorkspaceMerge, WorkspaceReferenceNaming},
checkout::UncommitedWorktreeChanges,
},
stack_ext::StackExt,
Expand Down Expand Up @@ -159,7 +159,7 @@ impl BranchManager<'_> {
&repo,
&mut *meta,
but_workspace::branch::apply::Options {
integration_mode: IntegrationMode::AlwaysMerge,
workspace_merge: WorkspaceMerge::AlwaysMerge,
on_workspace_conflict:
OnWorkspaceMergeConflict::MaterializeAndReportConflictingStacks,
workspace_reference_naming: WorkspaceReferenceNaming::Default,
Expand Down
Loading