Commit graph

2232 commits

Author SHA1 Message Date
Yuya Nishihara
6addfb0198 cli: migrate --config-toml processing, make UserSettings immutable
It's unclear whether parse_args() or its caller should update LayeredConfigs.
--config-toml is processed by callee to apply --color early. -R/--repository
will be processed by caller since it will instantiate WorkspaceLoader.
Maybe --config-toml can be removed from EarlyArgs, and handle_early_args()
just updates ui state based on --color argument?
2023-01-07 11:33:12 +09:00
Yuya Nishihara
39d5ce97ad cli: initialize ui with merged config containing defaults and envs
Since CliRunner knows both defaults and envs, it makes sense to feed them
to initialize ui.
2023-01-07 11:33:12 +09:00
Yuya Nishihara
3557622b09 cli: introduce struct that stores unmerged configs
Thinking of config precedence, we'll probably need to store "base" (default +
env_base + user) config and "override" (env_overrides + --config-toml) config
separately to support repo config. Suppose env_overrides() is a temporary
value, it's better to override any file-derived values with $JJ_ env.
2023-01-07 11:33:12 +09:00
Yuya Nishihara
47e2e4d220 cli: extract function that reads user config without merging
The next commit will add a struct that keeps umerged configs, which will be
used to insert repo config between user and override configs.
2023-01-07 11:33:12 +09:00
Yuya Nishihara
b3c792f7bf cli: resolve command alias without using UserSettings, use config::Config
For the same reason as the previous commit. -R/--repository can't be parsed
until the real command name gets available.
2023-01-07 11:33:12 +09:00
Yuya Nishihara
d0d92a0e06 cli: initialize Ui without using UserSettings, use config::Config
UserSettings will be instantiated after both user and repo configs are
loaded. We might want to add a wrapper for CLI settings, but I have no idea
how that should be structured. Let's use bare config::Config until then.
2023-01-07 11:33:12 +09:00
Yuya Nishihara
3c99852ebd tests: add basic config precedence test 2023-01-07 11:33:12 +09:00
dependabot[bot]
0bc52d4386 cargo: bump glob from 0.3.0 to 0.3.1
Bumps [glob](https://github.com/rust-lang/glob) from 0.3.0 to 0.3.1.
- [Release notes](https://github.com/rust-lang/glob/releases)
- [Commits](https://github.com/rust-lang/glob/compare/0.3.0...0.3.1)

---
updated-dependencies:
- dependency-name: glob
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-06 07:53:02 -08:00
dependabot[bot]
f2cba66029 github: bump actions/upload-artifact from 3.1.1 to 3.1.2
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](83fd05a356...0b7f8abb15)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-06 07:52:03 -08:00
Ilya Grigoriev
621293d7c6 jj resolve --list: Add descriptions of conflict complexity
The descriptions focus on adds, not the deletions. The deletions are used
to compute the number of deleted files that must be sides of the conflict.
2023-01-05 10:59:14 -08:00
Ilya Grigoriev
1f39ffce01 Rename print_conflicted_{files=>paths} 2023-01-05 10:59:14 -08:00
dependabot[bot]
6a6724fd87 github: bump actions/checkout from 3.2.0 to 3.3.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](755da8c3cf...ac59398561)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-05 15:33:10 +00:00
David Barnett
6da1ecfba0 Add pkg-config to required Linux dependencies
Without it, cargo started erroring out for me after #970 saying it
couldn't find openssl without pkg-config being installed.
2023-01-05 08:01:34 -06:00
Ilya Grigoriev
5ecac4fc44 jj resolve: List remaining conflicts (if any) on success
This can be prevented by the new `--quiet` option.
2023-01-04 21:48:33 -08:00
Ilya Grigoriev
b8ba78b996 Extract resolve_list from cmd_resolve, tests, minor refactoring
This is all in preparation for follow-up commit, which will change
some of the new tests. The extracted function will be further expanded
later.
2023-01-04 21:48:33 -08:00
Yuya Nishihara
42a044b7c7 cli: move ui.settings() to CommandHelper, disown UserSettings from Ui
Still UserSettings is cloned to WorkspaceCommandHelper, but I think this is
slightly better since CommandHelper and WorkspaceCommandHelper are scoped
based on call stack. Perhaps, UserSettings can be shared by Arc or immutable
reference.
2023-01-05 14:33:10 +09:00
Yuya Nishihara
71102a7d4a cli: pass CommandHelper in to branch/rebase helper functions
This prepares for migration from ui.settings() to command.settings(). We could
instead add workspace_command.settings(), but I'm not sure which would be less
bad. Anyway, these functions live in command layer, so taking CommandHelper
makes sense.
2023-01-05 14:33:10 +09:00
Yuya Nishihara
d8d015613c cli: include pager command args in warning message
"No such file or directory" is useless without a command name.
2023-01-05 14:33:10 +09:00
Yuya Nishihara
cfac7468d8 cli: store resolved pager command in Ui
ui.settings() will be removed.
2023-01-05 14:33:10 +09:00
Yuya Nishihara
825d00e62a cli: pass UserSettings in to expand_args() and parse_args(), update in place
This is a temporary workaround. I think UserSettings can be constructed after
user, repo, and --config-toml values are all set. parse_args() will probably
return config::Config or its wrapper instead of mutating UserSettings.
2023-01-05 14:33:10 +09:00
Yuya Nishihara
d7911ff279 cli: move ui.cwd() to CommandHelper
I'm going to remove owned UserSettings from Ui so that UserSettings can be
instantiated after both user and repo configs are loaded. ui.cwd() belongs
to the same category (random environment stuff), and Ui doesn't depend on it,
so let's remove it first from Ui.

I'm not pretty sure if CommandHelper and WorkspaceCommandHelper should be
a permanent home for cwd and settings, but it works for now as CommandHelper
is immutable.
2023-01-05 14:33:10 +09:00
Yuya Nishihara
42fa8bc20a cli: pass UserSettings in to edit_description() instead of Ui
It might be better to proxy editor handling thorough Ui (to do some I/O
adjustment?), but right now, edit_description() doesn't need Ui.
2023-01-05 07:56:03 +09:00
Yuya Nishihara
69bfaf8b76 cli: pass UserSettings in to update_working_copy() explicitly 2023-01-05 07:56:03 +09:00
Yuya Nishihara
4b1008271b cli: pass UserSettings in to load_revset_aliases() explicitly 2023-01-05 07:56:03 +09:00
Yuya Nishihara
20bed8f80e cli: pass UserSettings in to merge_tools::get_*_from_settings() explicitly
editor_name_from_settings() needs &mut Ui to show hint, but we're lucky that
the caller has a clone of UserSettings. This is one reason I want to remove
ui.settings(). A function taking (&mut Ui, &UserSettings) sounds reasonable,
but we can't pass in (&mut ui, ui.settings()) to it.
2023-01-05 07:56:03 +09:00
Yuya Nishihara
7232dac7e9 cli: pass UserSettings in to diff_util::diff_formats_for*()
This and the subsequent patches prepare for the removal of ui.settings().
Ui will be a consumer of UserSettings (or config::Config) to make it clear
that Ui can be constructed before UserSettings is fully set up.
2023-01-05 07:56:03 +09:00
Yuya Nishihara
d99c299ee0 cli: set StoreFactories directly by CommandHelper::new() 2023-01-05 07:56:03 +09:00
Yuya Nishihara
f89f91a18b cli: instantiate CommandHelper by caller of parse_args()
parse_args() doesn't know all parameters needed to set up CommandHelper,
and we have to set StoreFactories later. That's okay for now, but I'm going
to add more parameters derived from CliRunner.
2023-01-05 07:56:03 +09:00
Yuya Nishihara
d48d080c4b cli: extract first half of parse_args() to new function
The next commit will move CommandHelper construction to the caller of
parse_args(). Without this change, parse_args() would have to return a tuple
of 3 elements, which seemed a bit too much.
2023-01-05 07:56:03 +09:00
Yuya Nishihara
ca73e39ead cli: for ColorChoice, implement fmt::Display instead of ToString
And inline {choice}.
2023-01-05 07:56:03 +09:00
dependabot[bot]
46c5e354eb cargo: bump insta from 1.23.0 to 1.24.1
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.23.0 to 1.24.1.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.23.0...1.24.1)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-04 09:30:57 -08:00
Ilya Grigoriev
b293d72dfd Put timestamp config for tests into debug namespace 2023-01-03 23:02:46 -08:00
Ilya Grigoriev
30d98974bb Make change ids in tests repeatable
This will be needed to test functionality for showing shortest
unique prefix for commit and change ids. As a bonus, this also
allows us to test log output with change ids.

