just playing with tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cli `fix`: change default from `-s @` to `-s 'reachable(@, mutable())'`

Most of the value of `jj fix` over a shell script is in formatting commits
other than `@`. `@::` often doesn't contain those other commits, so `-s @` is a
bad default.

We could get the same effect from `-s 'mutable() & ::@'`, but `reachable()` is
a bit more explicit and simple to read.

We could also base this on excluding `trunk()`, but that just seems like an
indirection for `mutable()` that might ignore the user's intent if they have
configured part of trunk to be mutable.

+41 -19
+3
CHANGELOG.md
··· 16 16 * Dropped support for automatic upgrade of repo formats used by versions before 17 17 0.12.0. 18 18 19 + * `jj fix` now defaults to the broader revset `-s reachable(@, mutable())` 20 + instead of `-s @`. 21 + 19 22 ### Deprecations 20 23 21 24 ### New features
+1 -1
cli/src/commands/fix.rs
··· 67 67 pub(crate) struct FixArgs { 68 68 /// Fix files in the specified revision(s) and their descendants. If no 69 69 /// revisions are specified, this defaults to the `revsets.fix` setting, or 70 - /// `@` if it is not set. 70 + /// `reachable(@, mutable())` if it is not set. 71 71 #[arg(long, short)] 72 72 source: Vec<RevisionArg>, 73 73 /// Fix only these paths
+1 -1
cli/src/config-schema.json
··· 349 349 "fix": { 350 350 "type": "string", 351 351 "description": "Default set of revisions to fix when no explicit revset is given for jj fix", 352 - "default": "@" 352 + "default": "reachable(@, mutable())" 353 353 }, 354 354 "log": { 355 355 "type": "string",
+1 -1
cli/src/config/revsets.toml
··· 2 2 # adding/updating any of these aliases 3 3 4 4 [revsets] 5 - fix = "@" 5 + fix = "reachable(@, mutable())" 6 6 log = "@ | ancestors(immutable_heads().., 2) | trunk()" 7 7 8 8 [revset-aliases]
+1 -1
cli/tests/cli-reference@.md.snap
··· 798 798 799 799 ###### **Options:** 800 800 801 - * `-s`, `--source <SOURCE>` — Fix files in the specified revision(s) and their descendants. If no revisions are specified, this defaults to the `revsets.fix` setting, or `@` if it is not set 801 + * `-s`, `--source <SOURCE>` — Fix files in the specified revision(s) and their descendants. If no revisions are specified, this defaults to the `revsets.fix` setting, or `reachable(@, mutable())` if it is not set 802 802 803 803 804 804
+34 -15
cli/tests/test_fix_command.rs
··· 142 142 #[test] 143 143 fn test_default_revset() { 144 144 let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]); 145 + std::fs::write(repo_path.join("file"), "trunk1").unwrap(); 146 + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "trunk1"]); 147 + test_env.jj_cmd_ok(&repo_path, &["new"]); 148 + std::fs::write(repo_path.join("file"), "trunk2").unwrap(); 149 + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "trunk2"]); 150 + test_env.jj_cmd_ok(&repo_path, &["new", "trunk1"]); 145 151 std::fs::write(repo_path.join("file"), "foo").unwrap(); 146 152 test_env.jj_cmd_ok(&repo_path, &["branch", "create", "foo"]); 153 + test_env.jj_cmd_ok(&repo_path, &["new", "trunk1"]); 154 + std::fs::write(repo_path.join("file"), "bar1").unwrap(); 155 + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "bar1"]); 147 156 test_env.jj_cmd_ok(&repo_path, &["new"]); 148 - std::fs::write(repo_path.join("file"), "bar").unwrap(); 149 - test_env.jj_cmd_ok(&repo_path, &["branch", "create", "bar"]); 150 - test_env.jj_cmd_ok(&repo_path, &["new", "foo"]); 151 - std::fs::write(repo_path.join("file"), "baz").unwrap(); 152 - test_env.jj_cmd_ok(&repo_path, &["branch", "create", "baz"]); 157 + std::fs::write(repo_path.join("file"), "bar2").unwrap(); 158 + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "bar2"]); 159 + test_env.jj_cmd_ok(&repo_path, &["new"]); 160 + std::fs::write(repo_path.join("file"), "bar3").unwrap(); 161 + test_env.jj_cmd_ok(&repo_path, &["branch", "create", "bar3"]); 162 + test_env.jj_cmd_ok(&repo_path, &["edit", "bar2"]); 153 163 154 - // With no args and no revset configuration, we fix `@`. 164 + // With no args and no revset configuration, we fix `reachable(@, mutable())`, 165 + // which includes bar{1,2,3} and excludes trunk{1,2} (which is immutable) and 166 + // foo (which is mutable but not reachable). 167 + test_env.add_config(r#"revset-aliases."immutable_heads()" = "trunk2""#); 155 168 let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["fix"]); 156 169 insta::assert_snapshot!(stdout, @""); 157 170 insta::assert_snapshot!(stderr, @r###" 158 - Fixed 1 commits of 1 checked. 159 - Working copy now at: mzvwutvl 5205c5f1 baz | (no description set) 160 - Parent commit : qpvuntsm 34af74d0 foo | (no description set) 171 + Fixed 3 commits of 3 checked. 172 + Working copy now at: yostqsxw 0bd830d2 bar2 | (no description set) 173 + Parent commit : yqosqzyt 4747dd17 bar1 | (no description set) 161 174 Added 0 files, modified 1 files, removed 0 files 162 175 "###); 176 + let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "trunk1"]); 177 + insta::assert_snapshot!(content, @"trunk1"); 178 + let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "trunk2"]); 179 + insta::assert_snapshot!(content, @"trunk2"); 163 180 let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "foo"]); 164 181 insta::assert_snapshot!(content, @"foo"); 165 - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "bar"]); 166 - insta::assert_snapshot!(content, @"bar"); 167 - let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "baz"]); 168 - insta::assert_snapshot!(content, @"BAZ"); 182 + let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "bar1"]); 183 + insta::assert_snapshot!(content, @"BAR1"); 184 + let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "bar2"]); 185 + insta::assert_snapshot!(content, @"BAR2"); 186 + let content = test_env.jj_cmd_success(&repo_path, &["print", "file", "-r", "bar3"]); 187 + insta::assert_snapshot!(content, @"BAR3"); 169 188 } 170 189 171 190 #[test] ··· 178 197 std::fs::write(repo_path.join("file"), "bar").unwrap(); 179 198 test_env.jj_cmd_ok(&repo_path, &["branch", "create", "bar"]); 180 199 181 - // Check out a different commit so that the schema default `@` would behave 182 - // differently from our customized default. 200 + // Check out a different commit so that the schema default `reachable(@, 201 + // mutable())` would behave differently from our customized default. 183 202 test_env.jj_cmd_ok(&repo_path, &["new", "-r", "foo"]); 184 203 test_env.add_config(r#"revsets.fix = "bar""#); 185 204