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

71 commits

Author SHA1 Message Date
Martin von Zweigbergk
0075174308 tests: move tests/ under cli/ so they're run again
Thanks to @ilyagr for noticing that they should be moved.
2023-08-05 06:18:59 +00:00
Ilya Grigoriev
44903ed603 cli status: rearrange sections
Puts the commit summary the working copy before the info about parent
commits, to match the output after most mutating commands.

Also puts the working copy diff before the commit summary, to keep it next to
the info about the working copy commit.
2023-08-02 12:14:04 -07:00
Ilya Grigoriev
d591b6776d cli templates: include change id and more in short commit description
Include change id as well as (empty) and (conflict) markers in short commit
description.

Unlike `jj log`,

* (conflict) is put in parentheses to distinguish it from the commit
description  when the output is not colored.

* the change id is placed right before the commit id to put it into a
predicteble place, even if the short commit description takes up more than one
line. The commit id can be important for commit descriptions in commands like
`abandon`.
2023-08-02 12:14:04 -07:00
Ilya Grigoriev
e667824ad9 cli templates: change default short id length from 12 to 8
This makes including the change id into the short
commit description in the following commit look less
noisy.
2023-08-02 12:14:04 -07:00
Ilya Grigoriev
315f698231 cli: New -changes-in argument to jj restore + docs
Also updates docstrings for `diffedit`, `abandon` in related ways. The changes
are a bit too intertwined to comfortable split into a separate commit.
2023-08-01 15:28:00 -07:00
Martin von Zweigbergk
aac5b7aa25 cargo: rename crates from jujutsu/jujutsu-lib to jj-cli/jj-lib
Almost everyone calls the project "jj", and there seeems to be
consensus that we should rename the crates. I originally wanted the
crates to be called `jj` and `jj-lib`, but `jj` was already
taken. `jj-cli` is probably at least as good for it anyway.

Once we've published a 0.8.0 under the new names, we'll release 0.7.1
versions under the old names with pointers to the new crates names.
2023-07-09 06:40:43 +02:00
Yuya Nishihara
868188c84e repo: handle empty .jj repo gracefully, include file path in error message 2023-07-06 20:48:46 +09:00
Yuya Nishihara
cf8a0466c4 backend: introduce error types specific to init/load phases
Errors that may occur while loading backend would vary per backends, and
it's unlikely that these errors could be mapped to BackendError variants
other than BackendError::Other. So let's extract Other(_) of that kind as
a separate type to clarify there would be no other error variants.

Perhaps, Backend/Error will be renamed to CommitBackend/Error or
CommitStore/Error?, whereas I think BackendInit/LoadError can be shared
among store factories.
2023-07-06 20:48:46 +09:00
Yuya Nishihara
5b78fe75b1 git_backend: propagate load() error to caller
#1794
2023-07-06 12:43:49 +09:00
Yuya Nishihara
d3c031b277 tests: add helper method to capture both stdout/stderr outputs
This pattern is common, and should have a shorthand so that we can easily
add warning messages.
2023-07-03 22:03:05 +09:00
Martin von Zweigbergk
35b19b1e28 cargo: upgrade clap from to 4.1.11 to 4.3.0
I changed `test_early_args` because the first line no longer has a
redundant color reset, so now we test the `Commands:` line instead,
which has actual color (well, bold+underline anyway).
2023-05-31 12:32:26 -07:00
Martin von Zweigbergk
9c91f8190d tracing: bump a few trace events from DEBUG to INFO
Now that we don't print INFO-level events by default, we can start
using that level.
2023-05-03 11:40:23 -07:00
Yuya Nishihara
feeacacb7b tests: rewrite default-command test to not depend on "show" template 2023-04-22 14:37:39 +09:00
Aaron Bull Schaefer
6c627fb30d cli: default to log when no subcommand is provided
This is a convenience optimization to improve the default user
experience, since `jj log` is a frequently run command. Accessing the
help information explicitly still follows normal CLI conventions, and
instructions are displayed appropriately if the user happens to make a
mistake. Discoverability should not be adversely harmed.

Note that this behavior mirrors what Sapling does [2], where `sl` will
display the smartlog by default.

