Commit graph

1001 commits

Author SHA1 Message Date
Yuya Nishihara
c147125ce9 cli: migrate "cat" to matcher API, warn unmatched paths
This is the last non-debug command that doesn't support file patterns. It
wouldn't make much sense to "cat" multiple files (despite the command name),
but doing that should be harmless.
2024-04-16 10:12:31 +09:00
Yuya Nishihara
ac794e560f cli: extract function that prints multiple file contents
Prepares for migrating to the matcher API. "Path exists but is not a file"
error is turned into a warning because the loop shouldn't terminate there.

"No such path" error message is also updated for consistency.
2024-04-16 10:12:31 +09:00
Anton Älgmyr
af185725a1 Move to inline labeling and building a single label in log node template. 2024-04-15 22:21:31 +02:00
Anton Älgmyr
2af590eb54 Add template aliases with node symbol configs. 2024-04-15 22:21:31 +02:00
Evan Mesterhazy
0ef25bb4b6 Add a --use-destination-message option to jj squash
if `--use-destination-message/-u` is passed to `jj squash`, the resulting
revision will use the description of the destination revision and the
description(s) of the source revision(s) will be discarded.
2024-04-14 16:58:30 -04:00
Ilya Grigoriev
82c85ba754 docs: stop mentioning meld as the default diff editor
The default is now `:builtin`.
2024-04-12 21:47:17 -07:00
dploch
57a5d7dd64 cli_util: support multiple extensions consistently
If we ever implement some sort of ABI for dynamic extension loading, we'll need these underlying APIs to support multiple extensions, so we might as well do that first.
2024-04-12 14:07:33 -04:00
Yuya Nishihara
30984dae4a cli: if enabled, parse path arguments as fileset expressions
If this doesn't work out, maybe we can try one of these:
 a. fall back to bare file name if expression doesn't contain any operator-like
    characters (e.g. "f(x" is an error, but "f x" can be parsed as bare string)
 b. introduce command-line flag to opt in (e.g. -e FILESET)
 c. introduce pattern prefix to opt in (e.g. set:FILESET)

Closes #3239, #2915, #2286
2024-04-12 11:36:40 +09:00
Yuya Nishihara
a9694cba27 cli: add ui.allow-filesets to experiment with fileset/pattern syntax
The pattern syntax could be enabled unconditionally, but I want to fully
replace the ad-hoc pattern parsing function.
2024-04-12 11:36:40 +09:00
Evan Mesterhazy
65a525cfd9 Add a test for splitting the parent of a merge commit without --siblings
This is the same as the `test_split_siblings_with_merge_child` added in
https://github.com/martinvonz/jj/pull/3485, but without the siblings flag. I
forgot to add the non-siblings version in that PR.

#3485
2024-04-11 14:58:55 -04:00
Ilya Grigoriev
8fa256ebac New jj debug watchman status command
This command checks not only whether Watchman works, but also whether
it's enabled in the config. Also, the output is easier to understand
than that of the other `jj debug watchman` commands.

It would be nice if `jj debug watchman` called `jj debug watchman
status`, but it's not trivial in `clap` to have a default subcommand.
2024-04-11 10:55:59 -07:00
Ilya Grigoriev
383711fcd8 config docs: document valid fsmonitor values
I was wondering how to disable the watchman in a repo if it's enabled in
the user config.
2024-04-11 10:55:59 -07:00
Evan Mesterhazy
37be542ebf Fix a bug when the target of jj split has merge commit children
Ilya reported this in https://github.com/martinvonz/jj/issues/3483.

The bug was introduced in 976320726d.

Before this fix, `jj split` dropped any parents what weren't involved in the
split when it rebased the children of the commit being split. This meant that
any children which were merge commits lost their other parents unintentionally.

Fixes #3483
2024-04-11 13:26:07 -04:00
Yuya Nishihara
1bfacea2f9 cli: migrate "chmod" to matcher API, warn unmatched paths 2024-04-11 00:51:19 +09:00
Yuya Nishihara
ae70db843e cli: warn explicit paths not exist in either of diff trees
Maybe we can optimize it to check paths during diffing, but I think it's okay
to add extra lookup cost at the end. The size of the path arguments is usually
small.

Closes #505
2024-04-11 00:51:19 +09:00
Jeremy O'Brien
580a90b694 cli: fix typo in 'jj untrack --help' 2024-04-09 09:18:40 -07:00
Yuya Nishihara
05b0fb50f1 cli: add fileset utility functions and debug command
Path parsing will be migrated to parse_union_filesets(), but I haven't decided
how we'll go forward:
 a. migrate everything to fileset
 b. require flag like "-e FILESET" (note -p conflicts with log -p)
 c. require flag like "-e FILESET" and deprecate positional PATHs #2554
 d. require prefix like "set:FILESET" (not consistent with -r REVSET)

I'm currently dogfooding (a). It works for me, but I don't use exotic file
names that would require quoting in zsh.

