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

5275 commits

Author SHA1 Message Date
Ikko Eltociear Ashimine
96efc1224f docs: update README.md
minor fix.
2024-02-04 10:12:48 -06:00
Yuya Nishihara
99f0e7f844 cli: remove workaround for ": {source}" embedded in error message 2024-02-04 09:13:21 +09:00
Yuya Nishihara
77ceadbfd0 cleanup: remove remaining ": {source}" from error message templates 2024-02-04 09:13:21 +09:00
Yuya Nishihara
1efadd96c8 git: remove ": {source}" from FailedRefExportReason, walk chain by caller
The error output gets more verbose because all gix error sources are printed.
Maybe we'll need a better formatting, but changing to multi-line output doesn't
look nice either.
2024-02-04 09:13:21 +09:00
Yuya Nishihara
a0cefb8b7b revset, template: remove ": {source}" from parse error message template
These error types are special because the message is embedded in ASCII art. I
think it would be a source of bugs if some error types had ": {source}" but
others don't. So I'm going to remove all ": {source}"s, and let the callers
concatenate them when needed.
2024-02-04 09:13:21 +09:00
Ilya Grigoriev
d439de073d rewrite.rs: revert commits cfcc7c5e and becbc889
This mostly reverts https://github.com/martinvonz/jj/pull/2901 as well as its
fixup https://github.com/martinvonz/jj/pull/2903. The related bug is reopened,
see https://github.com/martinvonz/jj/issues/2869#issuecomment-1920367932.

The problem is that while the fix did fix #2869 in most cases, it did
reintroduce the more severe bug https://github.com/martinvonz/jj/issues/2760
in one case, if the working copy is the commit being rebased.

For example, suppose you have the tree

```
root -> A -> B -> @ (empty) -> C
```

### Before this commit

#### Case 1

`jj rebase -s B -d root --skip-empty` would work perfectly before this
commit, resulting in

```
root -> A
  \-------B -> C
           \- @ (new, empty)
```

#### Case 2

Unfortunately, if you run `jj rebase -s @ -d A --skip-empty`, you'd have the
following result (before this commit), which shows the reintroduction of #2760:

```
root -> A @ -> C
         \-- B
```

with the working copy at `A`. The reason for this is explained in
https://github.com/martinvonz/jj/pull/2901#issuecomment-1920043560.

### After this commit

After this commit, both case 1 and case 2 will be wrong in the sense of #2869,
but it will no longer exhibit the worse bug #2760 in the second case.

Case 1 would result in:

```
root -> A
  \-------B -> @ (empty) -> C
```

Case 2 would result in:

```
root -> A -> @ -> C
         \-- B
```

with the working copy remaining a descendant of A
2024-02-03 15:56:44 -08:00
Austin Seipp
f775a30cfa docs: update changelog with checkout/merge deprecations
Summary: Put both notices together at once, for ease of reading and
understanding.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I2aedb42fdab346b21990a106433512d7ec119ad4
2024-02-03 17:21:56 -06:00
Austin Seipp
7a7f76cbfb cli: deprecate jj merge
Summary: As discussed in Discord, on GitHub, and elsewhere, this change
deprecates the use of `jj merge` and suggests users use `jj new` exclusively
instead. `merge` isn't completely unfit as a name; but we think it obscures
the generality of `new` and we want people to use it instead.

To further drive the bit home, by default, `jj merge` is now hidden. This will
hopefully stop new users from running into it.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I94938aca9d3e2aa12d1394a5fbc58acce3185b56
2024-02-03 17:21:56 -06:00
Austin Seipp
3f13ea39e2 cli: deprecate jj checkout
Summary: As discussed in Discord, on GitHub, and elsewhere, this change
deprecates the use of `jj checkout` and suggests users use `jj new` exclusively
instead. The verb `checkout` is a relic of a bygone era the — days of RCS
file locking, before 3-way merge — and is not a good, fitting name for the
functionality it provides.

To further drive the bit home, by default, `jj checkout` (and `jj co`) is now
hidden. This will hopefully stop new users from running into it.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I7a1adfc9168fce1f25cf5d4c4c313304769e41a1
2024-02-03 17:21:56 -06:00
Austin Seipp
2a9e6fc610 cli: move tests from test_checkout -> test_new_command
These didn't really need to use `jj checkout`, and it will be deprecated in a
future change anyway. Move them out of there and into `new`.