As another bonus, this will prevent occasional CI failures like
https://github.com/martinvonz/jj/actions/runs/3817554687/jobs/6493881468.
2023-01-03 23:02:46 -08:00
Ilya Grigoriev
44d443a63b Move the old new_change_id function next to the tests
In the following commit, we replace it everywhere else.
2023-01-03 23:02:46 -08:00
Ilya Grigoriev
bd234c13c5 Fix the RNG seed in tests 2023-01-03 23:02:46 -08:00
Ilya Grigoriev
89e268c9d9 Rearrange a few lines in TestEnvironment's jj_cmd.
Moves all the config that depends on the command
number next to each other.
2023-01-03 23:02:46 -08:00
Ilya Grigoriev
79aaf117ea Put an RNG in user settings with configurable seed
Some hijinx are utilized to make it possible to generate
random values using an immutable `&UserSettings` reference.
2023-01-03 23:02:46 -08:00
Ilya Grigoriev
e8b21c5ce0 Change with_toml_strings to incorporate_toml_string
It makes more sense for this function to change `self`.
2023-01-03 23:02:46 -08:00
Ilya Grigoriev
95637e252c Fix minor bug in UserSettings
The timestamp couldn't be set with `--config-toml 'user.timestamp=...'`.
2023-01-03 23:02:46 -08:00
Yuya Nishihara
6d8d495075 cli: port custom command dispatch to CliRunner
Box<dyn> isn't technically needed, but it simplifies the type signature. Type
alias is added to silence clippy warning.
2023-01-04 15:48:38 +09:00
Yuya Nishihara
e0690f9d66 cli: pass CommandHelper to dispatch function by reference
This allows us to chain custom dispatch functions. If CommandHelper were
moved or passed by mutable reference, weird thing could happen depending
on the call order.
2023-01-04 15:48:38 +09:00
Yuya Nishihara
0110814885 cli: integrate custom StoreFactories registration with CliRunner
.set_store_factories() could be invoked for any CliRunner<F> type, but
I don't care much about that since the type parameter F will be removed
soon.
2023-01-04 15:48:38 +09:00
Yuya Nishihara
f34f764b9f cli: migrate custom command augmentation and parse_args() to CliRunner
CommandHelper is passed by move because custom-backend/main.rs mutates it.
This will be addressed by the next commit.
2023-01-04 15:48:38 +09:00
Yuya Nishihara
9296ae6eb4 cli: add builder type that handles CLI initialization and teardown
parse_args() will probably become more involved to deal with --config-toml,
-R, and repository configs. This builder will hopefully allow us to move
things around without changing the high-level interface.
2023-01-04 15:48:38 +09:00
David Barnett
406be5e043 Add "jj debug config-schema" command to output JSON schema
Extends TOML/JSON schema changes from #966 to allow jj to output the
schema directly. Context in #879.
2023-01-03 22:02:25 -06:00
Martin von Zweigbergk
635f5a5cb8 build: don't use vendored OpenSSL by default
I added support for using a vendored OpenSSL in dbadbd68c0. That was
in order to get the musl binary to work. However, it shouldn't be
needed on most platforms, and we've had a few reports of issues caused
by it. Let's disable it by default and enable it specifically when
building the musl binary instead.
2023-01-03 18:57:38 -08:00
Yuya Nishihara
9763a4d689 cli: move --verbose handling to parse_args(), enable it in custom examples 2023-01-04 11:56:53 +09:00
Yuya Nishihara
dbcfb00d2c cli: extract thin wrapper for tracing initialization
I'm going to add a high-level abstraction to hide details of the CLI startup,
but a low-level wrapper like this would still be useful.
2023-01-04 11:56:53 +09:00
Ruben Slabbert
dc26d4db17 fix: update cargo install command in readme to specify jujutsu crate 2023-01-03 16:13:23 -08:00
David Barnett
01e656efbe Define config TOML/JSON schema
Can be used with tools like taplo-lsp to show hints & validation in
editors/IDEs. Won't apply automatically to config files until it's
submitted to schemastore.org, but in the meantime it can be used via a
schema directive
(https://taplo.tamasfe.dev/configuration/directives.html#the-schema-directive)
or other manual config mechanism.

Context in #879.
2023-01-02 20:26:28 -06:00