Commit graph

4964 commits

Author SHA1 Message Date
Yuya Nishihara
7a44e590dc lock: remove byteorder dependency from tests, use fs helper functions
This is the last use of Read/WriteBytesExt. The byteorder crate is great, but
we don't need an abstraction of endianness. Let's simply use the std functions.
2023-12-23 00:14:17 +09:00
Yuya Nishihara
9de6273e10 index, stacked_table: inline read_u32::<LittleEndian>()
There aren't many callers of ReadBytesExt::read_u32().
2023-12-23 00:14:17 +09:00
Yuya Nishihara
21c22be96e stacked_table: use u32::from_le_bytes() to reinterpret bytes as integer
Apparently, I forgot to update this in fb06e89649.
2023-12-23 00:14:17 +09:00
Yuya Nishihara
6f5096e266 index, stacked_table: use u32::try_from() instead of numeric cast
These .unwrap()s wouldn't be compiled out, but I don't think they would
have measurable impact. Let's use the safer method.
2023-12-22 09:03:50 +09:00
Yuya Nishihara
9ec89bcf86 index, stacked_table: use u32::to_le_bytes() to reinterpret as bytes 2023-12-22 09:03:50 +09:00
Yuya Nishihara
392539fa29 index, stacked_table: simply extend Vec<u8> to not use .write_all()
I'm going to remove use of .write_u32() there. It's not super important, but
fewer .unwrap()s, the code looks slightly better.
2023-12-22 09:03:50 +09:00
Yuya Nishihara
fb06e89649 index: use u32::from_le_bytes() to reinterpret bytes as integer
It's less abstract than going through io::Read, so is probably easier for
compiler to optimize out. I also feel it's a bit more readable.
2023-12-22 09:03:50 +09:00
Austin Seipp
889f052dfa readme: do some cleanup
As noted by Martin and Waleed on Discord.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I9cba734774a7e89dfd65c8202e76c2f4
2023-12-21 16:26:17 -06:00
dependabot[bot]
04f9440872 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [anyhow](https://github.com/dtolnay/anyhow) and [async-trait](https://github.com/dtolnay/async-trait).


Updates `anyhow` from 1.0.75 to 1.0.76
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.75...1.0.76)

Updates `async-trait` from 0.1.74 to 0.1.75
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.74...0.1.75)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: async-trait
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-21 08:07:54 -08:00
Yuya Nishihara
5bf9e4192a cli: don't look for added/removed conflicts across old/new heads
removed_heads..added_heads won't stop if new head is added on top of non-head
commit for example.

#2729
2023-12-21 23:40:52 +09:00
Gabriel Scherer
dafc900cca git comparison: include a 'git grep' equivalent 2023-12-21 00:20:45 +01:00
Gabriel Scherer
fad511a6e5 document the use of JJ_USER and JJ_EMAIL in combination with --reset-author
Suggested-by: David Barnett <dbarnett@google.com>
2023-12-21 00:20:45 +01:00
dependabot[bot]
cf3db53ea7 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.0 to 1.35.1
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.35.0...tokio-1.35.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-21 08:06:02 +09:00
Yuya Nishihara
38ce914321 index: reindex on content-related I/O errors
If read_exact() or read_u32() reached to EOF, the index file should be
considered corrupted. File not found error is also treated as data corruption
because an invalid file name could be read from the child segment file. It
can't handle special file names like "..", though.
2023-12-21 08:05:30 +09:00
Yuya Nishihara
e98104d6f0 index: add file name to both io/corrupt errors, combine these variants
Index file name also applies to io::Error. New error type reuses io::Error to
represent data corruption. We could add an inner Corrupt|Io enum instead, but
we'll need to remap some io::Error variants (e.g. UnexpectedEof) to Corrupt
anyway.
2023-12-21 08:05:30 +09:00
Yuya Nishihara
88f3085bb1 index: extract function that opens file and loads index segments 2023-12-21 08:05:30 +09:00
Yuya Nishihara
eccb9b7a44 index: propagate index load errors from DefaultIndexStore 2023-12-19 07:41:57 +09:00
Yuya Nishihara
dd8e686127 index: don't reload parent files after saving new segment file
This should be cheaper, and more importantly, we no longer need to propagate
ReadonlyIndexLoadError to the caller.
2023-12-19 07:41:57 +09:00
Yuya Nishihara
fb07749291 index: split load function into header and local parts as well 2023-12-19 07:41:57 +09:00
Yuya Nishihara
616a8c7f54 index: split serialization function into header and local parts
The idea is that we don't have to reload parent files as we already have the
chain of the parent segments. The resulting readonly index will be constructed
from the loaded parent segments + local entries blob.
2023-12-19 07:41:57 +09:00
Yuya Nishihara
31b6e93c6e index: move IndexLoadError to "readonly" module, rename accordingly
I thought IndexLoadError and DefaultIndexStoreError would represent "load" and
"store" failures respectively, but they aren't. Actually, DefaultIndexStoreError
is the store-level error, and IndexLoadError should be wrapped in it.
2023-12-19 07:41:57 +09:00
Yuya Nishihara
b5de16007e index: add stub IndexReadError type
This is needed to remove .unwrap()s from DefaultIndexStore.
2023-12-19 07:41:57 +09:00
Yuya Nishihara
d49b079494 index: update file format comment about ReadonlyIndexSegment
Also made it a doc comment. I think 4-byte alignment is a nice property,
so added note about that.
2023-12-19 07:41:34 +09:00
Ilya Grigoriev
c5f76d6b4d cli untrack --help: mention that files need to be already be ignored
Make it clearer what the command does, make the error message when the file is
not ignored less of a surprise.

Also, I think it's nice to mention `.git/info/exclude`, since the path is
not trivial to remember.
2023-12-17 22:16:22 -08:00
Ilya Grigoriev
9a990ad92f docs config.md Vim instructions: link to the Wiki instead of a gist 2023-12-17 22:16:02 -08:00
Yuya Nishihara
8909647d86 index: pass base directory path by reference 2023-12-18 08:49:21 +09:00
Yuya Nishihara
b733d52557 index: split DefaultIndexStoreError::Io variant, extract save helper
Since OpStoreError can also include io::Error, it doesn't make much sense to
have Io variant at this level. Let's split it to context-specific errors, and
extract helper method that maps io::Error.
2023-12-18 08:49:21 +09:00
Yuya Nishihara
bf4a4e70b1 index: use DefaultMutableIndex wrapper when reconstructing missing index
This allows us to extract helper method that writes index file and associates
it with the operation.
2023-12-18 08:49:21 +09:00
Yuya Nishihara
50164bb36f index: have IndexWriteError carry opaque error type instead of string
I'm going to remove some .unwrap()s from DefaultIndexStore, and the inner
error type will be consolidated to DefaultIndexStoreError.
2023-12-18 08:49:21 +09:00
Yuya Nishihara
87a8238bee git: turn git.auto-local-branch off by default
As far as I can see in the chat, there's no objection to changing the default,
and git.auto-local-branch = false is generally preferred.

docs/branches.md isn't updated as it would otherwise conflict with #2625. I
think the "Remotes" section will need a non-trivial rewrite.

#1136, #1862
2023-12-17 08:30:24 +09:00
Yuya Nishihara
6971ec239a tests: set git_settings.auto_local_branch where it matters 2023-12-17 08:30:24 +09:00
Yuya Nishihara
ac99145a28 working_copy: drop open file instance from PersistError
For the same reason as the file_util change.
2023-12-17 08:20:07 +09:00
Yuya Nishihara
c6df0ba4c3 file_util: don't try to overwrite existing content-addressed file on Windows
The doc says persist() replaces the destination file as rename() would do
on Unix. persist_noclobber() doesn't, and is probably more reliable on Windows.
I don't know if persist() is completely atomic on Windows, but if it isn't, it
might be the source of the "permission denied" error under highly contended
situation.

https://docs.rs/tempfile/latest/tempfile/struct.NamedTempFile.html#method.persist
https://github.com/Stebalien/tempfile/blob/v3.8.0/src/file/imp/windows.rs#L77

We could use persist_noclobber() on all platforms, but it's more involved on
Unix.

https://github.com/Stebalien/tempfile/blob/v3.8.0/src/file/imp/unix.rs#L107
2023-12-17 08:20:07 +09:00
Yuya Nishihara
dd325c089c file_util: drop open file instance from PersistError
PersistError is basically a pair of io::Error and NamedTempFile instance. It's
unlikely that we would want to propagate the open file instance to the CLI
error handler, leaving the temporary file alive.
2023-12-17 08:20:07 +09:00
Essien Ita Essien
35b8dad890 Implement a rename subcommand for the branch command.
This is really a simple change that does the following in a transaction:
* Set the new branch name to point to the same commit as the old branch name.
* Set the old branch name to point to no commit (hence deleting the old name).

