2532 Commits

Author SHA1 Message Date
Yuya Nishihara
de462a6268 tests: add helper to snapshot command output and exit status all at once
It's easier to review insta snapshot diffs than scanning panic log containing
lengthy output. I think this will also help printf debugging.

test_global_opts.rs is migrated to new API as an example.
2025-02-20 05:22:32 +00:00
Yuya Nishihara
740d8a2b1b tests: add #[must_use] to helper functions that return value to be tested 2025-02-20 05:22:32 +00:00
George Christou
a5e079f543 ui: add color to help text 2025-02-20 01:22:02 +00:00
Stephan Hügel
fececd9174 cli: add mergiraf to the default merge tools config
Added as per Martin's suggestion: https://discord.com/channels/968932220549103686/969291218347524238/1341910959601614893
2025-02-20 01:14:39 +00:00
Baltasar Dinis
f233de5f69 cli: remove error hint for invalid remote names
Existing hint suggests using `jj git remote rename`, but that's not
applicable to `jj git clone`.

This commit removes that hint.
2025-02-19 07:14:00 +00:00
Yuya Nishihara
48b02226f5 cli: add "Hint: " prefix to conflict hints 2025-02-19 06:52:09 +00:00
Yuya Nishihara
a2a9a9935c cli: render "conflicts" message as warning
I don't have strong feeling, but this might be better because conflicts are
unusual?
2025-02-19 06:52:09 +00:00
Yuya Nishihara
1fa4e5a340 cli: status: do not label message lines as "conflict"
The "conflict" label is supposed to highlight "(conflict)" markers in commit
template. This patch just removes the label as we don't colorize the same
message in update_working_copy().
2025-02-19 06:52:09 +00:00
Yuya Nishihara
617e17fbe6 cli: use commit.has_conflict() extensively
Maybe it's slightly cheaper if there are no conflicts.
2025-02-19 06:52:09 +00:00
Yuya Nishihara
067e2ebaaa cli: status: reorder conflict message to match checkout stats
It seems also nice that the list of conflict files is displayed closer to the
resolution hints.
2025-02-19 06:52:09 +00:00
Yuya Nishihara
630036eeb0 tests: add [EOF] marker to command output when displaying
It's important to test that command output is (usually) terminated with newline,
but insta::assert_snapshot!() is lax about that.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
a54165230a tests: add CommandOutputString wrapper
I'm going to add "[EOF]" marker to test that command output is terminated by
newline char. This patch ensures that callers who expect a raw output string
would never be affected by any normalization passes.

Some common normalization functions are extracted as CommandOutputString
methods.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
0eddf5f3d6 tests: extract helper function that substitutes $TEST_ENV
I'm going to add wrapper type for normalized output, and this change makes
porting a bit easier.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
dd59cef1a2 cli: show executable name (with suffix) in help requested by "jj help"
On Windows, "jj help" and "jj --help" outputs were slightly different because
the binary name may have ".exe" suffix.
2025-02-19 02:31:59 +00:00
Ilya Grigoriev
55f130e085 streampager: stop uselessly reading the config file (fix a TODO)
https://github.com/facebook/sapling/pull/1011 is in, yay! 🎉

Follows up on https://github.com/jj-vcs/jj/pull/5415
and https://github.com/jj-vcs/jj/pull/5711
2025-02-18 19:01:30 +00:00
Baltasar Dinis
64ea8bee47 git: reject remotes with forward slashes
Although this behaviour is accepted by git, it's a degenerate case.
Especially because we implicitely rely on being able to parse out the
remote from the refname (i.e., `refs/remotes/<remote>/<branch>`).

Branches can have forward slashes, but if remotes can also have them,
parsing the refname becomes ambiguous, and a pain. Especially because it
would be totally legal to have a branch "c" on remote "a/b" and a branch
"b" on remote "a".

Fixes #5731
2025-02-18 07:10:01 +00:00
Baltasar Dinis
d6e7047142 cli: add hint to rename on remote management error 2025-02-18 07:10:01 +00:00
Antoine Martin
149702ef7d working_copy: adjust max-size hint to fit all configurations
In the case where the user has set `snapshot.auto-track` to something
other than `all()`, running `jj st` with a higher file size set just for
that command will not actually fix the user's problem, `jj file track`
needs to be called instead.
2025-02-17 20:52:18 +00:00
Martin von Zweigbergk
a6ca04e6cb cli_util: call Workspace::check_out() also for no-op updates
Some working-copy implementations, like the Google CitC one, may want
to update the VFS's state even if the tree didn't change. In
particular, when updating between two commits with the same tree but
different mainline base, we want to update the base commit. Otherwise
a future snapshot, which we do relative to the mainline commit, may
notice an incorrect set of changed file.
2025-02-17 18:59:56 +00:00
Martin von Zweigbergk
a89bcf23ea cli_util: make update_working_copy() return all-zero stats instead of None
When updating the working copy results in no changes, we currently
return `None` from `cli_util::update_working_copy()`. However, a no-op
update is still an update, so I think it makes more sense to always
return a `CheckoutStats`. We already skip printing stats if they're
zero.
2025-02-17 18:59:56 +00:00
Scott Taylor
00f87a2846 cli: untrack remote bookmarks on bookmark forget
Forgetting remote bookmarks can lead to surprising behavior since it
causes the repo state to become out-of-sync with the remote until the
next `jj git fetch`. Untracking the bookmarks should be a simpler and
more intuitive default behavior. The old behavior is still available
with the `--include-remotes` flag.

