Skip to content

Commit

Permalink
WIP: Features which need a implementation
Browse files Browse the repository at this point in the history
Split per feature
  • Loading branch information
PhilipMetzger committed Dec 5, 2023
1 parent 1fd421f commit 30ab252
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ use crate::cli_util::{
};
use crate::ui::Ui;

/// The Strategy `run` uses to deal with any failure in it's subprocesses.
#[derive(Debug, Default, Clone, clap::ValueEnum)]
pub(crate) enum ErrorStrategy {
/// Stop at any revision if the subprocess fails.
/// Cancels any scheduled work but lets already running processes finish
/// their work.
#[default]
Stop,
/// Continue if an error occurs, similar to Make's --keep-going.
Continue,
/// Signal a fatal failure and stop immediately any processes. Also stops
/// any running jobs.
Fatal,
}

/// Run a command across a set of revisions.
///
///
Expand All @@ -45,6 +60,34 @@ pub struct RunArgs {
/// How many processes should run in parallel, uses by default all cores.
#[arg(long, short)]
jobs: Option<usize>,
/// Setup the required environment and instead of applying running script,
/// display all actions which would be done.
#[arg(long, short)]
dry_run: bool,
/// Ignore changes across multiple run invocations.
#[arg(long)]
read_only: bool,
/// Show the diff of an affected revision.
#[arg(long)]
show: Option<RevisionArg>,
/// After running the command rebase the revisions parent onto the new
/// commit. This is the default strategy.
#[arg(long)]
rebase: bool,
/// After running the command, re-adjust the parent commit to the new
/// revision.
#[arg(long, conflicts_with = "rebase")]
reparent: bool,
/// Clean up all hidden state for run.
#[arg(long)]
clean: bool,
/// Run the command for all revisions, even if a single one fails.
/// Implies error-strategy=continue
#[arg(short, long)]
keep_going: bool,
/// The strategy `jj run` should use, if a failure occurs.
#[arg(value_enum, default_value = "ErrorStrategy::Stop")]
error_strategy: ErrorStrategy,
}

pub fn cmd_run(ui: &mut Ui, command: &CommandHelper, args: &RunArgs) -> Result<(), CommandError> {
Expand All @@ -59,8 +102,20 @@ pub fn cmd_run(ui: &mut Ui, command: &CommandHelper, args: &RunArgs) -> Result<(
Some(0) => return Err(user_error("must pass at least one job")),
Some(jobs) => Some(jobs),
None => std::thread::available_parallelism().map(|t| t.into()).ok(),
}
};
// Fallback to a single user-visible job.
.unwrap_or(1usize);
// let _repo = workspace_command.repo();

// let _repo = workspace_command.repo();
// let backend = _repo.store().working_copy_store();
// let wc_copies = backend.get_or_create_stores(commits);
// // If the user has not specified the amount of jobs to use, create one per cpu core,
// // this models falls apart for large jobs, which themselves require a nproc jobs
// // like cargo or ninja.
// let mut workqueue = WorkQueue::new(wc_copies, jobs);
// let (error_recv, status_recv) = workqueue.channels();
//
// block_on(workqueue.run().await?);
Err(user_error("This is a stub, do not use"))
}

0 comments on commit 30ab252

Please sign in to comment.