Commit graph

9789 commits

Author SHA1 Message Date
Michael Chirico
aa2cbec029 user-friendliness: hint at lack of access as a possible reason to error 2025-09-22 22:20:42 +00:00
Benjamin Tan
b70a12e2db docs: standardize usage of term "colocate" without the hyphen
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
The hyphen-less version is preferred since there are already existing
command flags and config options which use the hyphen-less variation.
2025-09-05 16:32:25 +00:00
Austin Seipp
5b83c9899c cli, lib: convert revset expressions to use Arc over Rc
We want these to be `Send` and `Sync` so we can send them between
threads in our multi-threaded backend. This requires a bunch of subsequent
(but obvious) changes throughout cli and the tests.

Co-authored-by: Benjamin Brittain <ben@ersc.io>
Signed-off-by: Austin Seipp <austin@ersc.io>
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-09-05 16:09:44 +00:00
Martin von Zweigbergk
ba60fe1c61 revset: require SymbolResolverExtension to be Send and Sync
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
This will make `RevsetExtensions` also `Send` and `Sync`, which the
CLI crate already kind of assumes since it stores `RevsetExtensions`
in an `Arc`.
2025-09-05 11:25:22 +00:00
Yuya Nishihara
760ab75c5e formatter: make push/pop_label() never fail
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
This will help implement Drop for labeled formatter guard.
2025-09-05 03:40:29 +00:00
Yuya Nishihara
6a70a9bdb9 formatter: emit pending color sequence on flush() instead of pop_label()
formatter.with_label(..) API is getting complicated, and I'm thinking of
replacing .with_label*() functions with .labeled() that will do .pop_label() on
Drop.

This patch means that the last escape sequence is more likely emitted by Drop,
which is less reliable. However, in practice, output payload is terminated by
newline, and therefore, reset sequence would have been emitted by write().
Ignoring io::Error in Drop wouldn't be horrible either since subsequent write()
on the same stream would likely fail.
2025-09-05 03:40:29 +00:00
Yuya Nishihara
4dee8e46ce conflicts: compare new hunks without fully materializing original to text
It seemed odd that we had to pass ConflictMarkerStyle to snapshot functions.
Suppose materialize/parse functions aren't lossy, we can compare hunks in
Vec<Merge<BString>> form. This should also be robust for configuration changes.

test_materialize_parse_roundtrip_different_markers() is simplified as there
should no longer be "pair" of marker styles.
2025-09-05 00:39:41 +00:00
Yuya Nishihara
0b34bb31a6 tests: add test for unchanged conflict in working copy
This test would fail if we removed comparison of materialized contents from
conflicts::update_from_content().
2025-09-05 00:39:41 +00:00
Yuya Nishihara
9f69c58233 cli: help: look up subcommand without using error path
It's odd that cmd_help() returns an error for valid arguments. Let's look up the
target command explicitly. We still need to do app.try_get_matches_from_mut() to
initialize clap::Command internals, though.
2025-09-05 00:26:12 +00:00
Martin von Zweigbergk
da6c4b61b3 backend: remove unused TreeValue::Conflict and read/write methods
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
We no longer use the `TreeValue::Conflict` constructor or the
`Backend::read_conflict()` and `Backend::write_conflict()` methods.
2025-09-04 16:26:44 +00:00
Martin von Zweigbergk
ea2b53b4ca git_backend: drop support for reading conflicts
We haven't written legacy/path-level conflicts since jj 0.11 (Nov
2023). This patch makes the Git backend return legacy conflicts as the
regular JSON-containing files they are represented by.
2025-09-04 16:26:44 +00:00
Martin von Zweigbergk
5f3269db2b git_backend: drop support for writing TreeValue::Conflict
We haven't had any code that produces these values in a long time.
2025-09-04 16:26:44 +00:00
Martin von Zweigbergk
5f7f4318a0 working_copy: drop support for legacy trees
Legacy trees (those with conflicts recorded at the path level) have
not been created since 0.11 (Nov 2023). We're about to deprecate them
now. This patch removes support for them in the working copy. If
anyone still has a commit checked out at a legacy tree, we will now
interpret that as a modern tree, meaning that any conflicts will
appear as regular files with JSON contents in the previous snapshot,
so if we re-snapshot the working copy (and e.g. the mtime has
changed), these files will become resolved with the conflicts markers
still in them.

