From 8e0a4a09629f2af39c71009777c65ffa23d70338 Mon Sep 17 00:00:00 2001 From: Philip Metzger Date: Tue, 2 May 2023 16:30:25 +0200 Subject: [PATCH] run: Teach `run` to resolve revsets and other minor adjustments. This also adds `jobs`, the argument reading the thread count to use, and making execute a no-op boolean, like the `-r` in describe. While we're at it, teach `run` to resolve the passed revsets. --- cli/src/commands/mod.rs | 30 ++++++++++++++++++++++++++++++ cli/src/commands/run.rs | 28 +++++++++++++++++++--------- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 736c04af87..1253cc304b 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -281,6 +281,36 @@ struct RestoreArgs { revision: Option, } +/// Touch up the content changes in a revision with a diff editor +/// +/// With the `-r` option, which is the default, starts a diff editor (`meld` by +/// default) on the changes in the revision. +/// +/// With the `--from` and/or `--to` options, starts a diff editor comparing the +/// "from" revision to the "to" revision. +/// +/// Edit the right side of the diff until it looks the way you want. Once you +/// close the editor, the revision specified with `-r` or `--to` will be +/// updated. Descendants will be rebased on top as usual, which may result in +/// conflicts. +/// +/// See `jj restore` if you want to move entire files from one revision to +/// another. See `jj squash -i` or `jj unsquash -i` if you instead want to move +/// changes into or out of the parent revision. +#[derive(clap::Args, Clone, Debug)] +struct DiffeditArgs { + /// The revision to touch up. Defaults to @ if neither --to nor --from are + /// specified. + #[arg(long, short)] + revision: Option, + /// Show changes from this revision. Defaults to @ if --to is specified. + #[arg(long, conflicts_with = "revision")] + from: Option, + /// Edit changes in this revision. Defaults to @ if --from is specified. + #[arg(long, conflicts_with = "revision")] + to: Option, +} + /// Split a revision in two /// /// Starts a diff editor (`meld` by default) on the changes in the revision. diff --git a/cli/src/commands/run.rs b/cli/src/commands/run.rs index 6b1ebb261a..93865d2dfe 100644 --- a/cli/src/commands/run.rs +++ b/cli/src/commands/run.rs @@ -1,6 +1,10 @@ //! This file contains the internal implementation of `run`. -use crate::cli_util::{user_error, CommandError, CommandHelper, RevisionArg}; -use crate::ui::Ui; + +use crate::{ + cli_util::{resolve_multiple_nonempty_revsets, user_error, CommandError, CommandHelper}, + cli_util::{user_error, CommandError, CommandHelper}, + ui::Ui, +}; /// Run a command across a set of revisions. /// @@ -11,24 +15,30 @@ use crate::ui::Ui; /// # Example /// /// # Run pre-commit on your local work -/// $ jj run 'pre-commit.py .github/pre-commit.yaml' -r (main..@) -j 4 +/// $ jj run 'pre-commit run .github/pre-commit.yaml' -r (trunk()..@) -j 4 /// /// This allows pre-commit integration and other funny stuff. #[derive(clap::Args, Clone, Debug)] #[command(verbatim_doc_comment)] pub struct RunArgs { /// The command to run across all selected revisions. + shell_command: String, + /// A no-op option to match the interface of `git bisect -x`. #[arg(long, short, alias = "x")] - command: String, + command: bool, /// The revisions to change. + /// Multiple revsets are accepted and the work will be done on a + /// intersection of them. #[arg(long, short, default_value = "@")] revisions: Vec, + /// How many processes should run in parallel, uses by default all cores. + #[arg(long, short)] + jobs: Option, } -pub fn cmd_run( - _ui: &mut Ui, - _command: &CommandHelper, - _args: &RunArgs, -) -> Result<(), CommandError> { +fn cmd_run(_ui: &mut Ui, _command: &CommandHelper, __args: &RunArgs) -> Result<(), CommandError> { + let workspace_command = command.workspace_helper(ui)?; + let _resolved_commits = + resolve_multiple_nonempty_revsets(&args.revisions, &workspace_command, ui)?; Err(user_error("This is a stub, do not use")) }