Ideally this would go into `test_conflicts.rs`, but that exists in `jj-lib`, so
it doesn't have `TestEnvironment` available to it.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: If0173b27ab4d1f6036a4ec632ec77b6824f310c3
2024-02-03 17:21:56 -06:00
Benjamin Brittain
ae3404cdf2 chore: Bump yanked iana-time-zone crate 2024-02-03 15:22:07 -05:00
Essien Ita Essien
bcdb9beb6c cli: Move git_init() from init.rs to git.rs
* Move git_init() to cli/src/commands/git.rs and call it from there.
* Move print_trackable_remote_branches into cli_util since it's not git specific,
  but would apply to any backend that supports remote branches.
* A no-op change. A follow up PR will make use of this.
2024-02-03 15:06:09 +00:00
Essien Ita Essien
31e4061bab cli: Refactor out git_init() to encapsulate all git related work.
* Create a git_init() function in cli/src/commands/init.rs where all git related work is done.
  This function will be moved to cli/src/commands/git.rs in a subsequent PR.
2024-02-03 14:27:12 +00:00
Essien Ita Essien
8423c63a04 cli: Refactor workspace root directory creation
* Add file_util::create_or_reuse_dir() which is needed by all init
  functionality regardless of the backend.
2024-02-03 14:15:05 +00:00
Ilya Grigoriev
b3c47953e8 config.md docs: document jj config edit and jj config path
This changes the intro section to recommend using `jj config edit` to
edit the config instead of looking for the files manually.
2024-02-02 23:29:58 -08:00
Ilya Grigoriev
e9c482c017 docs: mention in jj help config edit that the command can create a file 2024-02-02 23:29:58 -08:00
Ilya Grigoriev
98948554f7 cli jj config: add jj config path command 2024-02-02 23:29:58 -08:00
Ilya Grigoriev
8a4b3966a6 test_global_opts: make test_version just a bit nicer when it fails 2024-02-02 23:19:25 -08:00
Ilya Grigoriev
42e6132771 test_global_opts: extract --version to its own test 2024-02-02 23:19:25 -08:00
dependabot[bot]
42c85b33c7 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [tokio](https://github.com/tokio-rs/tokio).


Updates `tokio` from 1.35.1 to 1.36.0
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.35.1...tokio-1.36.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-02 11:36:20 -06:00
dependabot[bot]
32c6406e5f github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [DeterminateSystems/magic-nix-cache-action](https://github.com/determinatesystems/magic-nix-cache-action).


Updates `DeterminateSystems/magic-nix-cache-action` from 1402a2dd8f56a6a6306c015089c5086f5e1ca3ef to eeabdb06718ac63a7021c6132129679a8e22d0c7
- [Release notes](https://github.com/determinatesystems/magic-nix-cache-action/releases)
- [Commits](1402a2dd8f...eeabdb0671)

---
updated-dependencies:
- dependency-name: DeterminateSystems/magic-nix-cache-action
  dependency-type: direct:production
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-02 11:36:07 -06:00
Daniel Ploch
01825953ac sparse-v2: design doc proposition for Sparse Patterns refactoring
Kicks off work on issue #1896
2024-02-01 16:02:14 -08:00
Yuya Nishihara
28dd0180ad cli: propagate WorkspaceLoadError::Path error transparently
The inner error message is now printed by default.
2024-02-02 08:22:24 +09:00
Yuya Nishihara
9adf6e1303 cli: remove "I/O error" prefix from the error message
It doesn't add much context, and looks worse with the new error formatting.
2024-02-02 08:22:24 +09:00
Yuya Nishihara
30666dfbcf cli: preserve source of user error, print source chain one by one
"Caused by" lines are inserted before the hint because they are more strongly
related to the error.
2024-02-02 08:22:24 +09:00
dependabot[bot]
fb6c834f59 cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [indexmap](https://github.com/indexmap-rs/indexmap), [libc](https://github.com/rust-lang/libc) and [rustix](https://github.com/bytecodealliance/rustix).


Updates `indexmap` from 2.2.1 to 2.2.2
- [Changelog](https://github.com/indexmap-rs/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/indexmap-rs/indexmap/compare/2.2.1...2.2.2)

Updates `libc` from 0.2.152 to 0.2.153
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.152...0.2.153)

Updates `rustix` from 0.38.30 to 0.38.31
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.30...v0.38.31)

---
updated-dependencies:
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: rustix
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-01 08:56:08 -08:00
Yuya Nishihara
526953cd87 cli: print "workspace root" without loading repo 2024-02-02 01:28:23 +09:00
Yuya Nishihara
818a885658 cli: map bare BackendError to internal error
The error message suggests that BackendError isn't a user error.
2024-02-01 16:59:44 +09:00
Yuya Nishihara
ca322b761a cli: print source chain of internal error in a similar way to anyhow
Multi-line output should be easier to follow than lengthy line separated by
colon.
2024-02-01 16:59:44 +09:00
Yuya Nishihara
a278059c64 cli: preserve source object of internal error
I'm going to rewrite the error output to print source chain one by one.

The "{message}: {err}" pattern is wrapped in an error struct. InternalError
variant could be a { message, source } pair, but not all errors need an
additional message. This will also apply to UserError.
2024-02-01 16:59:44 +09:00
Yuya Nishihara
8f118074fe cli: map bare io::Error to user error
Suppose the error is emitted from Ui or external command, I don't think
io::Error in CLI is an internal error.
2024-02-01 16:59:44 +09:00
Yuya Nishihara
ec0f2753ae repo: mark inner error of EditCommitError as source 2024-02-01 16:59:44 +09:00
Ilya Grigoriev
fa123bbfee docs: emphasize and clarify log revsets relevant to people coming from git
I couldn't come up with a Git analogue of `jj log`, but I think it's OK
leaving it as a TODO makes the point. Perhaps somebody can figure it
out.

Also, all the correspondences are not completely precise, so I didn't
emphasize it every single time.
2024-01-31 15:51:40 -08:00
Martin von Zweigbergk
7c87fe243c backends: implement as_any() on OpStore and OpHeadsStore too
It's useful for custom commands to be able to downcast to custom
backend types.
2024-01-31 00:15:29 -08:00
Ilya Grigoriev
cfcc7c5e34 test_rewrite: Fixup test comment after becbc88 2024-01-30 23:43:05 -08:00
Martin von Zweigbergk
9efa66e8c9 rewrite: remove return value from rebase_next()
`rebase_next()` returns an `Option<RebasedDescendant>`, but the only
way we use it is to decide whether to terminate the loop over
`to_visit`. Let's simplify by making the caller iterate over
`to_visit` instead.
2024-01-30 23:27:48 -08:00
Martin von Zweigbergk
881d75e899 rewrite: drop TODO about changing the API
The `rebase_next()` method is private, so I think we've addressed the
TODO.
2024-01-30 23:27:48 -08:00
Ilya Grigoriev
becbc88915 rewrite.rs: fix working copy position after jj rebase --abandon-empty
Fixes #2869
2024-01-30 22:53:55 -08:00
Ilya Grigoriev
1fff6e37a1 rewrite.rs DescendantRebaser: rename variable for clarity
The `edit` argument seems to be true if and only if the
old commit was *not* abandoned. So, I flipped its value
and renamed it to `abandoned_old_commit`.
2024-01-30 22:53:55 -08:00
Daniel Ploch
5326571cbd cli_util: allow extensions to run custom code before all commands 2024-01-30 22:47:52 -08:00
Yuya Nishihara
976b801208 index: on reinit(), delete all segment files to save disk space
Perhaps, reinit() will evolve to gc() function? It's basically a gc() with
empty operation set.
2024-01-31 09:40:52 +09:00
Yuya Nishihara
3d68601c01 index: remove redundant stat() of operation link file, handle error instead
This wouldn't matter in practice, but the operation link file could be deleted
after testing the existence.
2024-01-31 09:40:52 +09:00
Ilya Grigoriev
96d0e776ad docs: fixup to b318b200, mark code blocks in help as text
This prevents rust doctests from trying to compile the code blocks.

I don't think we use doctests much or at all, but I'd like
`cargo insta test --test-runner nextest --accept --workspace`
to pass.

Unfortunately, this affects the output of `jj help` as well, but I
can't think of a workaround for that.
2024-01-30 15:32:17 -08:00
Ilya Grigoriev
52c415eaf4 docs: store output of jj util markdown-help, render it on the website
I am using a very hacky approach, using `insta` to generate the markdown help.
This is based on a lucky coincidence that `insta` chose to use a header
format for snapshot files that MkDocs interprets as a Markdown header (and
ignores).

I considered several other approaches, but I couldn't resist the facts that:

- This doesn't require new developers to install any extra tools or run any
extra commands.
- There is no need for a new CI check.
- There is no need to compile `jj` in the "Make HTML docs" GitHub action,
  which is currently very fast and cheap.

Downside: I'm not sure how well MkDocs will work on Windows, unless the
developer explicitly enables symbolic links (which IIUC is not trivial).

### Possible alternatives 

My next favorite approaches (which we could switch to later) would be:

#### `xtask`

Set up a CI check and a  [Cargo `xtask`]  so that `cargo xtask cli-help-to-md`
essentially runs `cargo run -- util markdown-help > docs/cli-reference.md` from
the project root.

Every developer would have to know to run `cargo xtask cli-help-to-md` if
they change the help text.

Eventually, we could have `cargo xtask preflight` that runs `cargo +nightly
fmt; cargo xtask cli-help-to-md; cargo nextest run`, or `cargo insta`.

#### Only generate markdown for CLI help when building the website, don't track it in Git.

I think that having the file in the repo will be nice to preview changes to
docs, and it'll allow people to consult the file on GitHub or in their repo.

The (currently) very fast job of building the website would now require
installing Rust and building `jj`. 

#### Same as the `xtask`, but use a shell script instead of an `xtask`

An `xtask` might seem like overkill, since it's Rust instead of a shell script.
However, I don't want this to be a shell script so that new contributors on
Windows can still easily run it ( since this will be necessary for the CI to
pass) without us having to support a batch file.

#### Cargo Alias

My first attempt was to set up a [cargo alias] to run this, but that doesn't
support redirection (so I had to change the `jj util` command to output to a
file) and, worse, is incapable of executing the command *in the project root*
regardless of where in the project the current directory is. Again, this seems
to be too inconvenient for a command that every new PR author would have to run
to pass CI.

Overall, this just seems a bit ugly. I did file
https://github.com/rust-lang/cargo/issues/13348, I'm not really sure that was
worthwhile, though.

**Aside:** For reference, the alias was:
    
```toml
# .cargo/config.toml
alias.gen-cli-reference = "run -p jj-cli -- util markdown-help docs/cli-reference.md"
```

### Non-alternatives 

#### Clap's new feature

`clap` recently obtained a similarly-sounding feature in
https://github.com/clap-rs/clap/pull/5206. However, it only prints short help
for subcommands and can't be triggered by an option AFAICT, so it won't help us
too much.

[Cargo `xtask`]: https://github.com/matklad/cargo-xtask
[cargo alias]: https://doc.rust-lang.org/cargo/reference/config.html#alias
2024-01-30 14:58:32 -08:00
Ilya Grigoriev
b318b2009d cli help: add code blocks to make help render as markdown properly 2024-01-30 14:58:32 -08:00
Ilya Grigoriev
a197409b2b cli: new jj util markdown-help outputs jj help for all commands
This uses the [`clap-markdown`] library. It's not very flexible, but seems to
work. Its implementation is not difficult. If needed, we could later
reimplement the part that iterates over all subcommands and have a different
output (e.g., the boring version of each help text inside its own code block,
or a different file per subcommand, or some fancy template in handlebars or
another rust-supported templating language). I don't want to do it right now,
though.

The library does turn out to have some annoying bugs, e.g.
https://github.com/ConnorGray/clap-markdown/pull/18, but I think that's not a
deal-braker.  The fix seems to be 3 lines; if the fix doesn't get merged soon, we
could vendor the library maybe?

[`clap-markdown`]: https://docs.rs/clap-markdown/latest/clap_markdown/
2024-01-30 14:58:32 -08:00
Austin Seipp
6be5cf3dfc github: use macos-14, add new aarch64-apple-darwin release binary
GitHub announced these new Apple Silicon based runners today. Let's take them
for a spin.

Let's also add an entry in the release matrix to build and publish `aarch64-
apple-darwin` binaries, too. This doesn't migrate the old release matrix entry;
it still uses a `macos-11` runner. This means the x86 binaries should work on a
few older macOS versions if users need it.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-01-30 16:41:38 -06:00
Stephen Jennings
b2800f7f44 docs: add notes for Windows users 2024-01-29 12:16:15 -08:00
Philip Metzger
068f511b3f FAQ: Make a question clearer.
It seems that "amended" is not clear enough for users. So use simpler terms.

Suggestion from ilyagr in [Discord](https://discord.com/channels/968932220549103686/1201196831653236756/1201268055678931147).
2024-01-29 20:42:26 +01:00
dependabot[bot]
969db1b58d cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [indexmap](https://github.com/indexmap-rs/indexmap), [serde](https://github.com/serde-rs/serde) and [serde_json](https://github.com/serde-rs/json).


Updates `indexmap` from 2.1.0 to 2.2.1
- [Changelog](https://github.com/indexmap-rs/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/indexmap-rs/indexmap/compare/2.1.0...2.2.1)

Updates `serde` from 1.0.195 to 1.0.196
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.195...v1.0.196)

Updates `serde_json` from 1.0.111 to 1.0.113
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.111...v1.0.113)

---
updated-dependencies:
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 12:56:11 -06:00