ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

2211 commits

Author SHA1 Message Date
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
Waleed Khan
af55d17a25 git_backend: propagate various errors
I needed this in the course of debugging an error. Before this commit, the error looked like this:

```
Error: Unexpected error from backend: Object not found
```

After this commit, it looks like this:

```
Error: Unexpected error from backend: Object with CommitId 8f59646bc9bb6bb44b5624f1248f4a708f37003c not found: object not found - no match for id (8f59646bc9bb6bb44b5624f1248f4a708f37003c); class=Odb (9); code=NotFound (-3)
```
2023-01-02 12:28:51 -06:00
Waleed Khan
9f8d78c57d working_copy: propagate error source for SourceNotFound errors
Might as well while I'm here.
2023-01-02 12:28:51 -06:00
Waleed Khan
e299963fae backend: remove PartialEq/Eq implementations
As soon as we start tracking the `#[source]` for error variants, we won't be able to rely on the presence of `Eq` implementations.
2023-01-02 12:28:51 -06:00
Waleed Khan
67cb20611e cli_util: fix typo in From<BackendError>
This error message was confusing because I thought the error was coming directly from the store, not via the backend.
2023-01-02 12:28:51 -06:00
Waleed Khan
456be4cc73 backend: create BackendError::InvalidHashLength
Strictly speaking, we could rely on e.g. `git2::Oid::from_str` to produce an error, but I figure that having an explicit error for a mismatching hash length might demystify some error condition in the future, since commit IDs and change IDs and potentially other backends' IDs may have different lengths, so this could flag a mismatch earlier/more obviously.
2023-01-02 12:28:51 -06:00
Waleed Khan
7f8a196ab2 backend: create ObjectId trait
This lets us operate over various kinds of objects polymorphically (e.g. call `.hex()` on any kind of object hash).
2023-01-02 12:28:51 -06:00
Ilya Grigoriev
9974d67da2 Test jj log for divergent commits
It turns out we did not have tests that would catch `jj log` failing
to mark divergent commits.
2023-01-02 00:08:55 -08:00
Ilya Grigoriev
265fa7f7c7 cargo +nightly clippy --fix --workspace 2023-01-02 00:08:55 -08:00
Yuya Nishihara
6586a756c1 cli: inline create_ui(), use ? to handle config error 2023-01-02 14:14:50 +09:00
Yuya Nishihara
1b45c5fe8e cli: use ui.reset() to process --config-toml arguments
This should also fix handling of --config-toml 'colors...'. Before, the color
table wouldn't be updated without mode change.
2023-01-02 14:14:50 +09:00
Yuya Nishihara
fa68a21bd1 cli: create default ui, then reconfigure with loaded user settings
This function will probably be used to apply settings loaded from
.jj/repo/config.toml.
2023-01-02 14:14:50 +09:00
Yuya Nishihara
da95ae65be cli: extract Ui::new() that creates ui with default config
Since ui object is needed to report read_config() error, it makes sense to
create ui first without fallible user configuration. Ui::for_terminal() will
be replaced with this function and ui.reset(read_config()?).

Default::default() is also added to silence clippy. If we prefer, Ui::new()
can be replaced with Ui::default().
2023-01-02 14:14:50 +09:00
Philip Metzger
48356817ba [Docs]: Add some more documentation on how to work with github.
The document roughly describes some workflows, which help new users
to start with github.
2023-01-01 16:36:09 +01:00
Martin von Zweigbergk
d6fcf4c7b2 repo: load correct OpHeadsStore depending on repo's type
We forgot to actually call `StoreFactories::load_op_heads_store()` to
load the right type of `OpHeadsStore` depending on the contents of
`.jj/repo/op_heads/type`. That shouldn't have any effect yet since we
only have one type so far, and there are no out-of-tree types yet
either (clearly, since they would not work).
2022-12-31 01:22:29 -08:00
Waleed Khan
cf8c2b0717 cli_util: fix typo 2022-12-31 02:57:26 -06:00
dependabot[bot]
f05c6fc6fd cargo: bump once_cell from 1.16.0 to 1.17.0
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.16.0 to 1.17.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.16.0...v1.17.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-30 09:38:30 -08:00
dependabot[bot]
d7c335d6b2 cargo: bump predicates from 2.1.4 to 2.1.5
Bumps [predicates](https://github.com/assert-rs/predicates-rs) from 2.1.4 to 2.1.5.
- [Release notes](https://github.com/assert-rs/predicates-rs/releases)
- [Changelog](https://github.com/assert-rs/predicates-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/assert-rs/predicates-rs/compare/v2.1.4...v2.1.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-30 09:38:14 -08:00
Augie Fackler
f64d8f45ae Commands: Alias commit to ci for cvs/mercurial/svn compatability
As far as I can tell it won't hurt anyone to have this alias exist, but will
help those of us with old muscle memory.
2022-12-30 09:26:55 -05:00
Yuya Nishihara
b3fa9e5b6c matchers: rename Dirs to RepoPathTree as it no longer represents directory 2022-12-30 14:15:27 +09:00
Yuya Nishihara
4f875ff9b7 matchers: leverage Dirs tree to test prefix matches, no .to_vec() in loop
No special case for prefix.is_root() is needed since the root entry can
also be flagged as a file.
2022-12-30 14:15:27 +09:00
Yuya Nishihara
996ac22921 matchers: simplify FilesMatcher::new() to take slice of paths 2022-12-30 14:15:27 +09:00