I think it's quite unlikely that anyone has working copies this old so
I didn't mention it in the changelog.
2025-09-04 16:26:44 +00:00
Martin von Zweigbergk
d0913449d0 simple_store: drop support for legacy trees
Users should not be using the simple backend for anything serious, and
they definitely should not have any repos from back when we used
legacy trees.
2025-09-04 16:26:44 +00:00
Reilly Brogan
1080396831 cli: Default to nano editor on Linux
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
The pico text editor is effectively absent from the majority of Linux
distributions, having been replaced with nano by virtually all of them.
Some distros have symlinks for `pico` that point to `nano`, but not all
of them. Using nano as the fallback option has a much lower chance of
failure than pico.

Co-authored-by: Remo Senekowitsch <remo@buenzli.dev>
2025-09-04 14:52:36 +00:00
Martin von Zweigbergk
c15cc344de cli: add jj bisect run command
This adds a command that automatically bisects a range of commits
using a specified command. By not having the interactive kind
(e.g. `jj bisect good/bad/skip/reset`), we avoid - for now at least -
having to decide where to store the state. The user can still achieve
interactive bisection by passing their shell as the bisection command.

Closes #2987.
2025-09-04 14:30:52 +00:00
Martin von Zweigbergk
720b8cc114 bisect: add library for running bisection
I plan to add a `jj bisect run --range REVSET --command COMMAND` that
uses this library.
2025-09-04 14:30:52 +00:00
Remo Senekowitsch
ec5c135387 git: colocate repos by default
Closes https://github.com/jj-vcs/jj/issues/7189

Colocated repos have some advantages and some disadvantages. On the
whole, I think making Git repos colocated by default is a better
trade-off, especially for new users. With the `git.colocate` setting,
(experienced) users can easily change this according to preference.

A non-exhaustive list of pros and cons of colocated repos:

pros:
* Many code editors show the changes one is currently working on based
  on Git's "dirty worktree".
* There are a lot of tools that integrate with Git which don't work at
  all in non-colocated repositories.
* There are a lot of Git features that Jujutsu doesn't have yet. When
  users ask for them, the answer is usually: "Just colocate your repo
  and run git directly for now." It's a strength that Jujutsu can focus
  on what makes it special and not have to rush the reimplementation of
  every niche feature of Git. Examples: `git rebase` tracking file
  renames, `git bisect`, `git tag`, `git range-diff`, submodules.

cons:
* Jujutsu performs worse in colocated repositories with lots of refs,
  because of the automatic `jj git import`.
* Colocated repos make branch@git references show up in Jujutsu output,
  which is usually just aesthetically displeasing or possibly even
  confusing to inexperienced users.
* Interleaving jj and (mutating) git commands can lead to confusing
  situations. Examples:
  * Creating a commit with git instead of jj will often leave a
    duplicate "work in progress" commit in Jujutsu's log.
  * Some IDEs periodically run `git fetch` in the background. This can
    lead to conflicted branches and divergent change IDs, something many
    people struggle with.
2025-09-04 11:26:28 +00:00
Gaëtan Lehmann
1e1decb594 dev: add mise config
The [vars] section is used to define the tool versions, and the tools
are only declared in each task in order to be able to run a task and
install only the required dependencies. This way

  mise build:docs

only install the docs dependencies, but not the rust toolchain.

The task are organized hierarchically, allowing to run all of the tasks
in a category, for example with

  mise run "check:*"

Some aliases for the most common tasks are defined in order to keep the
command line short and easy to type. For example use

  mise test squash

to run all the squash tests.

Co-authored-by: Emily <artyom@artyom.me>
2025-09-04 08:33:03 +00:00
Austin Seipp
24f4e1083e release: 0.33.0
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-09-04 02:53:09 +00:00
Benjamin Tan
ba889a73df docs: improve description of different completion scripts
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-09-03 17:35:05 +00:00
Martin von Zweigbergk
24f7c761a5 metaedit: add option to update committer timestamp 2025-09-03 15:31:43 +00:00
Martin von Zweigbergk
dd7dc11fa9 metaedit: don't rewrite commits if nothing changed 2025-09-03 15:31:43 +00:00
Martin von Zweigbergk
d9730ffd72 metaedit: move rewriter.reparent() call inside if/else arms
This is just a tiny refactoring to prepare for making the command not
rewrite commits if nothing changed.
2025-09-03 15:31:43 +00:00
Martin von Zweigbergk
be6457321d metaedit: remove redundant check for error code
The status code is already tested as part of the `CommandOutput`.

