Commit graph

1083 commits

Author SHA1 Message Date
Yuya Nishihara
b3fa9e5b6c matchers: rename Dirs to RepoPathTree as it no longer represents directory 2022-12-30 14:15:27 +09:00
Yuya Nishihara
4f875ff9b7 matchers: leverage Dirs tree to test prefix matches, no .to_vec() in loop
No special case for prefix.is_root() is needed since the root entry can
also be flagged as a file.
2022-12-30 14:15:27 +09:00
Yuya Nishihara
996ac22921 matchers: simplify FilesMatcher::new() to take slice of paths 2022-12-30 14:15:27 +09:00
Yuya Nishihara
c7eaee3d86 matchers: remove redundant files set from FilesMatcher, use Dirs 2022-12-30 14:15:27 +09:00
Yuya Nishihara
2fb0363c03 matchers: add method to create visit sets from Dirs, remove separate getters
We might also want to eliminate .collect()/clone() here, but that's not
considered yet.
2022-12-30 14:15:27 +09:00
Yuya Nishihara
ba632e6ef6 matchers: build tree of Dirs so prefix match works out of the box
A file entry is represented as a Dirs of is_file flag set. This might seem
odd at this point, but allows us to remove special case from PrefixMatcher.
PrefixMatcher::new(&[RepoPath::root()]) will set is_file to the root entry.
2022-12-30 14:15:27 +09:00
dependabot[bot]
37fa7c39d4 cargo: bump whoami from 1.2.3 to 1.3.0
Bumps [whoami](https://github.com/ardaku/whoami) from 1.2.3 to 1.3.0.
- [Release notes](https://github.com/ardaku/whoami/releases)
- [Changelog](https://github.com/ardaku/whoami/blob/stable/CHANGELOG.md)
- [Commits](https://github.com/ardaku/whoami/compare/v1.2.3...v1.3.0)

---
updated-dependencies:
- dependency-name: whoami
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-29 07:39:59 -08:00
Martin von Zweigbergk
d86ba708a3 repo: add MutableRepo::rewrite_commit() returning CommitBuilder
Same reasoning as the previous commit.
2022-12-26 23:30:52 -08:00
Martin von Zweigbergk
812ef97adb repo: add MutableRepo::new_commit() returning CommitBuilder
Since `CommitBuilder` now has a reference to `MutableRepo`, it's
convenient to create instances of it by calling a method on
`MutableRepo`.
2022-12-26 23:30:52 -08:00
Martin von Zweigbergk
f3208f59c4 store: propagate error from Backend::write_commit() 2022-12-26 23:30:52 -08:00
Martin von Zweigbergk
f1d7bbe508 testutils: create a function for writing a random commit to MutableRepo
We already have `create_random_commit()`, which returns a
`CommitBuilder`. Most callers directly write that to a
`MutableRepo`. That currently returns a `Commit`, but I'm about to
make it propagate errors from the backend. That would add an
`unwrap()` to this sequence, making it longer. Let's create a simple
helper for these callers to simplify this common pattern.
2022-12-26 23:30:52 -08:00
Martin von Zweigbergk
49b2f3b6ca commit_builder: keep MutableRepo reference
When you're done with the `CommitBuilder`, you're going to have to
call `write_to_repo()`, passing it a mutable `MutableRepo`
reference. It's a bit simpler to pass that reference when we create
the `CommitBuilder` instead, so that's what this patch does.

A drawback of passing in the mutable reference when we create the
builder is that we can't have multiple unfinished `CommitBuilder`
instance live at the same time. We don't have any such use cases yet,
and it's not hard to work around them, so I think this change is worth
it.
2022-12-26 23:30:52 -08:00
dependabot[bot]
70a6798d76 cargo: bump pest_derive from 2.5.1 to 2.5.2
Bumps [pest_derive](https://github.com/pest-parser/pest) from 2.5.1 to 2.5.2.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.5.1...v2.5.2)

---
updated-dependencies:
- dependency-name: pest_derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-26 15:20:38 +00:00
Yuya Nishihara
d89619c9c6 git: diff refs to export without building dummy view 2022-12-25 00:11:14 +09:00
Martin von Zweigbergk
6514ab2e3a cli: when config is invalid, use default config
When we fail to read the user's config, it seems obviously better to
use the default config than to not use it. It doesn't matter yet, but
it will matter when I've moved color configs out of `formatter.rs` and
into a `.toml` file. Without this change, we'd lose the default
coloring of the error message for config errors.
2022-12-24 07:07:37 -08:00
dependabot[bot]
481f87abd3 cargo: bump pest from 2.5.1 to 2.5.2
Bumps [pest](https://github.com/pest-parser/pest) from 2.5.1 to 2.5.2.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.5.1...v2.5.2)

---
updated-dependencies:
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-23 09:24:57 -08:00
Yuya Nishihara
587e42d65d backend: deduplicate id type declarations by using declarative macro 2022-12-23 23:52:03 +09:00
Yuya Nishihara
b07c0db56b backend: deduplicate id type impls by using declarative macro
It's unlikely we'll need to customize these impls per type, so let's ensure
that these newtypes have identical implementations. This commit also adds
from_hex() to FileId, SymlinkId, and ConflictId.
2022-12-23 23:52:03 +09:00
Yuya Nishihara
36020a2bbf revset: parse hg/git-like '^' postfix operator and show hint 2022-12-23 00:38:29 +09:00
Yuya Nishihara
7cd01b27a7 revset: parse hg-like '-'/'+' infix operators and show hint
Suggested by @arxanas.

Actually, it's easier to support these infix ops than erroring out, but I
don't want to make revset syntax more cryptic. "x- y" can't be handled by
this rule because "x-" is parsed as a parents expression.
2022-12-23 00:38:29 +09:00
Benjamin Saunders
aaa175eca7 lib: replace protobuf crate with prost 2022-12-22 07:04:35 -08:00
Yuya Nishihara
986649623d commit_builder: relax type of description parameter
The next commit will introduce a newtype for -m/--message argument which
can be converted Into<String>.

Since CommitBuilder is a thin wrapper, code bloat caused by generic parameters
wouldn't matter. I have another set of commits that makes all builder methods
accept Into/IntoIterator, which will remove some of .clone() calls from tests.
2022-12-22 14:59:03 +09:00
dependabot[bot]
80ab49e2f6 cargo: bump num_cpus from 1.14.0 to 1.15.0
Bumps [num_cpus](https://github.com/seanmonstar/num_cpus) from 1.14.0 to 1.15.0.
- [Release notes](https://github.com/seanmonstar/num_cpus/releases)
- [Changelog](https://github.com/seanmonstar/num_cpus/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/num_cpus/compare/v1.14.0...v1.15.0)

---
updated-dependencies:
- dependency-name: num_cpus
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-21 09:06:25 -08:00
Yuya Nishihara
c9ff99d166 cargo: drop or move "rand" to dev-dependencies 2022-12-21 23:48:51 +09:00
Ilya Grigoriev
2f00fcb6b4 jj git push: Make sure each branch is processed at most once 2022-12-21 00:52:17 -08:00
dependabot[bot]
e1bf2ea7f4 cargo: bump thiserror from 1.0.37 to 1.0.38
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.37 to 1.0.38.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.37...1.0.38)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-19 09:57:39 -08:00
dependabot[bot]
548595ec52 cargo: bump blake2 from 0.10.5 to 0.10.6
Bumps [blake2](https://github.com/RustCrypto/hashes) from 0.10.5 to 0.10.6.
- [Release notes](https://github.com/RustCrypto/hashes/releases)
- [Commits](https://github.com/RustCrypto/hashes/compare/blake2-v0.10.5...blake2-v0.10.6)

---
updated-dependencies:
- dependency-name: blake2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-19 09:57:18 -08:00
dependabot[bot]
cb59948b3c cargo: bump serde_json from 1.0.89 to 1.0.91
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.89 to 1.0.91.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.89...v1.0.91)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-19 09:57:06 -08:00
Luke Granger-Brown
90ba55bd7b git: cache the extra metadata table
Performance on repositories with many commits is limited somewhat by repeatedly
stating the tablestore directory to work out what the head is. By caching the
table rather than looking it up from disk on every request, we can much more
rapidly satisfy requests. 

This avoids the pathological case in #845 where jj operations take several
minutes to complete.

This patch doesn't change the normal flow of the write path: that will still
always call get_head() on the underlying TableStore, which will stat the
directory before writing out changes. It will however empty the cache when the
metadata has been written.

Fixes #845.
2022-12-17 08:19:14 +00:00
Daniel Ploch
e9bd6fbeae op_heads_store: give the OpHeadsStore factory semantics 2022-12-16 10:47:48 -08:00
Daniel Ploch
90a66ec262 op_heads_store: move op_heads into a subdir, to make room for the 'type' marker 2022-12-16 10:47:48 -08:00
Daniel Ploch
2c5b3d0cc7 op_heads_store: convert load() to take &Path like other factories 2022-12-16 10:47:48 -08:00
Daniel Ploch
309a3f91a1 op_heads_store: refactor into an interface and simple implemenation
The implementation has some hoops to jump through because Rust does not allow
`self: &Arc<Self>` on trait methods, and two of the OpHeadsStore functions need
to return cloned selves. This is worked around by making the implementation type
itself a wrapper around Arc<>.

This is not particularly note worthy for the current implementation type where
the only data copied is a PathBuf, but for extensions it is likely to be more
critical that the lifetime management of the OpHeadsStore is properly
maintained.
2022-12-16 10:47:48 -08:00
Yuya Nishihara
4e8f51a983 cleanup: leverage Itertools::try_collect() instead of turbofish
It still requires return type annotation in some places, but should be easier
to type than ::<Result<...

https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.try_collect
2022-12-16 13:34:58 +09:00
Martin von Zweigbergk
daef30906f protobuf: remove ignored call to out_dir()
Since we call `cargo_out_dir()` - which is the preferred way of using
`protobuf_codegen::Codegen` in `build.rs` - our call to `out_dir()`
has no effect.
2022-12-15 13:02:22 -08:00
Martin von Zweigbergk
fb396e6b45 cleanup: address unnecessary_borrow lints reported by Clippy 1.66
Interestingly, the nightly release doesn't complain about this. One
instance in `test_working_copy.rs` is a bug in Clippy.
2022-12-15 12:38:01 -08:00
Martin von Zweigbergk
7f9a0a2820 cleanup: let new Clippy move variables into format strings
I ran an upgraded Clippy on the codebase. All the changes seem to be
about using variables directly in format strings instead of passing
them as separate arguments.
2022-12-14 21:30:58 -08:00
Daniel Ploch
bd31bfd2d7 repo: give OpStore factory load semantics 2022-12-14 14:10:30 -08:00
Daniel Ploch
0f62c795d8 repo: move backend loading onto the StoreFactories struct 2022-12-14 14:10:30 -08:00
Daniel Ploch
25c379429c op_store: init/load by &Path, for consistency with other stores 2022-12-14 14:10:30 -08:00
Daniel Ploch
7cbea42a24 repo: rename BackendFactories to StoreFactories 2022-12-14 14:10:30 -08:00
Daniel Ploch
7756cfa61b op_store: op store delegates should not implement the OpStore trait directly 2022-12-14 14:10:30 -08:00
Yuya Nishihara
ffbd6eb945 tree: ensure Tree outlives its iterator on dropping self-referential struct
Just for sanity. It wouldn't matter unless the iterator implements Drop.

https://doc.rust-lang.org/reference/destructors.html
2022-12-15 01:51:25 +09:00
dependabot[bot]
2a357ac2df cargo: bump insta from 1.22.0 to 1.23.0
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.22.0 to 1.23.0.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.22.0...1.23.0)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-13 11:32:05 -08:00
Yuya Nishihara
6237f3cdfd revset: fold nested parents expressions
Some other ancestors() expressions can also be substituted. Practically,
this is the rule to fold repeated '-' operators to evaluate them lazily.
2022-12-13 15:55:18 +09:00
Yuya Nishihara
069a8ed9bc revset: reimplement parents() as ancestors() with generation filter
This wouldn't make things any better by itself, but it allows us to merge
nested parents().
2022-12-13 15:55:18 +09:00
Yuya Nishihara
46b1465324 revset: add generation parameter to RevsetExpression::Ancestors/Range
Parents(heads) will be translated to Ancestors(heads, 1..2).
2022-12-13 15:55:18 +09:00
Yuya Nishihara
29a565e3fb revset: add substitution rule for roots..heads
While working on ancestor generation, I noticed Mercurial has this
substitution rule. Since it's easier to deal with Ancestors() than Range {},
'roots..heads' is first decomposed to ':heads & ~:roots'.
2022-12-13 15:55:18 +09:00
Yuya Nishihara
e6229e6d77 revset: turn RevWalkRevset into generic wrapper of cloneable iterator
I failed to solve type puzzle for to_predicate_fn<'a>(&'a self) where
'repo: 'a, so struct RevWalkRevset<'repo, T> is bounded by T to consume
the lifetime parameter.
2022-12-13 15:55:18 +09:00
Yuya Nishihara
4a889b986c index: implement generation filter on RevWalkGenerationRange
This will be a building block of 'parents(base)' revset. 'base---' will
be .filter_by_generation(3..4) for example. I think 'ancestors(base)' can
also have an optional generation parameter, but I haven't considered any
particular syntax yet.
2022-12-11 13:14:19 +09:00