Before it starts, it confirms that the new branch name is not already in use.
2023-12-16 18:44:46 +00:00
dependabot[bot]
d39843bd82 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [thiserror](https://github.com/dtolnay/thiserror).

- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.50...1.0.51)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-16 07:24:50 +00:00
Yuya Nishihara
5a466cab4c cli: ensure default remote branch is imported by "git clone"
I originally thought this would be unavoidable, but I was wrong. "jj git clone"
doesn't implicitly create any local branch if git.auto-local-branch is off, and
that's fine because the detached HEAD state is normal in jj.

That being said, Git users would expect that the main/master branch exists.
Since importing the default branch is harmless, let's create and track it no
matter if git.auto-local-branch is off.
2023-12-16 16:02:10 +09:00
Yuya Nishihara
0cb6a2f178 tests: deduplicate source repo setup in test_git_clone.rs 2023-12-16 16:02:10 +09:00
Yuya Nishihara
1fd8b82f13 github: reenable grouped cargo updates
The dependabot refused to update some dependencies anyway. Maybe it
conservatively checks if all intra dependencies meet a certain version?

```
updater | 2023/12/15 15:56:45 INFO <job_762807265> No update possible for cargo_metadata 0.17.0
updater | 2023/12/15 15:56:54 INFO <job_762807265> No update possible for crossterm 0.26.1
updater | 2023/12/15 15:57:04 INFO <job_762807265> No update possible for itertools 0.11.0
updater | 2023/12/15 15:57:16 INFO <job_762807265> No update possible for zstd 0.12.4
updater | 2023/12/15 15:57:16 INFO <job_762807265> No update possible for jj-cli 0.12.0
updater | 2023/12/15 15:57:27 INFO <job_762807265> No update possible for toml_edit 0.19.15
updater | 2023/12/15 15:57:38 INFO <job_762807265> No update possible for prost-build 0.11.9
updater | 2023/12/15 15:57:49 INFO <job_762807265> No update possible for prost 0.11.9
```

backout of commit 58744d9573
2023-12-16 14:40:39 +09:00
Yuya Nishihara
3a68baa90e cargo: update gix-ref to 0.39.1 which includes fix for Windows mmap issue
Fixes #2697
2023-12-16 08:19:29 +09:00
Yuya Nishihara
15c3014284 cli: colorize inline "jj branch" command hints
This is a bit different from the ordinary ui hints, but I feel the colored
output is easier to follow.
2023-12-16 07:50:15 +09:00
Yuya Nishihara
40d18bb2c9 cli: remove weird line break from the "jj branch forget" hint
The message seems a bit too long, but it doesn't make sense to insert \n
in the middle of sentence.
2023-12-16 07:50:15 +09:00
Yuya Nishihara
4d91e4c196 revset: simplify type constraints on combination iterators
Just a minor cleanup to remove lifetime parameter from the types. I tried to
reimplement them by using itertools, but I couldn't find a simple way to
encode short-circuiting at the end of either left or right iterator.
2023-12-16 07:50:04 +09:00
Yuya Nishihara
6d59156858 revset: parameterize candidates set of FilterRevset as well 2023-12-16 07:50:04 +09:00
Yuya Nishihara
a36368bb88 revset: make revset combinators generic over set types, merge UnionPredicate
UnionRevset and UnionPredicate are conceptually the same. Let's unify them.
2023-12-16 07:50:04 +09:00
Yuya Nishihara
af6047a655 lib: forbid unsafe_code at all 2023-12-15 16:10:28 +09:00
Yuya Nishihara
9990c41a90 repo: remove unsafe lifetime hack from change_id_index() 2023-12-15 16:10:28 +09:00
Yuya Nishihara
d9e8297059 index: add 'static version of evaluate_revset() to ReadonlyIndex
We'll probably need a better abstraction, but a separate method is good
enough to remove unsafe code from ReadonlyRepo.

I'm not sure if this is feasible for the other backends, but I guess there
would be less lifetimed variables than DefaultReadonlyIndex.
2023-12-15 16:10:28 +09:00
Yuya Nishihara
2ba50c76c7 revset: abstract evaluated RevsetImpl over owned/borrowed index types 2023-12-15 16:10:28 +09:00
Yuya Nishihara
72d9cd019b index: extract as_composite() to trait method
The revset engine will accept abstract AsCompositeIndex type, and the
evaluated revset can be 'static if the index is behind Arc<T>.
2023-12-15 16:10:28 +09:00