Also rename variable of type `CommandOutput` to more standard
`output`.
2025-09-03 15:31:43 +00:00
Martin von Zweigbergk
f82975614f cli: rename jj touch to jj metaedit
There were some concerns that `touch` only makes sense if you're
familiar with the Unix `touch` command. I think that's a fair
concern. I did not hear any objections to renaming the command. If
we're going to do it, we should do it now, so it doesn't ever get
released under the old name.
2025-09-03 15:31:43 +00:00
Ian Wrzesinski
ee6ae0662a working_copy: Add WorkingCopyStateError conversions for ergonomics
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Note that the actual error message is almost always the same. They all end up
with the message "Failed to read working copy state" in `tree_state`. So the
original code adding another equivalent message is unnecessary.
2025-09-03 13:19:12 +00:00
Yuya Nishihara
1cd6f9f6a8 conflicts: pack marker style/len into struct, merge materialize functions
I'm thinking of adding an option to do word-by-word merging, which will be pass
down to files::merge_hunks() through materialize_merge_result*(). Since tree
merging should also respect this option, it will be carried by the Store, and
copied to ConflictMaterializeOptions.
2025-09-03 09:34:44 +00:00
Martin von Zweigbergk
c6e4711928 working_copy: mark unused conflict_id proto field reserved
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
The field has been unused since it was deprecated in 97b81a0f (~2
years ago). It should have been marked reserved instead of deprecated
already then.
2025-09-03 05:47:08 +00:00
Ilya Grigoriev
566478c7b0 paid contributors: add myself as a newly minted ERSC employee
🎉
2025-09-03 02:10:36 +00:00
Ian Wrzesinski
f3d41b1826 working_copy: Move conlfict_marker_styles to TreeState 2025-09-03 00:40:52 +00:00
Ian Wrzesinski
f882681dd8 working_copy: Simplify Eol loading in TreeState init functions 2025-09-03 00:40:52 +00:00
Martin von Zweigbergk
6a22e9acbd governance: add Benjamin Tan and Scott Taylor as maintainers
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Copying from Discord:

