Commit graph

4614 commits

Author SHA1 Message Date
Ilya Grigoriev
adc8433204 mkdocs: make MkDocs work with more GitHub-like list formatting
This adds two MkDocs extensions to make list handling more flexible.
It took some trial-and-error, but it seems this config works OK.

revsets.md: use saner formatting that is now possible.

sapling-comparison.md: this was the one case I saw made worse by the
new plugins. I changed the Markdown formatting, it still looks sane.
2023-11-03 19:15:37 -07:00
Antoine Cezar
5973ab47b9 commands: move rebase_to_dest_parent to jj_lib::rewrite
What make rebase_to_dest_parent a good candidate for jj_lib::rewrite module:

- It is used both in obslog and interdiff. It's a sign that it may be moved to a lower layer
- CommandError is returned by converting from TreeMergeError. Not explicitly.
- It only use jj_lib::rewrite fonctions.
2023-11-03 20:48:00 +01:00
dependabot[bot]
4f84c6b5d5 github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [actions/checkout](https://github.com/actions/checkout).

- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-03 15:58:00 +00:00
Austin Seipp
c1b6f2c666 github: automatically update flake.lock every week
Summary: Keeping the flake.lock up to date and 'fresh' is nice for
all the same reasons that apply to things like Cargo, Poetry, etc.

Unfortunately, dependabot doesn't have support for Nix flakes. There is also
no mechanism to add 'out of band' updates through dependabot, at least not yet.
Instead, we use the `update-flake-lock` action from Determinate Systems, which
can paper over it for us.

This updates once a week on Sunday, which is pretty fine, I think.

A theoretical downside of this approach is that we can't group updates together
like dependabot does; but dependabot only groups 'related' updates together,
i.e. updates to Cargo dependencies. If it also detected updates for e.g. Poetry
or Nix, it would make separate PRs for those.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I6f447deffc545da77fb320519abcf437
2023-11-03 10:34:16 -05:00
Martin von Zweigbergk
904c37d36d working copy: use MergedTree::diff_stream()
This will make it a little faster to update the working copy at Google
once we've made `MergedTree::diff_stream()` fetch trees
concurrently. (It only makes it a little faster because we still fetch
files serially.)
2023-11-03 08:15:10 -07:00
Martin von Zweigbergk
72245cfac5 merged_tree: add Stream-based version of diff(), delegating for now
I'm going to implement a `Stream`-based version optimized for
high-latency (RPC-based) commit backends. So far, that implementation
is about 20% slower in the Linux repo when running `jj diff
--ignore-working-copy -s --from v5.0 --to v6.0`. I think that's almost
only because the algorithm is different, not because it's async per
se.

This commit adds a `Stream`-based version of `MergedTree::diff()` that
just wraps the regular iterator in stream. I updated `jj diff` to use
it. I couldn't measure any difference on the command above in the
Linux repo. I think that means we can safely use the same
`Stream`-based interface regardless of backend, even if we end up
needing two different implementations of the `Stream`. We would then
be using the wrapped iterator from this commit for local backends, and
the new implementation for remote backends. But ideally we can make
the remote-friendly implementation fast enough that we don't need two
implementations.
2023-11-03 08:15:10 -07:00
Martin von Zweigbergk
24b706641f async: switch to pollster's block_on()
During the transition to using more async code, I keep running into
https://github.com/rust-lang/futures-rs/issues/2090. Right now, I want
to convert `MergedTree::diff()` into a `Stream`. I don't want to
update all call sites at once, so instead I'm adding a
`MergedTree::diff_stream()` method, which just wraps
`MergedTree::diff()` in a `Stream. However, since the iterator is
synchronous, it needs to block on the async `Backend::read_tree()`
calls. If we then also block on the `Stream` in the CLI, we run into
the panic.
2023-11-03 08:15:10 -07:00
Antoine Cezar
b7c480a575 commands: move show_predecessor_patch code to obslog.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
5d45bd194a commands: move workspace code to workspace.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
9e462509f8 commands: move version code to version.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
04eddc666c commands: move untrack code to untrack.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
9d72fa2a51 commands: move unsquash code to unsquash.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
8bb0383ad5 commands: move util code to util.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
abe658d966 commands: move status code to status.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
116214a79d commands: move squash code to squash.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
38898336a0 commands: move split code to split.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
6d0633443b commands: move sparse code to sparse.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
8f09fcc434 commands: move show code to show.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
6ae2e4c54f commands: move run code to run.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
e2336728da commands: move restore code to restore.rs 2023-11-03 04:45:55 +01:00
Austin Seipp
37d6e71f76 github: fix codespell skip syntax for directories
Summary: Codespell actually matches local files at the root of the repo with the
`./` prefix, so without it the `skip` field won't match. Fix this for `./target`
and `./.jj` directories.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ibeafd7e400ff3bca9187d62241296060
2023-11-02 15:37:26 -05:00
Philip Metzger
c783bbce6d FAQ: Add an entry on how Jujutsu saves changes in the working-copy.
This was brought up as a common point of confusion in a Discord discussion ~2 
months ago.
2023-11-02 20:29:06 +01:00
Martin von Zweigbergk
3a378dc234 cli: add a function for restoring part of a tree from another tree
We had similar code in two places for restoring paths from one tree to
another. Let's reuse it instead.

I put the new function in the `rewrite` module. I'm not sure if that's
right place. Maybe it belongs in `tree`?
2023-11-02 06:07:45 -07:00
Yuya Nishihara
162dcd49b4 cli: rewrite base GitIgnoreFile lookup to use gitoxide instead of libgit2
Since gix::Repository::config_snapshot() borrows the repo instance, it has to
be allocated in caller's stack. That's why GitBackend::git_config() is removed.
2023-11-02 19:33:06 +09:00
Yuya Nishihara
c88e69ad6f git_backend: replace git2::Repository with gix::Repository
My gut feeling is that gitoxide aims to be more transparent than libgit2. We'll
need to know more about the underlying Git data model.

Random comments on gix API:

 * gix::Repository provides API similar to git2::Repository, but has less
   "convenient" functions. For example, we need to use .find_object() +
   .try_to/into_<kind>() instead of .find_<kind>().
 * gix::Object, Blob, etc. own raw data as bytes. gix::object and gix::objs
   types provide high-level views on such data.
 * Tree building is pretty low-level compared to git2.
 * gix leverages bstr (i.e. bytes) extensively.

It's probably not difficult to migrate git::import/export_refs(). It might
help eliminate the startup overhead of libssl initialization. The gix-based
GitBackend appears to be a bit faster, but that wouldn't practically matter.

#2316
2023-11-02 19:33:06 +09:00
Yuya Nishihara
9a86b77e38 tests: force gitoxide to not load config nor use "main" as default branch
AFAIK, there's no global config state for gitoxide. We can use
Config::isolated() in tests, but GitBackend should load config files in a
normal way.

https://docs.rs/gix/0.55.2/gix/open/permissions/struct.Config.html#method.isolated
https://docs.rs/gix/0.55.2/gix/init/constant.DEFAULT_BRANCH_NAME.html
2023-11-02 19:33:06 +09:00
Yuya Nishihara
f5a61dc2b7 git_backend: open just-initialized repo with canonicalized path
Otherwise, the initialized repo could have a different work-dir path than the
load()-ed one. libgit2 appears to do some normalization somewhere, but gix
won't.
2023-11-02 19:33:06 +09:00
Yuya Nishihara
fd187d266f git_backend: box GitBackendInit/LoadError up front
These error enums will wrap gix error types, and will become bigger enough for
clippy to complain.
2023-11-02 19:33:06 +09:00
Yuya Nishihara
b48569b104 cargo: add gitoxide (or gix) dependency
I've enabled the "index" component from the "basic" feature set, which would
be needed to implement colocated repo functionality. The doc suggests that
a library shouldn't activate "max-performance-safe", but our crate is also
an application so it would be okay to enable the feature. We'll need "parallel"
anyway to make GitBackend Sync.

https://docs.rs/gix/latest/gix/#feature-flags
2023-11-02 19:33:06 +09:00
Martin von Zweigbergk
46a8afe144 formatter: reset colors on early drop
If we create a `ColorFormatter`, add some labels to it, print
something using the configured style, and then return early because of
an error, we would leave the terminal in a bad state. I think many
shells reset color codes after a command returns, but let's still do
our best.
2023-11-01 21:41:25 -07:00
Ilya Grigoriev
2f6cce1e4f Fix 0.11 title in CHANGELOG.md
As reported by several people on Discord.
2023-11-01 19:05:25 -07:00
Martin von Zweigbergk
f00f7527dd release: release version 0.11.0
Thanks to everyone who's contributed!
2023-11-01 11:08:44 -07:00
dependabot[bot]
9e523cd218 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [indexmap](https://github.com/bluss/indexmap).

- [Changelog](https://github.com/bluss/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/bluss/indexmap/compare/2.0.2...2.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-01 08:39:59 -07:00
Yuya Nishihara
f89f2f9e7d cli: add "branch list [NAMES]..." filter
Like "jj log PATHS...", unmatched name isn't an error. I don't think
"jj branch list glob:'push-*'" should fail just because there are no in-flight
PR branches.
2023-11-01 08:38:55 -07:00
Isabella Basso
749d8bb15a git: preserve HEAD when possible
Closes: #2210
2023-11-01 08:23:52 -03:00
Tal Pressman
6b1217ec6d add FAQ for divergent changes 2023-11-01 16:55:57 +09:00
Ilya Grigoriev
0df851e6e2 glossary.md: Add a stub for "Hidden commits, Abandoned commits" 2023-10-31 23:41:41 -07:00
Ilya Grigoriev
c79920095b glossary.md: Clarify description of "visible commits" 2023-10-31 23:41:41 -07:00
Ilya Grigoriev
4c490d2ca9 revsets.md: correct description of "visible commits" 2023-10-31 23:41:41 -07:00
Ilya Grigoriev
d2c2c270f8 cli rebase: Move misplaced paragraph, fixup to 8bc3f5fd67 2023-10-31 18:57:02 -07:00
Ilya Grigoriev
a3f21f7a9d revsets.md: clarify string patterns and file patterns
I had to increase indent on two list items for multiple paragraphs to work in
MkDocs.
2023-10-31 17:49:49 -07:00
dependabot[bot]
02f728277f cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [serde_json](https://github.com/serde-rs/json).

- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.107...v1.0.108)

---
updated-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>
2023-10-31 15:54:17 +00:00
Ilya Grigoriev
38daa9abe3 install-and-setup.md: Document binary installation with cargo-binstall
I also mentioned this in the changelog, since people reading it are more likely
to use `binstall` than most.
2023-10-30 15:12:23 -07:00
Ilya Grigoriev
2cd262def3 install-and-setup.md: Make headings more consistent 2023-10-30 15:12:23 -07:00
Yuya Nishihara
1788b5014e git_backend: remove redundant copy back of author timestamp
Only the committer timestamp can be updated inside a loop.
2023-10-31 06:51:27 +09:00
Yuya Nishihara
f5aa739c70 git_backend: use .strip_suffix() instead of manual slicing 2023-10-31 06:51:27 +09:00
Yuya Nishihara
9bd84c55e0 git_backend: use file mode extensively in read_tree()
Both filemode() and kind() are calculated from the same underlying data,
and kind() is libgit2-specific API.
2023-10-31 06:51:27 +09:00
Yuya Nishihara
b3c9cab12d git_backend: handle read_tree() lookup/encoding errors gracefully 2023-10-31 06:51:27 +09:00
Yuya Nishihara
847adc832f git_backend: use lossy conversion to decode non-UTF-8 commit message
If message() returned None, it doesn't mean the commit message is empty. I
originally mapped it to an error, but that made import of linux repo fail.

https://docs.rs/git2/latest/git2/struct.Commit.html#method.message
2023-10-31 06:51:27 +09:00
Yuya Nishihara
06c254e742 git_backend: use non-owned str::from_utf8() to decode symlink target
Just for consistency with the other changes. str::Utf8Error is 2 words long,
so I removed the boxing.
2023-10-31 06:51:27 +09:00