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

5868 commits

Author SHA1 Message Date
Yuya Nishihara
c8f93c50fc revset: remove redundant Result<..> from parse_symbol_rule_as_literal() 2024-04-08 00:37:25 +09:00
Yuya Nishihara
d442cd872f revset: backport \-escapes parsing from templater 2024-04-08 00:37:25 +09:00
Yuya Nishihara
d1ae2d72c8 revset: rename Rule::literal_string to string_literal 2024-04-08 00:37:25 +09: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
850887cf09 fileset: add basic pattern parsing functions
Naming convention is described in FilePattern::from_str_kind(). It's based
on Mercurial's pattern prefixes, but hopefully fixes some inconsistencies.
https://github.com/martinvonz/jj/issues/2915#issuecomment-1956401114

#3239
2024-04-07 19:43:29 +09:00
Yuya Nishihara
3c1d485452 revset: extract function that handles kind:"value" pattern syntax
I also removed comment about the error span. It's unclear whether the kind
was invalid or the value had syntax error.
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
Yuya Nishihara
3e029537c6 fileset: add basic AST-level object and matcher builder
FilesetExpression is similar to RevsetExpression, but there are two major
differences:
 - Union is represented as N-ary operator,
 - Expression node isn't Rc-ed.
The former is because of the nature of the runtime Matcher objects. It's easier
to construct a Matcher from flattened union expressions than from a binary tree.
The latter choice comes from UnionAll(Vec<FilesetExpression>), which doesn't
have to be Vec<Rc<FilesetExpression>>, and Rc<[FilesetExpression]> can't be
constructed from [Rc<_>, ..]. Anyway, the internal representation may change as
needed.

Another design decision I made is Vec<Pattern(RepoPathBuf)> vs
Pattern(Vec<RepoPathBuf>). I chose the former because it will be more closer
to the parsed tree of the fileset language.
2024-04-06 23:59:54 +09:00
Yuya Nishihara
7acfab695a matchers: impl custom Debug for RepoPathTree to get stable and concise output
The default Debug output entries aren't sorted by name, which was inconvenient
while writing snapshot tests.
2024-04-06 23:59:54 +09:00
Yuya Nishihara
c9b21a16be matchers: require Matcher to be Debug
This helps to write snapshot tests.
2024-04-06 23:59:54 +09:00
Yuya Nishihara
f3485c9efb repo_path: make Debug formatting of RepoPathComponent less verbose
Since RepoPath is formatted as a string, it should be okay for RepoPathComponent
to do the same.
2024-04-06 23:59:54 +09:00
Yuya Nishihara
1134dc159e repo_path: use write!() macro to implement Debug 2024-04-06 23:59:54 +09:00
Yuya Nishihara
0b833ea9c0 repo_path: qualify fmt::Error, use fmt::Result for short
"Error" is super common type name, so I think better to not pollute the
namespace with a very specific Error type.
2024-04-06 23:59:54 +09:00
Ilya Grigoriev
93cebcd0c0 protos: cargo update prost prost-builder and regenerate protobufs 2024-04-05 16:56:20 -07: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
Yuya Nishihara
a364310b56 matchers: add binary UnionMatcher
This will be needed to concatenate patterns of different types (such as
"prefix/dir" exact:"file/path".)

The implementation is basically a copy of IntersectionMatcher, with some
logical adjustments. In Mercurial, unionmatcher supports list of matchers
as input, but I think binary version is good enough.
2024-04-05 10:26:01 +09:00
Yuya Nishihara
c4d7425de5 matchers: abstract matcher combinators over Matcher trait
In order to implement a fileset, we'll need owned variants of these matchers.
We can of course let callers move Box<dyn Matcher> into these adapters, but
we might need to somehow clone Box<dyn Matcher>. So, I simply made adapters
generic.
2024-04-05 10:26:01 +09: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
Martin von Zweigbergk
361b4ca425 docs: use command with argument as example for ui.default-command
Makes it easier to figure out how to pass arguments.
2024-04-04 11:19:07 -07:00
Yuya Nishihara
a7d5a9c99a commit: actually remove boxing from CommitIteratorExt::ids()
Also simplified lifetime bound a bit.
2024-04-05 00:16:42 +09: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
Yuya Nishihara
69d38fbf96 docs: move new changelog entry to the unreleased section 2024-04-04 13:21:20 +09: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
Martin von Zweigbergk
2dcdc7fb3f release: release version 0.16.0
Thanks to everyone who's contributed!
2024-04-03 12:46:23 -07:00
dependabot[bot]
6826be4af9 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [strsim](https://github.com/rapidfuzz/strsim-rs) and [syn](https://github.com/dtolnay/syn).


Updates `strsim` from 0.11.0 to 0.11.1
- [Release notes](https://github.com/rapidfuzz/strsim-rs/releases)
- [Changelog](https://github.com/rapidfuzz/strsim-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rapidfuzz/strsim-rs/compare/v0.11.0...v0.11.1)

Updates `syn` from 2.0.57 to 2.0.58
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.57...2.0.58)

---
updated-dependencies:
- dependency-name: strsim
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-03 19:04:27 +02: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
Noah Mayr
b79984884d cli: only use default log revset when neither path nor revset is provided 2024-04-03 07:57:06 +02:00
Ilya Grigoriev
670e6ac62b cmd squash: alias --to for the --into flag
I keep typing `--to` since I'm used to `jj move` interface. It is
also shorter.

Currently, if I type `--to`, clap unhelpfully suggests whether I
meant `--tool`.
2024-04-02 18:32:39 -07:00
Yuya Nishihara
bb87fac1a4 revset: parse "all:" prefix rule by pest
I had to use negative lookahead !":" because we still support a dummy ":"
operator to provide a suggestion.
2024-04-03 08:59:42 +09:00
Yuya Nishihara
13dadadcdc revset: add ParseState constructor 2024-04-03 08:59:42 +09:00
Yuya Nishihara
acf8a8e1b2 cli: unblock "branch list --all-remotes" with name patterns
Like -r/--revisions, it should be okay to filter synced/non-tracking remote
branches by name.

conflicts_with_all = "tracked" is redundant, so removed as well. The tracked
field declares that it conflicts with --all-remotes.
2024-04-03 08:59:29 +09:00
Patric Stout
e5b9e8ff58 docs: "bash" is no longer optional for command-line completion 2024-04-02 09:30:44 -07:00
dependabot[bot]
6d02614d5c cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [pest](https://github.com/pest-parser/pest) and [pest_derive](https://github.com/pest-parser/pest).


Updates `pest` from 2.7.8 to 2.7.9
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.8...v2.7.9)

Updates `pest_derive` from 2.7.8 to 2.7.9
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.8...v2.7.9)

---
updated-dependencies:
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: pest_derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-02 11:28:02 -05:00
Yuya Nishihara
a5abd98076 cli: inline resolve_revset() to caller
There's only one caller, and the implementation is straightforward.
2024-04-02 15:17:12 +09:00