Commit graph

309 commits

Author SHA1 Message Date
Ilya Grigoriev
c0fc9a464a jj abandon: Print every abandoned commit
This can be disabled with the new `--quiet` option.

Printing every commit would give the user all the information of how to undo
this or where to `jj restore` from if they realize they need to after the
abandon.
2023-01-11 23:32:39 -08:00
Ilya Grigoriev
ef3071ba09 Improve short_commit_description for commits without a description 2023-01-11 23:32:39 -08:00
Ilya Grigoriev
6765850c7d jj abandon: Report what commit or how many commits were abandoned
There are not tests for `jj abandon`, and I haven't written any yet.
2023-01-11 23:32:39 -08:00
Ilya Grigoriev
c43f0a580a Add tests for the abandon command
I tested some hairy cases, but didn't add any simpler tests.
2023-01-11 23:32:39 -08:00
Ilya Grigoriev
9a3329ee25 jj resolve --list: make output aligned
If all file names are short enough, this will align the conflict
description at 4 spaces past the longest file name, as follows.

```
src/templater.rs            2-sided conflict
src/templater_parsers.rs    2-sided conflict
```

If there is a long file name, conflict descriptions will either start
or column 35 or one space from a file name, whichever is later.

Previously, a single tab was used to separate file name from conflict
description. This didn't look as nice as I hoped when multiple files
are involved. I also don't think `jj` generally uses tabs in output.
The tab uncovered a bug in a watcher program I was using.
2023-01-11 23:29:53 -08:00
Ilya Grigoriev
5b1b35cbfe Update test to prepare for next commit 2023-01-11 23:29:53 -08:00
David Barnett
e6b3b9c09b Add a config edit command to open jj config in editor
Part of #531 to define the overall `config` command.
2023-01-12 01:10:07 -06:00
Vamsi Avula
1aad250420 Shorten the git push branch when possible using the short change ID hash. 2023-01-12 11:45:13 +05:30
Yuya Nishihara
ba7016788f cli: fix highlighting of checkout commit in "log --no-graph" 2023-01-11 11:33:28 +09: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
Ilya Grigoriev
65de7cb0eb jj log: Change conflicted branches from br? to br??
The divergent changes are marked with ?? (I found a single ? a bit easy to
overlook), and this should be consistent.

Ideally, the conflicted branches would also be red, but this takes a bit
larger changes to `templater.rs`: another `Property` as well as changes to
https://github.com/martinvonz/jj/blob/7f9a0a28/src/template_parser.rs#L385-L395
2023-01-09 22:44:45 -08:00
Ilya Grigoriev
8093bc0614 jj log: Replace divergent label with ?? and red color
This follows up on a [discussion] in a previous PR #941.

[discussion]: https://github.com/martinvonz/jj/pull/941#issuecomment-1363551162

Screenshot: https://user-images.githubusercontent.com/4123047/209286340-bb83df2d-4020-4608-9755-d965477799c3.png
2023-01-09 22:44:45 -08:00
Ilya Grigoriev
5f2a99ac8a Test commit template with divergence 2023-01-09 22:44:45 -08:00
Ilya Grigoriev
a43c47a28c Move a test from test_log_command to test_commit_template 2023-01-09 22:44:45 -08:00
Yuya Nishihara
d798213cc8 cli: do not look up workspace path more than once, reuse WorkspaceLoader 2023-01-10 11:51:29 +09:00
Martin von Zweigbergk
2506cdee28 log: add test of colored output
I'm about to make some changes to the templater, so let's have a test
least a simple test of the current colored output.
2023-01-08 12:32:31 -08:00
Martin von Zweigbergk
1b4992e11c tests: create new file for tests of commit template
An important part of the `jj log` output is the commit template. I
suspect we'll have many more tests for that, so let's move it to a
separate file. The main `test_log_command.rs` can focus on which
commits to display.
2023-01-08 12:32:31 -08:00
Ilya Grigoriev
fc9795e902 jj resolve --list: make output colorful
The description is usually in yellow, which looks nice and neutral. If the
conflict has more than 2 sides or has special files, that's marked in red.
2023-01-07 15:29:19 -08:00
Ilya Grigoriev
89de9aeae1 jj resolve --list: Replace separator with \t
The `:` was a bit noisy. With upcoming color support, it seems unnecessary.

This should also be a little better for any tools that want to parse the
output.

Finally, `insta` also seems to want to rewrite test snapshots to be shorter.
They seem equivalent.
2023-01-07 15:29:19 -08:00
Ilya Grigoriev
e32342a6c4 jj op log: Show durations with relative timestamps
Before, the humanized versions of start and end times often were identical.
2023-01-07 12:08:00 -08:00
Ilya Grigoriev
a48b4855be Have jj op log obey ui.relative-timestamps option 2023-01-07 12:08:00 -08:00
Martin von Zweigbergk
4aeb4f6e2a tests: drop no-longer-needed filtering of change ID
Our change IDs are now predictable in tests.
2023-01-06 23:03:58 -08: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
3c99852ebd tests: add basic config precedence test 2023-01-07 11:33:12 +09: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
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
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
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
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
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
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
David Barnett
e824c491bf Add a "config" command with "get" and "list" subcommands
Partially fixes #531.
2022-12-27 16:59:20 -06:00
Yuya Nishihara
2550dcae4c cli: include diff summary in commit/describe editor content 2022-12-23 00:47:22 +09:00
Yuya Nishihara
d438f43224 cli: rephrase diff summary header so it can be reused for commit/describe 2022-12-23 00:47:22 +09:00
Yuya Nishihara
5076622598 tests: use insta to test editor contents
It's tedious to update editor expectation manually. Let's dump the actual
content and test it after each command invocation.
2022-12-23 00:47:22 +09:00
Yuya Nishihara
36020a2bbf revset: parse hg/git-like '^' postfix operator and show hint 2022-12-23 00:38:29 +09:00
Yuya Nishihara
7cd01b27a7 revset: parse hg-like '-'/'+' infix operators and show hint
Suggested by @arxanas.

Actually, it's easier to support these infix ops than erroring out, but I
don't want to make revset syntax more cryptic. "x- y" can't be handled by
this rule because "x-" is parsed as a parents expression.
2022-12-23 00:38:29 +09:00
Yuya Nishihara
300f744e41 cli: normalize line ending of edited commit description, ensure last newline
Since CR+LF vs LF things shouldn't matter in commit description, it's probably
better to normalize newline characters.

In Mercurial, ui.edit() and changelog.stripdesc() handle line normalization,
and trailing newlines are stripped. In Git, cleanup_message() handles that,
and the last newline is added after stripping trailing newlines.
2022-12-22 14:59:03 +09:00
Yuya Nishihara
6f8fb09609 cli: append "\n" to commit description specified by -m/--message
Otherwise the description set by -m would differ from the one set by editor.
This fixes test_describe() which says "make no changes", but previously "\n"
would be added by the second "jj describe".

As you can see, almost all hashes change in CLI tests. This means in-flight
PRs will need to be rebased to update insta snapshots.

Description text could be normalized by CommitBuilder, but the caller would
have to normalize it beforehand to compare with the current description, so
we would need an explicit function anyway. Another idea is to add a newtype
that represents a normalized description, and make CommitBuilder require it.
Commit::description() will return &Description in place of &str to ensure
that commit.description() == raw_str wouldn't compile.

Git CLI provides --cleanup=<mode> option to switch normalization rules, but
I don't think we'll need such feature.
2022-12-22 14:59:03 +09:00
Ilya Grigoriev
386fdce631 Rename test_touchup_command.rs to test_diffedit_command.rs 2022-12-21 08:15:06 -08:00
Ilya Grigoriev
18722bbf36 cmd: Remove the -i option to jj restore.
It is superceded by the new options to the `jj diffedit` command.
2022-12-21 08:15:06 -08: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
Yuya Nishihara
b474fc6ab5 cli: fix move/squash/unsquash tests to run without source commit description
And ensure that editor isn't invoked in those cases.
2022-12-22 00:29:03 +09:00
Ilya Grigoriev
2f00fcb6b4 jj git push: Make sure each branch is processed at most once 2022-12-21 00:52:17 -08:00
Ilya Grigoriev
fad686f48c Allow jj git push to push multiple branches/changes at once
Also creates short arg `-b` for `--branch`.
2022-12-21 00:52:17 -08:00