#3239
2024-04-09 20:42:09 +09:00
Yuya Nishihara
521bcd81ab dsl_util: deduplicate collect_similar() from revset and templater
For convenience, sort and dedup are done by collect_similar().
2024-04-09 20:42:09 +09:00
Evan Mesterhazy
13592ce49e Make jj next work when the working copy is a merge commit 2024-04-08 14:52:11 -04:00
Evan Mesterhazy
d90a0ec246 Make jj prev work when the working copy is a merge commit
Before this commit `jj prev` fails if the current working copy commit is a
merge commit. After this commit it will prompt the user to choose the ancestor
they want to select.

#2126
2024-04-08 14:52:11 -04:00
Evan Mesterhazy
cc6d290679 Fix a few minor issues with the jj prev tests
This commit adds commit graphs to most of the tests for `jj prev` to make it
clearer where `@` points before and after `prev` is run.

In addition, there were a couple of tests where the comments suggested the test
meant to have `@` pointing to a specific commit, but it actually pointed to an
empty child of that commit.

This sort of issue also exists in `test_prev_editing`. The test is supposed to
check that `--edit` is implied if you run `jj prev` on an interior commit, but
it actually caused a new empty commit to be created since `@` was sitting on a
tip commit.
2024-04-08 09:12:19 -04:00
Anton Bulakh
feaaa48ed0 templates: Change builtin_log_root to be consistent with other hooks 2024-04-07 19:46:52 +03:00
Anton Bulakh
0f2573abae templates: Split oplog template into hookable functions
This is to allow modifying default templates without completely overriding
them, for example to change the oplog snapshots but keep other defaults
2024-04-07 19:46:52 +03:00
Anton Bulakh
29729e844d templater: Add operation.snapshot() boolean
Expose the information we now record, to allow changing the default "snapshot
working copy" message or to make snapshots more compact/less distracting in
the log
2024-04-07 19:46:52 +03:00
Evan Mesterhazy
f4fb8f18a7 Update the documentation for jj next
This is to match the recent changes made to the docs for `jj prev`.
2024-04-07 12:21:35 -04:00
Evan Mesterhazy
506392703b Make a minor formatting change to the help page for jj parallelize
Per discussion on another PR, we're going to avoid ALL CAPS for argument names
in the documentation even though Clap uses that style for the `--help` output.

- https://github.com/martinvonz/jj/pull/3453#discussion_r1554169975
2024-04-07 12:20:19 -04:00
Evan Mesterhazy
c1920d765f Improve the documentation of jj prev
This will hopefully make it clear that `jj prev` does not
move by [OFFSET] relative to `@`, which is a misconception
that I had and I think others may also have.

I am suggesting this change as a result of the vigorous discussion in
these two issues:

- https://github.com/martinvonz/jj/issues/3426
- https://github.com/martinvonz/jj/pull/3445

We should make similar changes to `jj next` as well since
it follows similar rules.
2024-04-07 12:19:54 -04:00
Yuya Nishihara
274183fa66 dsl_util: extract helper that parses string literal with \-escapes
The top-level assertion is removed since it's now obvious that the pair
represents a Rule::string_literal.
2024-04-08 00:37:25 +09:00
Yuya Nishihara
46b4c68325 templater: mark string literal as compound atomic, and integer as atomic
They aren't important because we don't use implicit whitespace rule, but let's
clarify they are atomic rules.

https://pest.rs/book/grammars/syntax.html#atomic
2024-04-08 00:37:25 +09:00
Yuya Nishihara
6039e9889c templater: rename string literal rules
This patch adds "string_" prefix to the related rules to discriminate them from
integer_literal. I also renamed "raw_literal" because it sounds like a raw
string literal that preserves backslash characters.
2024-04-08 00:37:25 +09:00
Yuya Nishihara
9b1eb03c73 cli: inline matcher_from_values() in favor of parse_file_patterns() 2024-04-07 19:43:29 +09:00
Yuya Nishihara
07d027193b cli: add support for file kind:pattern syntax
This is basically the same as string kind:pattern syntax in CLI. This will
hopefully be superseded by filesets, but I'm not sure if that will work out.
A file name is more likely to contain whitespaces, which will have to be
quoted as '"Documents and Settings"'.
2024-04-07 19:43:29 +09:00
Yuya Nishihara
8b32a8a916 revset: add support for file(kind:pattern) syntax
There are no more callers of parse_function_argument_to_string(), so it's
removed. This function was a thin wrapper of literal parser, and can be
easily reintroduced if needed.
2024-04-07 19:43:29 +09:00
Yuya Nishihara
47150d2bb4 revset: migrate file() predicate to be based on FilesetExpression 2024-04-06 23:59:54 +09:00
Scott Olson
e22370c485 cli: support filtering by paths in status 2024-04-05 20:41:44 +01:00
Evan Mesterhazy
64e242ab3a Implement jj parallelize
Parallelize revisions by making them siblings

Running `jj parallelize 1::2` will transform the history like this:
```text
3
|             3
2            / \
|    ->     1   2
1            \ /
|             0
0
```

