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

283 commits

Author SHA1 Message Date
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
Ilya Grigoriev
63854e7b6c Add a test for git push --change 2022-12-21 00:52:17 -08:00
Yuya Nishihara
9158c96202 cli: show hint if e.g. checkout revset resolved to multiple revisions
As suggested at
https://github.com/martinvonz/jj/issues/878#issuecomment-1345466602
2022-12-15 22:55:29 +09:00
Martin von Zweigbergk
7f9a0a2820 cleanup: let new Clippy move variables into format strings
I ran an upgraded Clippy on the codebase. All the changes seem to be
about using variables directly in format strings instead of passing
them as separate arguments.
2022-12-14 21:30:58 -08:00
Yuya Nishihara
cec4d6c214 cli: allow multiple diff outputs
"jj log -p --summary" now shows summary and color-words diff, like
"hg log -p --stat".

Handling of "-p" is tricky. I first considered "-p" would turn on the default
diff output, but I found it would be confusing if "jj log -p --git" showed
both color-words and git diffs. So the default format is inserted only if
no --git nor --color-words is explicitly specified.
2022-12-15 11:41:42 +09:00
Yuya Nishihara
69e57daa64 cli: enable diff output by 'log --color-words'
It doesn't make sense that --git implies -p, but --color-words doesn't.
2022-12-15 11:41:42 +09:00
Martin von Zweigbergk
b28ff2fbd9 cli: use committer timestamp instead of author timestamp in log output
The author timestamp is rarely useful (in my experience). The
committer timestamp, on the other hand, can be useful for
understanding when a change was most recently modified. IIRC, I
originally picked the author timestamp to match the email (which is
the author's), but it's probably not confusing to use the author email
and the committer timestamp. I suspect few users will even reflect on
it.
2022-12-14 15:48:11 -08:00
Yuya Nishihara
73ea5cd56e cli: parse early args in/after alias properly
Follows up aa2ce88544 'cli: process args to "--help" and "help"'.
2022-12-14 13:51:23 +09:00
Yuya Nishihara
5dc73ab7ad cli: do not raise ClapError from resolve_aliases()
This allows us to process early args after alias resolution.
2022-12-14 13:51:23 +09: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
Yuya Nishihara
67be440f4a cli: resolve operation symbol first and apply '-' postfix repeatedly
Just like revsets.
2022-12-13 09:28:48 +09:00
Yuya Nishihara
c46c150542 cli: add one more operation to test_op_log()
Also made op id variables less dynamic as operation ids are now stable
in tests.
2022-12-13 09:28:48 +09:00
Waleed Khan
91ead75e43 feat(branch): support jj branch forget --glob 2022-12-10 16:51:10 -08:00
Danny Hooper
6787e17254 Do not use "..." between diff chunks when it only replaces 1 line of the diff
The number of lines in the diff output is unchanged.

This makes diffs a little more readable when the "..." would otherwise hide a
single line of code that helps in understanding the surrounding context lines.

This change mostly rearranges the loop that consumes the diff lines, so it can
buffer up to num_context_lines*2+1 lines instead of just num_context_lines.
There's a bit of extra code to handle times when a "..." replaces the last line
of a diff.

Note that `jj diff --git` is unchanged, and will still output `@@` lines that
replace a single line of context.
2022-12-09 20:39:40 -06:00
Martin von Zweigbergk
2a1c2e05ba cli: when colocated with Git, export refs on snapshot
This fixes the bug described in the previous commit.

Because we now print the message about failed exports also while
snapshotting, we may end up reporting it twice on one command. I'm not
sure it's worth worrying about that. We can deal with that later if it
turns out to be a common complaint.
2022-12-08 23:10:18 -08:00
Martin von Zweigbergk
217883591b git: demonstrate how branches don't get exported on snapshot
If a branch points to the working-copy commit, it will automatically
get updated when the working copy is snapshotted. However, it turns
out that we don't automatically export the change to Git when running
in a colocated working copy (nor in a non-colocated working copy, but
that shouldn't be surprising). The change will not get exported until
a non-snapshot operation runs. We noticed this bug in @hooper's repo
today.
2022-12-08 23:10:18 -08:00
Yuya Nishihara
b6e06f6dc9 cli: use deserialize to parse alias definition
Unfortunately, config::Value is lax and '[7]' could be parsed as '["7"]'.
I don't like it, but I think that's actually better for consistency as we
use config.get_string() in various places.
2022-12-07 23:26:11 +09:00
Yuya Nishihara
283231b1e4 cli: load all aliases to map first to suppress cryptic error
Otherwise 'jj foo.' would fail with 'Config error: Char'.
2022-12-07 23:26:11 +09:00
Yuya Nishihara
a45e00179c cli: on clone, turn local git remote to absolute path
Otherwise a subsequent git fetch would fail.
2022-12-07 14:14:31 +09:00
Ilya Grigoriev
9e334de7d6 Remove insta::assert_snapshot that causes a failure with insta 1.22 2022-12-05 22:29:05 -08:00
Martin von Zweigbergk
a0573b1737 cli: add a command for updating a stale working copy
When a workspace's working-copy commit is updated from another
workspace, the workspace becomes "stale". That means that the working
copy on disk doesn't represent the commit that the repo's view says it
should. In this state, we currently automatically it to the desired
commit next time the user runs any command in the workspace. That can
be undesirable e.g. if the user had a slow build or test run started
in the working copy. It can also be surprising that a checkout happens
when the user ran a seemingly readonly command like `jj status`.

This patch makes most commands instead error out if the working copy
is stale, and adds a `jj workspace update-stale` to update it. The
user can still run commands with `--no-commit-working-copy` in this
state (doing e.g. `jj --no-commit-working-copy rebase -r @ -d @--` is
another way of getting into the stale-working-copy state, by the way).
2022-12-05 08:50:52 -08:00
Ilya Grigoriev
e9952bcf76 Minimal version of resolve --list
Simply lists conflicted files
2022-12-04 22:58:12 -08:00
Ilya Grigoriev
ea1395ad95 Make optional the path argument to resolve, allow partial paths
Also allows several paths to be specified. By default, `jj resolve`
will find the first conflict that matches provided paths (if any)
and try to resolve it.
2022-12-04 22:39:45 -08:00
Ilya Grigoriev
b58be8d7a4 Mention path in message for ConflictResolveError::NotNormalFilesError. 2022-12-04 22:39:45 -08:00
Martin von Zweigbergk
48c44344bf cli: make jj status not just care about the first parent
It seems like I forgot to update the `jj status` output when I decided
(years ago?) that the changes in a commit should always be compared to
the auto-merged parents. I was very confused before I realized that
`jj status` was showing the diff summary against the first parent. I
suppose the fact that `jj status` lists only one parent should have
been a hint. Thanks to ilyagr@ for finding this odd behavior. This
patch fixes it by making the command list all parents, and changes the
diff summary to be against the auto-merged parents.
2022-12-04 22:29:12 -08:00
Ilya Grigoriev
d6c1b0bc9c jj resolve: option to parse conflict markers + tests
If this new option is not specified, we start with empty output
file and trust the merge tool did a complete merge no matter
what the file contains.

Includes tests.
2022-12-03 15:12:40 -08:00
Ilya Grigoriev
3e86baa7f1 Test basic jj resolve functionality 2022-12-03 15:12:40 -08:00