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

5848 commits

Author SHA1 Message Date
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
Yuya Nishihara
5d09234839 cli: don't check duplicates in revisions prefixed with "all:"
Since "all:" implies that the user doesn't care about the order of the
revisions within that argument, it should be okay if two "all:" sets overlapped.
2024-04-02 15:17:12 +09:00
Yuya Nishihara
c3fa13e761 cli: inline resolve_revset_default_single() 2024-04-02 15:17:12 +09:00
Yuya Nishihara
4f0c52d828 cli: extract parsing part of resolve_single_rev_with_hint_about_all_prefix()
Yet another step towards inlining resolve_revset_default_single(). I'll
reimplement parse_revset_with_all_prefix() later to be pest-based.
2024-04-02 15:17:12 +09:00
Yuya Nishihara
a8c4e0ecbd cli: move resolve_multiple_nonempty_revsets_default_single() to command helper
resolve_revset_default_single() will be inlined instead. Since "default_single"
evaluation can return multiple revisions, the CLI interface usually accepts
multiple arguments. This suggests that there would be no external callers of
the singular resolve_revset_default_single().
2024-04-02 15:17:12 +09:00
Yuya Nishihara
0c4f4c8767 cli: extract evaluation part of resolve_single_rev_with_hint_about_all_prefix()
I'm going to reorganize "single"/"default_single" revset functions in a way
that resolve_single_rev_with_hint_about_all_prefix() is inlined.
evaluate_revset_to_single_commit() could be a private method of
WorkspaceCommandHelper, but I want to minimize the code that has to be hosted
there.
2024-04-02 15:17:12 +09:00
Yuya Nishihara
f04402e3c7 cli: extract function that creates "not a single revision" error
This function isn't small, so let's split up into two parts. The extracted
function is the part which depends on the commit summary template.
2024-04-02 15:17:12 +09:00
Christoph Koehler
7bde6ddc29 revset: add working_copies() function
It includes the working copy commit of every workspace of the repo.

Implements #3384
2024-04-01 19:36:53 -06:00
Evan Mesterhazy
ebe8e6adba Update jj split tests to show what happens to branches
When a commit is split, any branches pointing to it are moved to the second
commit created by the split. This is true even if the --siblings option is
used.


#3419
2024-04-01 21:19:29 -04:00
Evan Mesterhazy
976320726d Add a --siblings option to the jj split command
If the --siblings option is used, the target commit is split into two sibling
commits instead of parent and child commits. Any children of the original
commit will have both siblings as their new parents.


#2274
2024-04-01 19:22:47 -04:00
Evan Mesterhazy
c3ee86d92a Split rebase_descendants into two functions
This refactor will allow us to reuse new `rebase_descendants` function for the
`jj split --siblings` feature (#2274) and later possibly for `jj parallelize`
(#1079).
2024-04-01 19:22:47 -04:00
Martin von Zweigbergk
7b3f8e8cb6 resolve: remove --quiet flag, rely on global one 2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
adf3b50209 cli: add a global --quiet flag, which silences status messages
Note that `jj resolve` already had its own `--quiet` flag. The output
with `--quiet` for that command got a lot quieter with the global
`--quiet` also taking effect. That seems reasonable to me.
2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
4962d9af3b ui: make hint_*() methods return Option
Same reasoning as the previous patch: we can avoid doing work when
`--quiet` is passed.
2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
e38e2904bb ui: make status() return a dyn Write, add status_formatter()
When the caller needs a formatter, it's because they're doing
something non-trivial. When the user passed `--quiet` (see upcoming
patch), we should ideally skip doing related work for print the
formatting output. It helps if the `Ui` object doesn't even return a
`Formatter` then, so the caller is forced to handle the quiet case
differently.

Thanks to Yuya for the suggestion.
2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
b940f1a092 errors: don't use the ui.hint*() helpers
I'm about to make hints not get printed with `--quiet`, but error
hints are probably still useful to get. They shouldn't be a problem
for scripts since the script would have to deal with the error anyway.
2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
aeaab8aad3 cli: add a Ui::status() helper for writing non-error to stderr
This clarifies that status messages are not errors, and allows us to
implement a global `--quiet` flag for silencing status messages.
2024-04-01 13:00:27 -07:00
dependabot[bot]
2dc95bb18b cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [minus](https://github.com/arijit79/minus) and [syn](https://github.com/dtolnay/syn).


Updates `minus` from 5.6.0 to 5.6.1
- [Changelog](https://github.com/arijit79/minus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/arijit79/minus/compare/v5.6.0...v5.6.1)

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

---
updated-dependencies:
- dependency-name: minus
  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-01 15:21:10 +00:00
Simon Wollwage
320f50e00f cli: rename --all to --all-remotes for branch list 2024-04-01 10:12:13 +09:00
Yuya Nishihara
6004efb3b2 cli: replace last use of evaluate_revset() with evaluate_programmatic()
evaluate_programmatic() should be allowed here. AFAIK, the contract is that
the expression should never contain any bare symbols and "fallible" symbol-like
expressions, which doesn't apply to branches() and remote_branches() functions.

evaluate_revset() is removed because there are no callers. However, it's simple
and basic function, so we might want to reintroduce it if needed.
2024-04-01 10:08:44 +09:00
Yuya Nishihara
b3d3b26656 cli: make check_rewritable() not evaluate revset to commit objects 2024-04-01 10:08:44 +09:00