Each of the target revisions is rebased onto the parents of the root(s) of
the target revset (not to be confused with the repo root). The children of
the head(s) of the target revset are rebased onto the target revisions.

The target revset is the union of the REVISIONS arguments.

The target revset being parallelized must satisfy several conditions,
otherwise the command will fail.

1. The heads of the target revset must not have different children.
2. The roots of the target revset must not have different parents.
3. The parents of all target revisions except the roots must also be
   parallelized. This means that the target revisions must be connected.
2024-04-05 12:43:10 -04:00
Austin Seipp
4b45dde8c6 clippy: disable bogus lints for nightly clippy
The nightly compiler has several clippy fix-its that, if applied, break the
build. There are various bugs about this, but there isn't enough space in the
margins to detail it all.

Just ignore these on a per-function basis; about 70% of them are just multiple
instances happening inside a single function.

This makes `cargo clippy --workspace --all-targets` run clean, even with the
nightly compiler.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ic26a025d3c62b12fbf096171308b56e38f7d1bb9
2024-04-05 11:39:29 -05:00
Austin Seipp
db14f33170 cli: add ui.always-allow-large-revsets option
This lets users use "large" revsets in commands such as `jj rebase`, without
needing the `all:` modifier.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ica80927324f3d634413d3cc79fbc73057ccefd8a
2024-04-04 18:38:48 -05:00
Noah Mayr
2cf1c34f58 template: add method mine() to commit type 2024-04-04 22:47:34 +02:00
Yuya Nishihara
32afea198a templater: relax operator precedence rule to reduce possibility of large reparse
After upgrading pest from 2.7.8 to 2.7.9, I noticed CLI tests got significantly
slow (something around 40sec -> 60sec on my laptop.) I suspect this would be
caused by detailed error state tracking introduced in 2.7.9, but it's also true
that our template grammar exercises such code path.

My understanding is that PEG is basically a top down parsing with unlimited
lookahead. Before this change, the default commit_summary template would be
parsed as follows:
 1. parse the outermost separate(..) as "term"
 2. "concat" rule can't continue, so
 3. reparse the whole string as "expression"
Because this pattern is not uncommon, I think it's better to rewrite the
grammar to avoid large retry.

With this patch, our tests runs within ~50sec under debug build. It appears to
save a few milliseconds in release build, but my development environment isn't
quiet enough to say the difference is significant.
2024-04-04 23:46:32 +09:00
Evan Mesterhazy
b07fb3ea58 Rename the "AMOUNT" argument for jj prev and jj next to OFFSET
Offset is a more descriptive noun for this argument. This commit also tweaks
the help message for the argument.

This isn't an option/flag, so this change should be transparent to users.
2024-04-04 09:32:29 -04:00
Evan Mesterhazy
d4a04779c0 Make check_rewritable take an iterator of &CommitId instead of &Commit
This function doesn't actually need commits, it only needs their IDs. In some
contexts we may only have commit IDs, so there's no need to require an iterator
of Commits.

This commit also adds a `CommitIteratorExt` that makes it easy to convert an
iterator of `&Commit` to an iterator of `&CommitId`.
2024-04-04 09:31:17 -04:00
Benjamin Tan
7e46cc13dc cli: print conflicted paths whenever the working copy is changed
This is disabled when the global `--quiet` flag is used.
2024-04-04 11:24:09 +08:00
Yuya Nishihara
eaa15f804d squash: accept multiple --from arguments
Since multiple revisions can be specified, there's no reason to reject multiple
--from arguments.
2024-04-04 12:08:42 +09:00
Yuya Nishihara
363b508441 cli: ditch Deref, implement AsRef and Display for RevisionArg instead
Deref has a super power, which we no longer need.
2024-04-03 15:30:30 +09:00
Yuya Nishihara
c596d457f6 cli: migrate singular parse/resolve revset argument to RevisionArg
It doesn't make sense that plural versions take &[RevisionArg], whereas
singular ones take &str.
2024-04-03 15:30:30 +09:00
Yuya Nishihara
311bdbf58d cli: use RevisionArg type in "resolve -r", "bench", and example command 2024-04-03 15:30:30 +09:00
Yuya Nishihara
ae91adbaf4 cli: preserve RevisionArg type as much as possible
Just for a bit of type safety.
2024-04-03 15:30:30 +09:00
Yuya Nishihara
426ee1c154 cli: abuse Cow to declare RevisionArg("@") constant
I'm going to make all WorkspaceCommandHelper::parse/resolve_revset functions
accept &RevisionArg, so I want a convenient way to unwrap Option<RevisionArg>.

Another option is to add an associated function that returns
RwvisionArg("@".to_owned()). As we wouldn't care for the allocation cost, either
approach should work fine.
2024-04-03 15:30:30 +09:00
Noah Mayr
88a4a8281f cli: add better error message when immutable_heads() cannot be resolved 2024-04-03 07:58:00 +02:00