I also changed the displayed number of forgotten branches. Previously
when forgetting "bookmark", "bookmark@remote", and "bookmark@git" it
would display `Forgot 1 bookmarks`, but I think this would be confusing
with the new flag since the user might think that `--include-remotes`
didn't work. Now it shows separate `Forgot N local bookmarks` and
`Forgot M remote bookmarks` messages when applicable.
2025-02-17 17:02:58 +00:00
Yuya Nishihara
3cdaa5b1d8 cli: bookmark: remove hint about upsert behavior
It was added at 3c80e3453db6 "cli: branch: make "set" do upsert as before" in
order to remind behavior change.
2025-02-17 12:44:03 +00:00
Alain Leufroy
fa3254b4a7 templates: add hook points for users to customize the default operation id
Same as `format_short_change_id`.

We can't use `format_short_id` because `operation.id()` does not have `shortest()` method.
2025-02-17 09:08:51 +00:00
Martin von Zweigbergk
3bfbec1c83 undo: fix check for double-undo
The condition we were checking (which I suggested during review) is
very broken. It checks if the new view is equal to view before the
current operation, but that's supposed to always be true (except for
operation that update remote bookmarks). The reason the warning didn't
trigger all the time was that we did the comparison after calling
`merge_view()` but before calling `rebase_descendants()` (via
`tx.finish()`). The former only records commits as abandoned without
actually hiding them. However, because of [the hack][hack] in
`merge_view()` to make it work reasonably well in huge repos, every
undo operation at Google would print the warning.

This patch fixes the bug by checking if the to-be-undone operation is
an undo by comparing its view to its grandparent's view.

 [hack]: ec6f8278fd/lib/src/repo.rs (L1693-L1708)
2025-02-16 16:52:51 +00:00
Martin von Zweigbergk
3470a48345 undo: demonstrate how double-undo warning isn't shown correctly
Will be fixed in the next patch.
2025-02-16 16:52:51 +00:00
maan2003
ec6f8278fd signing: allow specifying sign behavior 2025-02-16 05:56:52 +00:00
Evan Mesterhazy
a4b064ea8d cli split: Move bookmarks to the first commit instead of the second
After even more discussion on Discord, we decided to use the new bookmark
behavior immediately and only print a warning during `jj split` if the user has
opted out of the new behavior using the `split.legacy-bookmark-behavior` config
setting.

The reasoning is that if the behavior change breaks someone's workflow or is
very disruptive, they are likely to check the changelog and learn about the
config option. For users that are not adversely impacted, printing a warning
that can only be silenced by changing their config is also disruptive.

#3419
2025-02-16 04:02:24 +00:00
Yuya Nishihara
4ec22dde38 templater: port annotation line content to template
I originally thought we would have to add BString template type first, but we
can use opaque Template type instead.
2025-02-15 11:07:17 +00:00
Yuya Nishihara
6f51696600 templater: use property.map() to apply infallible transformation
Also renamed data to line as the type name was changed to AnnotationLine.
2025-02-15 11:07:17 +00:00
Bryce Berger
3bc111e60e annotate: make AnnotationLine template type
Allows:
* self.commit()
* self.line_number()
* self.first_line_in_hunk()

Certain pagers (like `delta`), when used for `git blame`, only show the
commit information for the first line in a hunk. This would be a nice
addition to `jj file annotate`.

`jj file annotate` already uses a template to control the rendering of
commit information --- `templates.annotate_commit_summary`. Instead of
a custom CLI flag, the tools necessary to do this should be available in
the template language.

If `1 % 2` or `1.is_even()` was available in the template language, this
would also allow alternating colors (using `raw_escape_sequence`).

Example:

```toml
[templates]
# only show commit info for the first line of each hunk
annotate_commit_summary = '''
if(first_line_in_hunk,
  show_commit_info(commit),
  pad_end(20, " "),
)
'''
```
2025-02-15 02:34:38 +00:00
Martin von Zweigbergk
77fb50c8cd completion: mark git remote arguments as URL instead of path
Fixes #5704.
2025-02-15 01:59:16 +00:00
Bryce Berger
e4ad7b6c0f fix: add simple debugging logs
There's currently no way to tell what `jj fix` is doing. This adds some
traces such that `jj fix --debug` will at least tell you what's being
run and what it's exit code is, similar to other subprocessing code.
2025-02-15 01:13:17 +00:00
Philip Metzger
4a47a4fc1d commit: Add commit.is_hidden(repo)
Also simplify the `hidden()` revset with it.
2025-02-14 16:24:01 +00:00
Martin von Zweigbergk
5e896b22fe repo: make commit visible when pointing bookmark to it
This was discussed in the Discord a while ago, and this is the logical and consistent
conclusion. Implementing it as such makes it consistent with both `jj edit` and `jj new`
which make hidden commits such as predecessors visible.

