forked from mirrors/jj
cli: redefine default log revset using immutable_heads()
I think most users who change the set of immutable heads away from `trunk() | tags()` are going to also want to change the default log revset to include the newly mutable commit and to exclude the newly immutable commits. So let's update the default log revset to use `immutable_heads()` instead. `test_templater` changed because we have overridden the set of immutable commits there so `jj log` now includes the remote branch.
This commit is contained in:
parent
8ec402fc90
commit
58de7c292b
6 changed files with 34 additions and 17 deletions
|
@ -355,7 +355,8 @@ struct StatusArgs {}
|
|||
#[derive(clap::Args, Clone, Debug)]
|
||||
struct LogArgs {
|
||||
/// Which revisions to show. Defaults to the `revsets.log` setting, or
|
||||
/// `@ | ancestors((remote_branches() | tags()).., 2)` if it is not set.
|
||||
/// `@ | ancestors(immutable_heads().., 2) | heads(immutable_heads())` if
|
||||
/// it is not set.
|
||||
#[arg(long, short)]
|
||||
revisions: Vec<RevisionArg>,
|
||||
/// Show commits modifying the given paths
|
||||
|
|
|
@ -294,7 +294,7 @@
|
|||
"log": {
|
||||
"type": "string",
|
||||
"description": "Default set of revisions to show when no explicit revset is given for jj log and similar commands",
|
||||
"default": "@ | ancestors((remote_branches() | tags()).., 2)"
|
||||
"default": "@ | ancestors(immutable_heads().., 2) | heads(immutable_heads())"
|
||||
},
|
||||
"short-prefixes": {
|
||||
"type": "string",
|
||||
|
|
|
@ -165,8 +165,7 @@ fn test_branch_delete_glob() {
|
|||
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
@ bar-2 foo-1 foo-3 foo-4 6fbf398c2d59
|
||||
│
|
||||
~
|
||||
◉ 000000000000
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "delete", "--glob", "foo-[1-3]"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
|
@ -174,8 +173,7 @@ fn test_branch_delete_glob() {
|
|||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
@ bar-2 foo-1@origin foo-3@origin foo-4 6fbf398c2d59
|
||||
│
|
||||
~
|
||||
◉ 000000000000
|
||||
"###);
|
||||
|
||||
// We get an error if none of the globs match live branches. Unlike `jj branch
|
||||
|
@ -196,8 +194,7 @@ fn test_branch_delete_glob() {
|
|||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
@ bar-2 foo-1@origin foo-3@origin foo-4@origin 6fbf398c2d59
|
||||
│
|
||||
~
|
||||
◉ 000000000000
|
||||
"###);
|
||||
|
||||
// The deleted branches are still there
|
||||
|
|
|
@ -60,9 +60,23 @@ fn test_rewrite_immutable_generic() {
|
|||
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
|
||||
"###);
|
||||
// Error if we redefine immutable_heads() with an argument
|
||||
// TODO: This error comes from the built-in definition of
|
||||
// `revsets.short-prefixes`. That's not clear to the user.
|
||||
test_env.add_config(r#"revset-aliases."immutable_heads(foo)" = "none()""#);
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["edit", "root()"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Config error: Invalid `revsets.short-prefixes`: --> 1:31
|
||||
|
|
||||
1 | @ | ancestors(immutable_heads().., 2) | heads(immutable_heads())
|
||||
| ^
|
||||
|
|
||||
= Invalid arguments to revset function "immutable_heads": Expected 1 arguments
|
||||
For help, see https://github.com/martinvonz/jj/blob/main/docs/config.md.
|
||||
"###);
|
||||
// ... even if we also update the built-in call sites
|
||||
test_env.add_config(r#"revsets.short-prefixes = "immutable_heads(root())""#);
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["edit", "root()"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Error: The `revset-aliases.immutable_heads()` function must be declared without arguments.
|
||||
"###);
|
||||
}
|
||||
|
@ -82,19 +96,20 @@ fn test_rewrite_immutable_commands() {
|
|||
test_env.jj_cmd_success(&repo_path, &["branch", "create", "main"]);
|
||||
test_env.jj_cmd_success(&repo_path, &["new", "description(b)"]);
|
||||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "main""#);
|
||||
|
||||
// Log shows mutable commits and immutable heads by default
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["log"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
@ yqosqzyt test.user@example.com 2001-02-03 04:05:13.000 +07:00 3f89addf
|
||||
│ (empty) (no description set)
|
||||
│ ◉ mzvwutvl test.user@example.com 2001-02-03 04:05:11.000 +07:00 main d809c5d9 conflict
|
||||
╭─┤ (empty) merge
|
||||
◉ │ kkmpptxz test.user@example.com 2001-02-03 04:05:10.000 +07:00 c8d4c7ca
|
||||
│ │ b
|
||||
│ ◉ zsuskuln test.user@example.com 2001-02-03 04:05:11.000 +07:00 6e11f430
|
||||
├─╯ c
|
||||
◉ qpvuntsm test.user@example.com 2001-02-03 04:05:08.000 +07:00 46a8dc51
|
||||
│ a
|
||||
◉ zzzzzzzz root() 00000000
|
||||
│ │
|
||||
│ ~
|
||||
│
|
||||
◉ kkmpptxz test.user@example.com 2001-02-03 04:05:10.000 +07:00 c8d4c7ca
|
||||
│ b
|
||||
~
|
||||
"###);
|
||||
|
||||
// abandon
|
||||
|
|
|
@ -67,7 +67,9 @@ fn test_templater_branches() {
|
|||
let template = r#"commit_id.short() ++ " " ++ branches"#;
|
||||
let output = test_env.jj_cmd_success(&workspace_root, &["log", "-T", template]);
|
||||
insta::assert_snapshot!(output, @r###"
|
||||
◉ b1bb3766d584 branch3??
|
||||
◉ fed794e2ba44 branch3?? branch3@origin
|
||||
│ ◉ b1bb3766d584 branch3??
|
||||
├─╯
|
||||
│ ◉ 21c33875443e branch1*
|
||||
├─╯
|
||||
│ @ a5b4d15489cc branch2* new-branch
|
||||
|
|
|
@ -159,7 +159,9 @@ impl UserSettings {
|
|||
// For compatibility with old config files (<0.8.0)
|
||||
self.config
|
||||
.get_string("ui.default-revset")
|
||||
.unwrap_or_else(|_| "@ | ancestors((remote_branches() | tags()).., 2)".to_string())
|
||||
.unwrap_or_else(|_| {
|
||||
"@ | ancestors(immutable_heads().., 2) | heads(immutable_heads())".to_string()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue