2692 Commits

Author SHA1 Message Date
Yuya Nishihara
1194b94e51 templater: inline old impl_core_wrap_property_fns!() macro
There aren't many users of this macro, and the set of Template-like types
wouldn't grow.
2025-05-10 10:04:30 +00:00
Yuya Nishihara
f5c36d5420 templater: replace remainders of P::wrap_<type>(), remove old wrap_<type> fns 2025-05-10 10:04:30 +00:00
Yuya Nishihara
098f7d3bee templater: annotate some property output types
As I'm going to remove P::wrap_<type>(), these types will no longer be inferred.
2025-05-10 10:04:30 +00:00
Yuya Nishihara
cd9a3fb45f templater: use WrapTemplateProperty trait in list helpers 2025-05-10 01:52:56 +00:00
Yuya Nishihara
f221a751fc templater: move wrap_list() to callers of build_filter_operation()
This will help annotate the output property type. build_map_operation() is also
updated for consistency.
2025-05-10 01:52:56 +00:00
Yuya Nishihara
a084561528 templater: use WrapTemplateProperty trait bound at parsing functions
All parsed template types can be deduced, but I've inserted type annotations
where the type is inferred only by template.format() call.
2025-05-10 01:52:56 +00:00
Yuya Nishihara
ae22633247 templater: introduce trait for wrapping BoxedTemplateProperty<O> types
Old P::wrap_<type>() functions will be removed, and the wrap_<type>() callbacks
will be replaced with L::Property: WrapTempalteProperty<C> trait bounds. We
could instead use the std From trait, but my feeling is that we would be better
off using less-generic abstraction. It's unlikely that external callers would
have to use this trait.

This will help define List<T> template methods as table of fn(..)s. I think the
parsing/building API will look slightly nicer.
2025-05-10 01:52:56 +00:00
Yuya Nishihara
5fc347cad9 templater: in tests, use custom context type instead of ()
I'm going to add generic wrap(BoxedTemplateProperty<T>) trait, which means a
conversion from T should be uniquely defined. Even though we won't add the ()
template type, it's better to not reserve () for tests.
2025-05-10 01:52:56 +00:00
Yuya Nishihara
cb2944e287 rewrite: pack move_commits() parameters into struct for clarity 2025-05-10 01:52:48 +00:00
Yuya Nishihara
a9b153c2e7 rewrite: specify move target by Vec<CommitId> consistently 2025-05-10 01:52:48 +00:00
Yuya Nishihara
7aa60cb12e rewrite: use &[CommitId] consistently as move_commits() destination arguments 2025-05-10 01:52:48 +00:00
Winter
bece25ccc7 cli: diffedit: remove confusing/redundant documentation
The former wording of "With the `-r` option, which is the default" is
confusing, and made redundant by the clarifications within the
option-level documentation.
2025-05-09 05:00:02 +00:00
Winter
dddb4045fe cli: diff: document default arguments more precisely
The former wording of "[w]ith the `-r` option, which is the default..." is
a bit confusing. This change brings `jj diff`'s documentation more in
line with the other commands with similar semantics, such as `jj rebase`.
2025-05-09 05:00:02 +00:00
Yuya Nishihara
7fe4878d3e tests: update short commit id prefix after acd824269f1d 2025-05-09 02:47:53 +00:00
Yuya Nishihara
79fb219159 files: make DiffLineIterator omit blank right line following matching+left
I was wondering whether this is presentation issue or not, and I think it is a
matter of DiffLineIterator. For matching hunks, DiffLineIterator flushes the
current_line buffer and bumps the line numbers for the next line. This should
guarantee that there are no blank DiffLine to be queued. However, for different
hunks, only the left line number can be bumped in the first loop, so there may
be an empty-looking hunk having the same right line number.

Closes #6471
2025-05-09 00:49:10 +00:00
Yuya Nishihara
39295238ac tests: demonstrate redundant right blank lines in color-words diffs 2025-05-09 00:49:10 +00:00
Martin von Zweigbergk
8ee0bd45c7 status: update severely stale command description
The command has displayed all parents and the diff summary from the
merged parents since 48c44344bfb3 (2022-12-04) but it still says that
it only cares about the first commit. This patch finally fixes that.
2025-05-09 00:48:55 +00:00
Martin von Zweigbergk
acd824269f git: write change-id header by default
We haven't had any reports of problems from people who opted in. Since
it's early in the release cycle now, let's now test it on everyone who
builds from head, so we get almost a month of testing from those
people before it's enabled by default in a released version.

This impacts lots of test cases because the change-id header is added
to the Git commit. Most are uninteresting. `test_git_fetch` now sees
some divergent changes where it used to see only divergent bookmarks,
which makes sense.
2025-05-08 23:05:38 +00:00
Gaëtan Lehmann
b31c4158cc split: add the --message option
to set the message on the first commit, where the selected
changes are going. The commit with the remaining changes
keeps the original description.
With this option it becomes possible to use split in a fully
non-interactive way, in combination with the filset feature.
It also makes jj split more consistent with other commands
like squash, commit or new.
2025-05-07 21:35:55 +00:00
Austin Seipp
72b342782a cli: suppress a warning when building without git
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-05-07 20:27:33 +00:00
Emily
4f6e79a22a git: remove unused parameter from GitFetch::get_default_branch 2025-05-07 19:29:20 +00:00
Emily
860a787958 git: remove GitFetchPrepareError 2025-05-07 19:29:20 +00:00
Emily
1f1440d334 tests: rename test_git_clone_with_depth{_subprocess =>} 2025-05-07 19:29:20 +00:00
Emily
adcc1de466 tests: remove obsolete insta::allow_duplicates! blocks 2025-05-07 19:29:20 +00:00
Emily
d2a8160a7a tests: remove obsolete git2 branches 2025-05-07 19:29:20 +00:00
Emily
2fec09ac60 tests: remove obsolete helpers 2025-05-07 19:29:20 +00:00
Emily
e942744f84 tests: deparameterize Git remote tests 2025-05-07 19:29:20 +00:00
Emily
7bcc5cca8f git: remove git2 feature 2025-05-07 19:29:20 +00:00
Emily
f3de3858ef git: remove git.subprocess setting 2025-05-07 19:29:20 +00:00
Daniel Luz
87f6db0a70 completion: revset expression completer 2025-05-05 02:54:51 +00:00
Yuya Nishihara
8936a7bc4b templater: unify property conversion traits
We could define separate traits for conversion "from" and "to", but there aren't
many users who benefit from precise trait bounds.
2025-05-05 01:16:41 +00:00
Yuya Nishihara
780f9e547d templater: call property wrap_() functions directly, delete old forwarding fns
This patch replaces single-char L type aliases with P, and renames the L aliases
where that makes sense. Many of the P aliases will be removed later by
introducing generic wrap<T>() trait.
2025-05-05 01:16:41 +00:00
Yuya Nishihara
b611c313aa templater: move non-core wrap_*() functions to property types, leverage macro
Since the return type is now Self, we can reuse impl_wrap_property_fns!() macro
for non-core types.
2025-05-05 01:16:41 +00:00
Yuya Nishihara
7643364a76 templater: move core wrap_*() functions to property wrapper type
I think this was remainder of the old design where wrap_*() functions took
&TemplateLanguage as self argument. Since the wrapper type implements accessor
functions like .try_into_boolean(), it makes sense that the same type implements
::wrap_boolean(), etc.

These .wrap_<T>() functions will become generic over T.
2025-05-05 01:16:41 +00:00
Yuya Nishihara
577a484d1d templater: remove unneeded trait bound from build_lambda_expression()
This function just passes P down to the build_body() callback transparently.
2025-05-05 01:16:41 +00:00
Martin von Zweigbergk
103d05149d cli: add "$schema" line when creating new config file
It seems like a small usability improvement if users don't need to
enter the "$schema" link manually when they create a new config file.

This doesn't help existing users.
2025-05-04 17:14:10 +00:00
Ilya Grigoriev
4f3d890bee docs cli reference: update and pin clap-markdown, include aliases in reference
clap-markdown doesn't follow semver, so I pinned the version exactly.
2025-05-03 00:35:12 +00:00
Nicole Patricia Mazzuca
b568bb67f0 config: deprecate macOS legacy platform configs 2025-05-02 20:05:24 +00:00
Nicole Patricia Mazzuca
6f6496ba83 config: default to XDG config files on macOS
Support existing users with the "legacy" config directory, as well.
This will be deprecated in a latter commit.
2025-05-02 20:05:24 +00:00
Nicole Patricia Mazzuca
f9966a644b config: switch to etcetera from dirs 2025-05-02 20:05:24 +00:00
Nicole Patricia Mazzuca
19f997a466 config: change how config paths are represented
This change, from an enum to a struct, is a more accurate representation
of the actual way that a ConfigPath works; additionally, it lets us add
different information without modifying every single enumeration field.
2025-05-02 20:05:24 +00:00
Steve Fink
0eceed9832 restore, diffedit: do not output "Created ..." message, which dates back to before we couldn't lookup by change id. 2025-05-01 21:11:31 +00:00
Yuya Nishihara
1b300fefa2 templater: add type alias for Box<dyn TemplateProperty<..>>
It's verbose to type.
2025-05-01 00:33:59 +00:00
Yuya Nishihara
b96924d17f templater: convert property to trait object by caller
I'm trying to refactor property wrapping functions, and noticed that it's odd
that .wrap_<property>() does boxing internally whereas .wrap_template() doesn't.

Also, it sometimes makes sense to turn property into trait object earlier. For
example, we can deduplicate L::wrap_boolean() in build_binary_operation().
2025-05-01 00:33:59 +00:00
Yuya Nishihara
96b633a091 templater: add property.into_dyn() helper
I'm going to move Box<dyn _> conversion to callers, so there will be more places
to use this helper.
2025-05-01 00:33:59 +00:00
Yuya Nishihara
533fb5e4bb generic_templater: remove unneeded lifetime bounds
Perhaps, these bounds were needed because the context type were compiled into
the template object before.
2025-05-01 00:33:59 +00:00
Théo Daron
3ab9e098d7 cli config edit: Rollback to previous config when invalid TOML is saved 2025-04-29 16:26:11 +00:00
Jonas Greitemann
928984019f completion: fix completion of arguments for aliases/default-command in bash and zsh
This also adds a test case for the completion of arguments following
multi-argument aliases, to cover the bug reported in issue #5377.

The default command is like a special kind of alias, one which is
expanded from zero tokens. Consequently, it also triggers the bug
#5377 on bash/zsh, even if the `default-command` is just a single token.

The fix is along the lines sketched out by the "TODO" comment. Bash and
Zsh don't behave identical, so the padding ([""]) still needs to be
applied (and removed) conditionally in a disciplined manner.
2025-04-29 14:38:25 +00:00
Jonas Greitemann
eaaaf058a8 completion tests: parameterize test case over different shells
The completion mechanism works differently in different shells:

For example, when the command line `jj aaa bb ccc` is completed at the
end of the `bb` token, bash and zsh pass the completer the whole line
`-- jj aaa bb ccc` and an index of 2 which refers to the `bb` token;
they are then expected to complete `bb`. Meanwhile, fish and Powershell
only pass the command up to the completion point, so `-- jj aaa bb`;
the completer is always expected to complete the last token. In all
cases, the shell ultimately decides what to do with the completions,
e.g. to complete up to a common prefix (bash), to show an interactive
picker (zsh, fish), or to insert the completion if it is the only one
(all shells). Remaining tokens (`ccc`) are also always appended by the
shell and not part of the completion.

While this is mostly handled by the clap_complete crate, we do expand
aliases and present clap_complete with a fake view of the real command
line, thereby reaching into its internals by wrapping the interface
between the completion shell script that is provided by clap_complete
and its Rust code in `CommandEnv::try_complete()`. If we get this wrong,
completion might yield unexpected results, so it is worth testing
completion for both flavors of shells whenever aliases are potentially
in the mix.

To avoid redundancy, the shell-specific invocation of `jj` is factored
into a `complete_at()` function of the test fixture. The `test-case`
crate is then used to instantiate each test case for different values of
clap_complete's `Shell` enum.

filter

bash/zsh specific behavior

move impl
2025-04-29 14:38:25 +00:00
Gaëtan Lehmann
2c4a0328f9 templates: add self.trailers().contains_key(key)
as a simpler and more readable alternative to

    self.trailers().filter(|t| t.key() == "Change-Id")
2025-04-29 06:36:12 +00:00