[1] https://github.com/clap-rs/clap/issues/975
[2] https://sapling-scm.com/docs/overview/smartlog
2023-04-17 16:30:42 -07:00
Martin von Zweigbergk
4b5b497283 tests: use absolute timestamps in the operation log
The current use of `timestamp.ago()` in the default template makes the
tests depend on the current time, which they shouldn't.
2023-04-08 14:02:39 -07:00
Martin von Zweigbergk
ed0b23d009 cli: include commit id from build in version
This changes the version number reported by `jj version` from "0.7.0"
to something like
"0.7.0-24a512683bc921699575b6a953624b05c068d544a". The hash is added
if running in a jj repo or a git repo.
2023-04-07 17:33:44 -07:00
Ilya Grigoriev
0e2579ee6a Switch graph node to use for commit instead of
This follows up on 5c703aeb03.

The only reason for this change is that, subjectively, the result looks better to me. I'm not sure why, but I couldn't get used to the old symbol in spite of its seeming reasonableness. It felt really bold and heavy.

If people agree, we can wait until we need to update the screenshots for some other reason before merging this. Sorry I didn't figure this out while the discussion about the referenced commit was going on.

I'm not 100% certain how many fonts support each symbol. Please try it out and let me know if it doesn't work for you.

Compare after:

![image](https://user-images.githubusercontent.com/4123047/229251383-563b889d-7233-42e2-a3c5-bf9368a4d1fd.png)

and before:

![image](https://user-images.githubusercontent.com/4123047/229251695-7fd0ff2c-2832-4262-ade5-5120288cccdf.png)
2023-04-02 23:15:37 -07:00
Martin von Zweigbergk
5fe5991ca8 cli: on config error, point to documentation 2023-03-30 21:16:28 -07:00
Waleed Khan
4c629f3aa6 cli: add warrant to identity-not-configured message
The impact of not having configured one's name and email is not apparent from the warning message. Under the Toulmin model:

- Claim (implicit): You should configure your name and email.
- Grounds: Your name and email are not currently configured.
- Warrant (currently missing): Configuring your name and email will let you do...
2023-03-30 11:43:30 -07:00
Martin von Zweigbergk
8f1dc49039 cargo: upgrade to clap 4.1
This includes some changes to error messages. Also, the Zsh shell
completion script is now simpler to source.

Fixes #1393.
2023-03-17 22:44:29 -07:00
Martin von Zweigbergk
5c703aeb03 cli: replace o as graph node by when using unicode graph
@joyously found `o` confusing because it's a valid change id prefix. I
don't have much preference, but `●` seems fine. The "ascii",
"ascii-large", and "legacy" graph styles still use "o".

I didn't change `@` since it seems useful to have that match the
symbol used on the CLI. I don't think we want to have users do
something like `jj co ◎-`.
2023-03-12 23:21:05 -07:00
Martin von Zweigbergk
346e3c849b repo: propagate error when failing to look up backend type 2023-02-27 09:44:28 -08:00
Martin von Zweigbergk
a67fbb6714 cli: switch default graph style to be Sapling's curved style
We seem to quite unanimously prefer this style, so let's make the
default.
2023-02-12 07:23:29 -08:00
Yuya Nishihara
e2a5a14463 cli: use label() to highlight "working_copy" commit in log template
I think this is a proper way to label the working-copy commit. This also
fixes "jj obslog" output, but I don't think anyone would care.
2023-02-04 01:58:13 +09:00
Martin von Zweigbergk
b0a6493d20 cli: rename --no-commit-working-copy to --ignore-working-copy
We have moved from saying "committing the working copy" towards saying
"snapshotting the working copy". More importantly, the option also
means that we don't update the working copy at the end. I went with
the `--ignore-working-copy` name suggested by Ilya. I also updated the
documentation of the option.
2023-02-02 21:03:30 -08:00
Martin von Zweigbergk
3ccdd1f98a tests: pass string instead of bytes to add_config()
I don't think need to write non-UTF8 bytes to our config files. If we
ever do (maybe to test that we give the user a reasonable error
message), we add a custom function for that.
2023-01-26 12:48:30 -08:00
Martin von Zweigbergk
e1d49cc67f tests: use dotted notation in TOML when it saves lines 2023-01-26 12:48:30 -08:00
Martin von Zweigbergk
6ae671960c formatter: don't write escape codes until we write text
We often end up writing escape codes for one style and then
immediately after, we write escape codes for another style. That seems
harmless, but it's a little ugly. More importantly, it prepares for
not emitting any escapes for turning off attributes at the end of
formatted contents across multiple lines (see next commit).
2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
2a9c37a693 formatter: remove hack for making bright colors bold
We can now configure the working-copy commit and the head operation to
use bold font, so we no longer need the hack to make bright colors
bold.
2023-01-13 21:47:50 -08:00
Martin von Zweigbergk
5cf2b6615a formatter: use crossterm for colors
Let's use `crossterm` to make `ColorFormatter` a little more readable,
and maybe also more portable.

This uses the `SetForegroundColor()` function, which uses the escapes
for 256-color support (code 38) instead of the 8-color escapes (codes
30-37) combined with bold/bright (code 1) we were using before. IIUC,
most terminals support the 16 base colors when using the 256-color
escape even if they don't support all the 256 colors. It seems like an
improvement to use actual color codes for the bright colors too,
instead of assuming that terminals render bold as bright (even though
most terminals do).

Before this commit, we relied on ANSI escape 1 - which is specified to
make the font bold - to make the color brighter. That's why we call
the colors "bright blue" etc. When we switch from using code 30-37 to
using 38 to let our color config just control the color (not using
escape1), we therefore lose the bold font on many terminals (at least
in iTerm2 and in the terminal application on my Debian work
computer). As a workaround, I made us still use escape 1 when the
bright colors are used. I'll make boldness a separately configurable
attribute soon. Then we'll be able to remove this hack.

With the switch to `crossterm`, we also reset just the foreground
color (code 39) instead of resetting all attributes (code 0). That
also seems like an improvement, probably making it easier for us to
later support different background colors, underlining, etc.
2023-01-13 21:47:50 -08:00
Yuya Nishihara
cb0b9e590a cli: do not search ancestor paths specified by -R/--repository
If a workspace path is explicitly specified, it must point to the exact
workspace directory. This is the same behavior as 'hg -R'. OTOH, 'git -C'
is the option to chdir, so it makes sense to search .git from that directory.

This also fixes 'jj -R ../..' which would previously look up '../..', '..',
'.', ...
2023-01-10 23:31:26 +09:00
Yuya Nishihara
40a9f75441 workspace: do not look up ancestor paths by Workspace::load()
I don't think Workspace::load() should be permissive in that regard.
WorkspaceLoader could provide such function, but I feel it's more like
CLI business. CLI can also look for parent '.git' directory to suggest
'jj init --git-repo=..' if needed.
2023-01-10 23:31:26 +09:00
Yuya Nishihara
d798213cc8 cli: do not look up workspace path more than once, reuse WorkspaceLoader 2023-01-10 11:51:29 +09:00
Yuya Nishihara
ea96ea3ffe cli: load configs from .jj/repo/config.toml
Since per-repo config may contain CLI settings, it must be visible to CLI.
Therefore, UserSettings::with_repo() -> RepoSettings isn't used, and its
implementation is nullified by this commit.

#616
2023-01-07 11:33:12 +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
Ilya Grigoriev
c9706fc0d4 Rename jj touchup to jj diffedit 2022-12-21 08:15:06 -08:00
Ilya Grigoriev
f71ca25ebe cmd: Add --to and --from arguments to jj touchup
This allows touching up a commit while seeing the differences between it and
another arbitrary commit.
2022-12-21 08:15:06 -08:00
Glen Choo
aa2ce88544 cli: process args to "--help" and "help"
Clap bails parsing when an "error" is encountered, e.g. a subcommand is missing,
"--help" is passed, or the "help" subcommand is invoked. This means that the
current approach of parsing args does not handle flags like `--no-pager` or
`--color` when an error is encountered.

Fix this by separating early args into their own struct and preprocessing them
using `ignore_errors` (per https://github.com/clap-rs/clap/issues/1880).

The early args are in a new `EarlyArgs` struct because of a known bug where
`ignore_errors` causes default values not to be respected
(https://github.com/clap-rs/clap/issues/4391 specifically calls out bool, but
strings may also be ignored), so when `ignore_errors` is given, the default
values will be missing and parsing will fail unless the right arg types are used
(e.g`. Option`). By parsing only early args (using the new struct) we only need
to adjust `no_pager`, instead of adjusting all args with a default value.
2022-12-14 04:50:14 +08:00
Glen Choo
0df5f7c5bf cli: add --no-pager 2022-11-30 06:14:39 +08:00
Martin von Zweigbergk
d8feed9be4 copyright: change from "Google LLC" to "The Jujutsu Authors"
Let's acknowledge everyone's contributions by replacing "Google LLC"
in the copyright header by "The Jujutsu Authors". If I understand
correctly, it won't have any legal effect, but maybe it still helps
reduce concerns from contributors (though I haven't heard any
concerns).

Google employees can read about Google's policy at
go/releasing/contributions#copyright.
2022-11-28 06:05:45 -10:00
Ruben Slabbert
f0e4615e61 feature: add verbose flag and tracing library 2022-11-24 16:35:14 +10:00
Yuya Nishihara
946d5c5896 tests: suppress must_use warning and update cli_error output 2022-11-21 23:14:50 +09:00
Waleed Khan
9607d954e4 tests: assert result of TestEnvironment::jj_cmd_cli_error
In the test case `test_branch_mutually_exclusive_actions`, we weren't actually testing anything useful, because the interface has since changed to use subcommands instead of options. The test has been deleted in this commit, and `TestEnvironment::jj_cmd_cli_error` has been changed to return a `#[must_use]` `String` representing stderr. I also added `#[must_use]` to `TestEnvironment::jj_cmd_failure` while I was here.
2022-11-20 05:08:35 -08:00
Yuya Nishihara
6d500ed66c cli: fix crash by "jj <global_opts>" without subcommand 2022-11-20 22:02:46 +09:00
Ilya Grigoriev
93b7b34871 Add --config-toml command-line argument for additional TOML config
Unfortunately, TOML requires quotes around the argument. So, the
usage is `jj --config-toml ui.color=\"always\"` in bash. The plan is
to eventually have a `--config` option with simpler syntax for
simple cases.

As discussed in https://github.com/martinvonz/jj/discussions/688.
2022-11-05 21:21:33 -07:00
Martin von Zweigbergk
5fa21b612c cli: remind the user to configure their name and email
This commit adds a reminder in `finish_transaction()` if the user
hasn't configured their name and email. That means they'll get a
reminder after most mutating commits, except for commands that only
snapshot the working copy, and a few more cases.

Closes #530.
2022-10-09 21:24:05 -07:00
Martin von Zweigbergk
b561a05d25 cargo: upgrade to clap 4.0.4
I changed the "GLOGAL OPTIONS" help heading to use title case, to
match clap's new help style.

I also removed our override of the help text for `-h, --help` because
the default text now includes "(use `-h` for a summary)" (and it's
harder override now).

Perhaps the most obvious difference to users will be the changed help
output
(https://epage.github.io/blog/2022/09/clap4/#polishing-help-output). It
no longer has color, and long lines are not wrapped. I suppose we
should wrap the text ourselves instead..
2022-09-29 17:53:36 -07:00
Martin von Zweigbergk
9c55d98842 cli: rename jj edit to jj touchup 2022-07-01 08:58:08 +08:00
Yuya Nishihara
4dea1f9e16 cli: parse --color option and reconfigure ui
I often redirect the jj output to pager, so I set ui.color = "always" in
config file. This patch allows me to remove such config, and instead specify
--color=always only when needed.
2022-06-10 12:47:06 +09:00
Yuya Nishihara
3d41db1659 config: move NO_COLOR handling from ui, don't override user setting
According to the NO_COLOR FAQ, "user-level configuration files [...] should
override $NO_COLOR." https://no-color.org/

Unfortunately this makes it harder to test the $NO_COLOR behavior since the
test environment isn't attached to a tty. We could allocate a pty or
LD_PRELOAD shim to intercept isatty(), but I feel it would be too much to do.

https://github.com/assert-rs/assert_cmd/issues/138
2022-06-10 12:47:06 +09:00