@ilyagr recently accepted a job offer from East River Source Control
(ersc.io). That means we will have two of the five maintainers from
that company (@thoughtpolice is the other one), which is more than the
1/3 that our policy allows
(https://github.com/jj-vcs/jj/blob/main/GOVERNANCE.md#single-company-influence). To
resolve it, we decided to add more maintainers. We're happy to
announce that both @bnjmnt4n and @scott2000 have agreed to join. Thank
you!
2025-09-02 21:08:49 +00:00
Jade Lovelace
735a27d4ef templates: add string.match function
This allows for any matcher type and allows extracting a capture group
by number.
2025-09-02 02:19:54 +00:00
Jade Lovelace
30bb37967d templates: support string patterns in template language
This is a basic implementation of the same string pattern system as in
the revset language. It's currently only used for `string.matches`, so
you can now do:

```
"foo".matches(regex:'[a-f]o+')
```

In the future this could be added to more string functions (and e.g.
the ability to parse things out of strings could be added).

CC: https://github.com/jj-vcs/jj/issues/6893
2025-09-02 02:19:54 +00:00
Jade Lovelace
17127219fb templates: improve rustdocs 2025-09-02 02:19:54 +00:00
Yuya Nishihara
b5c5a442e5 working_copy: set MaterializedConflictData by caller of write_conflict()
Since file stats and conflict metadata are calculated from different sources,
it's simpler to initialize FileState without MaterializedConflictData.
2025-09-02 00:52:13 +00:00
Yuya Nishihara
3654b8ba19 working_copy: pass slice to write_conflict(), rename variables
It seemed confusing that we had "conflict_data" as file content, and
MaterializedConflictData as metadata.
2025-09-02 00:52:13 +00:00
Matt Stark
c1641c6e52 clippy: Add needless_lifetimes lint.
When I run the same command as CI, `cargo +stable clippy --all-features --workspace --all-targets -- -D warnings` I previously got errors such as:

```
error: the following explicit lifetimes could be elided: 'a
   --> cli/src/operation_templater.rs:365:6
    |
365 | impl<'a, L: ?Sized, P> OperationTemplateBuildFnTable<'a, L, P> {
    |      ^^                                              ^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
    = note: `-D clippy::needless-lifetimes` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]`
help: elide the lifetimes
    |
365 - impl<'a, L: ?Sized, P> OperationTemplateBuildFnTable<'a, L, P> {
365 + impl<L: ?Sized, P> OperationTemplateBuildFnTable<'_, L, P> {
    |
```

This fixes the errors that I'm getting locally, and also enables the
same lints on CI.
2025-09-02 00:30:58 +00:00
Ivan Petkov
032fd44b02 docs: update comment about simple fetch refspecs being respected
Now that https://github.com/jj-vcs/jj/pull/7275 has merged it's worth
mentioning that simple fetch refspecs will (now) be respected when other
branches are otherwise not specified on the CLI
2025-09-01 14:29:42 +00:00
Remo Senekowitsch
1fa53c6a4f config-schema: add --when and --scope keys 2025-08-30 21:31:39 +00:00
dependabot[bot]
5ff828bf5b cargo: bump tracing-subscriber from 0.3.19 to 0.3.20
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.3.19 to 0.3.20.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.3.19...tracing-subscriber-0.3.20)

---
updated-dependencies:
- dependency-name: tracing-subscriber
  dependency-version: 0.3.20
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-29 23:53:20 +00:00
Josh Steadmon
f5e77069f3 merge: fix formatting in Merge method doc comments
Rustdoc was losing the formatting of the merge diagrams in
`Merge::flatten()`'s doc comment; preserve it with an HTML `<pre>`
block.

Also remove a stray backtick that broke formatting in
`Merge::to_file_merge()`'s doc comment.
2025-08-29 17:43:01 +00:00
Remo Senekowitsch
5947632027 config: use schema directive comment
Tombi is an LSP that complains about the "$schema" key, because it
itself is not actually part of our schema. Taplo is another LSP that
can read this comment directive. Using a comment seems generally more
appropriate. Syntax highlighting makes comments usually less visible,
indicating that the directive is not actually part of the configuration
data.
2025-08-29 14:52:30 +00:00
Yuya Nishihara
5f8ffd3e20 templater: relax whitespace requirement by leveraging implicit whitespace rule
This means `f ()`, `x . f()`, etc. are now allowed. Before, `x\n.f()` was syntax
error, which seemed unintuitive in multi-line expression.

This also means that whitespace around alias declaration is ignored.
tempalte-aliases.' foo ' is identical to tempalte-aliases.foo.

https://pest.rs/book/grammars/syntax.html#implicit-whitespace

Closes #7378
2025-08-29 10:21:37 +00:00
Ilya Grigoriev
ba2d3b730c undo/redo cli docs: add details about new behavior
I considered adding more details, but ultimately decided to err on the
side of brevity. We could later write a short doc detailing the behavior
(see the comments in the source) and point the CLI docs to it.

For now, I tried to explain the smallest mental model the users should
have in mind to feel comfortable with these commands.

Since `jj redo` is the command that really makes the notion of an "undo
stack" tick, I only mentioned that notion in there.

Follows up on #7293 and #7277
2025-08-29 05:37:46 +00:00
Ilya Grigoriev
300f761749 changelog: move jj redo as the first new feature
A lot of breaking changes and deprecations are about `undo`, so it feels right
to mention `redo` soon after. We often rearrange the changelog during a release,
but this stood out to me, so why not do it now.
2025-08-29 05:37:46 +00:00
Stephen Jennings
72df6a5167 docs: Recommend unhiding revisions in the accidental changes FAQ
After a change has been accidentally modified, the user may want to
recover the original revision with the same commit ID if it was pushed
to a remote, not just restore the original contents.

Instead of using `jj restore` to restore contents, recommend using `jj
new <PREVIOUS_ID>` to unhide the original commit. This strategy works
whether or not the user cares about the original commit ID.
2025-08-29 05:30:42 +00:00
Yuya Nishihara
42f645ed28 file_util: insert fdatasync() before persisting temporary files
This implements the steps 3-4 described in "When Should You Fsync?"
https://lwn.net/Articles/457667/

With my testing on Linux VM, persisted op_store file names (or directory entry)
can occasionally lost as well as op_heads entries. We can insert fsync(dir_fd)
to fix these, but then we'll get data corruption somewhere in Git object store.
Since Git/gix writes small files more frequently, I don't think we can easily
address the problem at gix side. I think the current state is not that bad as we
can recover from corruption relatively easily if the op_store contents are
valid.

I had this patch for months, and I didn't find any significant performance
degradation.

#4423
2025-08-29 01:30:43 +00:00
Yuya Nishihara
12f0551842 file_util: add thin wrapper over NamedTempFile::persist()
I'll insert fdatasync() there.
2025-08-29 01:30:43 +00:00