This actually was Martins work, I just added the tests.

Co-Authored-by: martinvonz <martinvonz@google.com>
2025-02-14 16:24:01 +00:00
Benjamin Tan
e021036740 cli: backout: add templates.backout_description configuration
Closes #5676.
2025-02-14 07:56:40 +00:00
Josh Steadmon
23691a636c config-schema: validate default configs in tests with taplo
Set up tests using `taplo check --schema` to validate the default configs.
Install taplo in GitHub CI and in the Nix flake.

Fixes #5670.
2025-02-14 04:17:37 +00:00
Evan Mesterhazy
37992412b6 cli split: Recommend jj config set --user instead of --repo in deprecation warning
It only occurred to me after I rebuilt jj and actually had to run the command
that we should probably recommend a change to the user config instead of the
repo config.

#3419
2025-02-14 01:41:41 +00:00
Yuya Nishihara
381bb8a869 tests: create parent directory of .git link file by caller
It seems a bit safer to set up the working directory by caller who knows the
test environment directory exists.
2025-02-14 01:14:39 +00:00
Yuya Nishihara
d5493e6b10 tests: inline create_gitlink() option to caller
Since we don't set up Git worktree properly, it's odd that init_git_repo() has
a option to create a workspace at the specified path.
2025-02-14 01:14:39 +00:00
Yuya Nishihara
0d2becbac3 templater: add stringify(x) function to call string methods on template
It's also useful to remove color labels from the inner template.
2025-02-14 00:54:03 +00:00
Evan Mesterhazy
d5d21643d5 cli split: Add a config option controlling how bookmarks move during splits
Currently, `jj split` moves bookmarks from the target revision to the second
revision created by the split. Since the first revision inherits the change id
of the target revision, moving the bookmarks to the first revision is less
surprising (i.e. the bookmarks stay with the change id). This no-implicit-move
behavior also aligns with how `jj abandon` drops bookmarks instead of moving
them to the parent revision.

Two releases from now, `jj split` will no longer move bookmarks to the second
revision created by the split. Instead, local bookmarks associated with the
target revision will move to the first revision created by the split (which
inherits the target revision's change id). You can opt out of this change by
setting `split.legacy-bookmark-behavior = true`, but this will likely be
removed in a future release. You can also try the new behavior now by setting
`split.legacy-bookmark-behavior = false`.

Users who have not opted into the new behavior via the config setting will see
a warning when they run `jj split` informing them about the change. The default
behavior be changed in the future.

The `jj split` tests for bookmarks are updated to run in all three configurations:

- Config setting enabled
- Config setting disabled
- Config setting unset


#3419
2025-02-13 21:45:56 +00:00
Evan Mesterhazy
b90e5af51c json schema: Fix bad indentation for jj fix settings
The fix settings weren't indented consistent with the rest of the settings,
causing them to appear in the redacted snapshot in the test_util_config_schema
test.
2025-02-13 02:37:19 +00:00
hkalbasi
272955f4fe templater: add .escape_json method to string 2025-02-12 22:17:30 +00:00
Ilya Grigoriev
e83b328f71 ui.rs: style, fixup to 8aa2916 2025-02-12 21:25:37 +00:00
Josh Steadmon
69050f31f4 config-schema: expand options for ui.editor, ui.diff.tool, and ui.pager
In addition to a single string, the `ui.editor` and `ui.diff.tool` options also
allow arrays of strings. `ui.pager` allows arrays of strings as well as a nested
table describing both the command and the environment.

Update config-schema.json to allow all of these types of values.

Fixes #5617
2025-02-12 20:43:17 +00:00
Evan Mesterhazy
b2e2c79088 cli split: Move bookmark testing to a separate test
We are planning to add a config option that controls how bookmarks and change
ids move during `jj split` based on feedback in https://github.com/jj-vcs/jj/pull/5618.
I think the tests will be more readable after the config option is added if we
move the bookmark testing to its own test.

#3419
2025-02-12 19:45:37 +00:00
Baltasar Dinis
9ca6d179b2 cli/tests: port test_gitignore to gitoxide 2025-02-12 17:06:59 +00:00
Baltasar Dinis
6746942a06 cli/tests: port test_git_init to gitoxide
cargo-insta was re-run.
This is due to centralizing git interaction code to use a particular
different signature, which changes the commit hashes
2025-02-12 17:06:59 +00:00
Baltasar Dinis
18cd4d3010 cli/tests: add more gitoxide helpers
These are helpers for:
 - gitlinks
 - removing config values
 - symbolic references
 - status
 - index management
2025-02-12 17:06:59 +00:00
Ilya Grigoriev
a3647a6796 json schema: update some defaults to their modern values 2025-02-11 23:25:00 +00:00