Commit graph

3531 commits

Author SHA1 Message Date
Yuya Nishihara
fb77c55268 index: use as_composite() to access to index stats
The idea is that .as_composite() is equivalent to .as_index(), but for the
implementation type. I'm going to add "impl Index for CompositeIndex" to
clean up index references passed to revset engine.
2023-05-29 08:15:40 +09:00
Yuya Nishihara
92c1b7091b index: make CompositeIndex copyable to clarify it is a cheap reference type
Well, I might change it to an owned wrapper later, but if I made such change,
the current CompositeIndex<'_> would be replaced with &CompositeIndex.
2023-05-29 08:15:40 +09:00
Martin von Zweigbergk
d047a8fbd4 tree: respect matcher.visit() when walking entries
This handles the basic case of where the matcher says that a whole
subtree is not matched. In the Linux repo, That's already enough to
speed up `jj --ignore-working-copy files samples` from 298 ms to 129
ms.
2023-05-28 07:28:16 -07:00
Martin von Zweigbergk
dbcecf7244 tree: rewrite recursive entries iterator to not use machine stack
In the same vein as c02c4168fe.
2023-05-28 07:28:16 -07:00
Martin von Zweigbergk
a897b27770 revset: minor fixes to documentation of graph iterator 2023-05-26 15:55:29 -07:00
Martin von Zweigbergk
7bf1ab712a progress: update progress only every 10 ms
In the Linux repo, this speeds up `jj diff` in a clean working copy
from 1.41 s to 881 ms.
2023-05-26 12:22:29 -07:00
dependabot[bot]
1fa88dbad0 github: bump github/codeql-action from 2.3.4 to 2.3.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.4 to 2.3.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](f0e3dfb303...0225834cc5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-26 17:09:56 +00:00
dependabot[bot]
fe90574b37 cargo: bump regex from 1.8.2 to 1.8.3
Bumps [regex](https://github.com/rust-lang/regex) from 1.8.2 to 1.8.3.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.8.2...1.8.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-26 16:11:49 +00:00
dependabot[bot]
b2ecabe89a github: bump github/codeql-action from 2.3.3 to 2.3.4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.3 to 2.3.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](29b1f65c5e...f0e3dfb303)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-25 16:12:55 +00:00
Aaron Bull Schaefer
d10af403a5 cleanup: fix minor typos in function names
> error: `mutliple` should be `multiple`
> error: `visble` should be `visible`

Found via typos:
- https://github.com/crate-ci/typos
2023-05-25 08:43:06 -07:00
Martin von Zweigbergk
d087e64abf cleanup: consistently (?) put removed conflict terms before added ones 2023-05-25 04:24:26 -07:00
Martin von Zweigbergk
97c64d8071 tree: leverage trivial_merge() for file executable bit 2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
f838d083d3 tree: add test of merge of executable bit
We didn't seem to have any tests of this, so let's add one before I
change the implementation.
2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
28d3ad6f1d files: add more multi-hunk tests
We seemed to have poor coverage of merges affecting multiple hunks, so
I added a few. Thanks to @quark-zju for providing the last of them.
2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
1c284322b3 files: leverage trivial_merge() in merge()
Note that one test changed because the new `trivial_merge()` is more
strict than the old algorithm. I don't think that's a problem because
5-way conflicts are not very common, and I prefer to be strict now and
possibly relax it later if we decide that we would prefer that.
2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
61c1b9f4eb files: add another test of a 5-way merge
Just to show that this case doesn't change in the next commit.
2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
1ec906b114 files: make merge() require one more adds than removes
All call paths already check before calling the function that the
condition is true. One caller - `tree::try_resolve_file_conflict()` -
checks it itself. The other caller -
`conflicts::materialize_merge_result()` - doesn't, but its callers
have checked it via `extract_file_conflict_as_single_hunk()`.

The deleted comment about empty strings seems to be obsolete since
e48ace56d1. The caller pads the inputs with empty strings since that
commit.

I think we should ideally change this function's signature to make it
impossible to call it with bad inputs, and I hope to get back to that
soon.
2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
3069718c0f refs: leverage trivial_merge() in merge_ref_targets() 2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
451af92912 tree: leverage trivial_merge() in merge_trees() 2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
ef7b831411 merge: optimize 3-way merge case
I haven't done any profiling to see if this is actually useful, but
it's also pretty simple to do.
2023-05-24 22:00:38 -07:00
Martin von Zweigbergk
aa2792c5e5 merge: add a generic function for resolving trivial N-way merges
We already resolve merge conflicts between hunks, trees, and refs, and
maybe more. They each have their own code for the handling trivial
merges (where the output is equal to one of the inputs). They look
surprisingly different. This commit adds a generic function for doing
that. Curiously, this new implementation uses implements it in yet
another way (basically using a multi-set).
2023-05-24 22:00:38 -07:00
dependabot[bot]
69a7df1715 github: bump cachix/install-nix-action from 20 to 21
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 20 to 21.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](29bd9290ef...4b933aa7eb)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-24 16:13:59 +00:00
dependabot[bot]
6e09e47129 cargo: bump toml_edit from 0.19.9 to 0.19.10
Bumps [toml_edit](https://github.com/toml-rs/toml) from 0.19.9 to 0.19.10.
- [Commits](https://github.com/toml-rs/toml/compare/v0.19.9...v0.19.10)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-24 16:11:45 +00:00
dependabot[bot]
3c1183fb38 cargo: bump regex from 1.8.1 to 1.8.2
Bumps [regex](https://github.com/rust-lang/regex) from 1.8.1 to 1.8.2.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.8.1...1.8.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-23 16:13:49 +00:00
Yuya Nishihara
8157c4a926 index: remove walk_revs() from trait API
It only makes sense for the DefaultIndexStore.
2023-05-24 01:02:37 +09:00
Yuya Nishihara
e24fe817c9 tests: invoke .walk_revs() through CompositeIndex
Prepares for removal of the index trait method.
2023-05-24 01:02:37 +09:00
Yuya Nishihara
6ba684a395 index: replace use of walk_revs() with revset API
I've added a helper function because the construction of the range expression
is a bit noisy. It could be a Repo method, but I don't want to make it a
default implementation of the trait method.

revset::walk_revs() let the caller handle RevsetEvaluationError since the
evaluation engine may error out even with such a trivial query. For now, most
callers just .unwrap() the error as before.
2023-05-24 01:02:37 +09:00
Yuya Nishihara
0b2f0eca05 revset: add Revset::count() API
The default-engine implementation is pretty much the same as iter().count(),
but custom engine may have an optimal path.
2023-05-24 01:02:37 +09:00
Yuya Nishihara
5b568cabcc revset: add iterator of (CommitId, ChangeId) pairs, use it in id_index
There are a few more places where we need these pairs.
2023-05-24 01:02:37 +09:00
Yuya Nishihara
4d39fdf614 id_prefix: remove redundant CommidId field from disambiguation index 2023-05-24 01:02:37 +09:00
Yuya Nishihara
44927be7c9 id_prefix: add IdIndex method that looks up unambiguous key
resolve_prefix_with() is changed to return both key and values.
2023-05-24 01:02:37 +09:00
Yuya Nishihara
e93ff5815c id_prefix: rename IdIndex::resolve_prefix() to resolve_prefix_to_values()
I'll add a key resolution method.
2023-05-24 01:02:37 +09:00
Yuya Nishihara
e7f83e7681 index: add PrefixResolution::map() helper
I'm going to make IdIndex::resolve_prefix_with() return (key, values) pair,
and add convenient wrappers that .map() the pair to either key or values.
2023-05-24 01:02:37 +09:00
Yuya Nishihara
d6f1ab697a cli: load revset/template aliases in order of config layers
Since we abuse TOML table syntax to define function aliases, an identical
function alias can be found more than once in the merged config. The merged
config doesn't preserve the definition order, so we need to load aliases
table per layer.
2023-05-23 14:20:55 +09:00
Yuya Nishihara
97e2ee2868 cli: pass CommandHelper reference to WorkspaceCommandHelper constructor
I'll need to access LayeredConfigs there, and I don't think external callers
would want to specify each argument separately.
2023-05-23 14:20:55 +09:00
Martin von Zweigbergk
f1e2849c23 cli: add some documentation for jj sparse, including examples 2023-05-22 09:49:38 -07:00
Martin von Zweigbergk
b6691a1d23 cli: make jj sparse --list a subcommand
`jj sparse` is a bit different from other commands in that its `jj
sparse --list` is practically a separate command. Let's make it an
actual subcommand for consistency, and so we can more cleanly add
additional flags for `jj sparse list` in the future. I moved all the
other arguments to `jj sparse set`. I'm not sure if `jj sparse set
--reset` would have been better as `jj sparse reset`, but it is
technically just updating the sparse patterns just like the other
arguments (`--clear`, `--add` , `--remove`).
2023-05-22 09:49:38 -07:00
dependabot[bot]
3575c1f499 cargo: bump digest from 0.10.6 to 0.10.7
Bumps [digest](https://github.com/RustCrypto/traits) from 0.10.6 to 0.10.7.
- [Commits](https://github.com/RustCrypto/traits/compare/digest-v0.10.6...digest-v0.10.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-22 16:16:04 +00:00
dependabot[bot]
d8d8fcff2f cargo: bump clap_complete from 4.2.3 to 4.3.0
Bumps [clap_complete](https://github.com/clap-rs/clap) from 4.2.3 to 4.3.0.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.2.3...clap_complete-v4.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-22 16:13:55 +00:00
Martin von Zweigbergk
6a9b527987 tests: test lookup of prefixes from the log output just about
It's easier to follow the test if we try to resolve commits from the
`jj log` output just above. That's what we did until I changed it away
from that without thinking in fcda05c69b.
2023-05-22 07:02:32 -07:00
Martin von Zweigbergk
5d2872d76f tests: restore effectiveness of prefix among hidden commits
When I added `revsets.short-prefixes` in 20ef171d7a, I didn't notice
that I made the test of commit prefixes among hidden commits
ineffective because. This restores that by disabling short prefixes in
the test.
2023-05-22 07:02:32 -07:00
Martin von Zweigbergk
a72898000f tests: avoid hardcoding commit/operation ids when possible
Hardcoded ids cannot be updated with `insta`.
2023-05-22 07:02:32 -07:00
Martin von Zweigbergk
0e18757610 tests: include description in test_git_colocated log template
I think this makes the tests a little clearer.
2023-05-22 07:02:32 -07:00
Yuya Nishihara
c23f1e4161 cli: reload both repo and wc commit if working copy was updated
Otherwise, working-copy snapshot would be taken against wrong parent, which
would cause divergence if the history was previously rewritten.

Fixes #1608
2023-05-22 08:36:38 +09:00
Yuya Nishihara
ed60ddcdcc cli: move code that reloads repo to working-copy operation
Reloading repo also means the working-copy commit can change, so the caller
needs to do more things than repo.reload_at().
2023-05-22 08:36:38 +09:00
Yuya Nishihara
1675aec388 git: handle lock error that could occur while adding GC-preventing refs
If I spawned ~20 "jj status &" processes, some of them panicked there.
Spotted when debugging #924.
2023-05-22 08:36:29 +09:00
Yuya Nishihara
b01614bbdd cleanup: leverage scoped thread in tests 2023-05-21 21:02:58 +09:00
Yuya Nishihara
38a7e7fd62 git_backend: on read_commit(), bulk-update extra metadata table of ancestors
Otherwise, "jj init --git-repo ." would create extra table files per commit,
and merge them.

I considered adding an explicit GitBackend method to be called from
git::import_refs(), but the call order matters. The method should be invoked
before calling store.get_commit(..) or mut_repo.add_head(..). Since commits
are likely to be loaded from the head, we can instead make read_commit()
import ancestor metadata at all.

Alternatively, we could make a Git commit hidden until it's inserted into
the extra table. It's rather big change, and I wouldn't like to do that
without thinking more thoroughly.
2023-05-21 08:29:00 +09:00
Yuya Nishihara
fe97dccd02 git_backend: move add_entry() of extra metadata table to caller
I'm going to add a caller which will insert multiple entries at once.
2023-05-21 08:29:00 +09:00
Yuya Nishihara
e6addf7905 git_backend: extract helper that converts git2::Commit to backend::Commit
The root parent id is filled by caller because empty parents list is more
convenient while walking ancestors.
2023-05-21 08:29:00 +09:00