Commit graph

3677 commits

Author SHA1 Message Date
Martin von Zweigbergk
83fefa9a3b conflicts: add a map(), use in extract_as_single_hunk()
Now that we've replaced `MergeHunk` by a `Conflict`, it makes sense to
convert the input `Conflict<FileId>` by mapping each term. Unlike
`Option::map()` I made `Conflict::map()` take a reference `self`,
because it's not uncommon to want to map the same conflict multiple
times. I'm going to use that for producing a
`Conflict<Option<TreeValue>>` from a `Conflict<Tree>` and a set of
paths.
2023-06-30 14:43:58 +02:00
Martin von Zweigbergk
6bd13382f4 backend: add a function for setting or removing a tree entry 2023-06-30 14:43:58 +02:00
Martin von Zweigbergk
c0ffce781e store: cache tree on write and return it
This matches what we do when writing commits.
2023-06-30 14:12:36 +02:00
Martin von Zweigbergk
b297c0c0d8 rewrite: propagate errors from merge_trees() 2023-06-30 14:12:36 +02:00
Martin von Zweigbergk
134efabcef test_merge_trees: make merge_trees() wrapper's signature match original 2023-06-30 14:12:36 +02:00
Kevin Liao
eac90fd113 Update init_external to return an error instead of unwrapping 2023-06-29 10:03:13 -07:00
dependabot[bot]
00d8cd740d cargo: bump num_cpus from 1.15.0 to 1.16.0
Bumps [num_cpus](https://github.com/seanmonstar/num_cpus) from 1.15.0 to 1.16.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.15.0...v1.16.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>
2023-06-29 18:49:48 +02:00
Yuya Nishihara
458ae45905 cli: ensure log revset expression tree is optimized
I don't think we have any substitution rules applied to union or intersection
with single file predicate, but there might be something in future.
2023-06-29 19:33:32 +09:00
Yuya Nishihara
e601a30b15 cli: make log accept multiple -rREVISION expressions
For scripting scenario, multiple -r options are easier to construct than
concatenating expressions with ")|(".
2023-06-29 19:33:32 +09:00
Yuya Nishihara
7ad6357c10 revset: add union_all(...) helper to concatenate multiple -rREV options 2023-06-29 19:33:32 +09:00
Yuya Nishihara
f0b9969e74 cli: document that "git push --all" includes deleted branches
Since deleted branches are a bit special, I couldn't be sure that --all
includes deleted without reading the source code.
2023-06-29 17:05:53 +09:00
Yuya Nishihara
b1267cae4b cli: remove redundant deduplication of branch names from cmd_git_push() 2023-06-29 17:05:53 +09:00
Yuya Nishihara
237dd98b87 cli: in cmd_git_push(), narrow scope of seen_branches 2023-06-29 17:05:53 +09:00
Martin von Zweigbergk
68e696d673 cargo: upgrade clap from 4.3.8 to 4.3.9
The new version has a change that makes `ignore_errors()` not ignore
the error from `--help` (clap handles `--help` by returning an
error). To compensate for that, I disabled the `--help` and
`--version` flag and the `help` subcommand while parsing early
arguments.
2023-06-28 23:22:09 +02:00
Martin von Zweigbergk
9995415440 cli: propagate clap error from handle_early_args()
If we fail to parse the command line, even with `ignore_errors(true)`
set, we currently let clap exit the process for us because we call
`get_matches_from()`. We should instead propagate any errors and
exit in `CliRunner::run()` as usual..
2023-06-28 23:22:09 +02:00
dependabot[bot]
db87cb2c39 cargo: bump rustix from 0.37.20 to 0.38.0
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.37.20 to 0.38.0.
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.37.20...v0.38.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-28 22:16:49 +02:00
Yuya Nishihara
3779b45b94 git: use type-safe RefName enum extensively in import_some_refs()
I was thinking of adding GitRefName newtype, but the RefName type can serve
the same role.
2023-06-28 23:11:08 +09:00
Yuya Nishihara
1d9552406b git: leverage parse_git_ref() to test reference kind 2023-06-28 23:11:08 +09:00
Martin von Zweigbergk
e6d5df1010 docs: add doc comparing jj to Sapling (#1708) 2023-06-28 06:56:57 +02:00
Martin von Zweigbergk
779b8ba318 files: replace uses of MergeHunk by Conflict<ContentHunk>
Since `Conflict`s can represent the resolved state, so
`Conflict<ContentHunk>` can represent the states that we use
`MergeHunk` for. `MergeHunk` does force the user to handle the
resolved case, which may be useful. I suppose one could use the same
argument for making `Conflict` an enum, i.e. if we think that
`MergeHunk`'s two variants are beneficial, then we should consider
making `Conflict` an enum with those two variants.
2023-06-28 06:51:37 +02:00
Martin von Zweigbergk
c625e9352d files: make MergeHunk::Conflict be a Conflict<ContentHunk>
The `ConflictHunk` type doesn't add anything over
`Conflict<ContentHunk>`.
2023-06-27 21:06:32 +02:00
Martin von Zweigbergk
35e4d5f205 conflicts: add take(), returning the removes and adds Vecs 2023-06-27 21:06:32 +02:00
Martin von Zweigbergk
b1f2e80349 files: add a newtype around Vec<u8> for content hunks
It's useful to have a more readable `Debug` format for `Vec<u8>`
(`"foo"` is better than `[102, 111, 111]`). It might also make types
in function signatures and elsewhere more readable.
2023-06-27 21:06:32 +02:00
Martin von Zweigbergk
b3946be414 conflicts: avoid unnecessary cloning of conflict content 2023-06-27 21:06:32 +02:00
Glen Choo
777b786c53 git: add a hidden submodule subcommand
Add the `submodule` subcommand, which will remain hidden while we are
polishing up the submodules feature. Also, add a debugging-only
sub-subcommand `print-gitmodules` that tests our .gitmodules parser with
the .gitmodules in the working copy.
2023-06-27 10:07:00 -07:00
Glen Choo
7afaa2487b git: add .gitmodules parser
This only parses the fields relevant to us, i.e.:

- name: the stable identifier of the submodule
- path: the path to the submodule in the current commit
- url: the remote we can clone the submodule from

The full list of .gitmodules fields can be found at
https://git-scm.com/docs/gitmodules.
2023-06-27 10:07:00 -07:00
Grégoire Geis
fee7eb5813 add --edit option to jj sparse set 2023-06-27 22:56:46 +09:00
dependabot[bot]
23351c32ea github: bump ossf/scorecard-action from 2.1.3 to 2.2.0
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.1.3 to 2.2.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](80e868c13c...08b4669551)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 07:58:14 +02:00
dependabot[bot]
0a6355ea1a cargo: bump indexmap from 1.9.3 to 2.0.0
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.9.3 to 2.0.0.
- [Changelog](https://github.com/bluss/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/bluss/indexmap/compare/1.9.3...2.0.0)

---
updated-dependencies:
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 07:57:50 +02:00
dependabot[bot]
43cedfd0c9 cargo: bump serde_json from 1.0.97 to 1.0.99
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.97 to 1.0.99.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.97...v1.0.99)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 07:56:50 +02:00
dependabot[bot]
d7544f86c0 github: bump dtolnay/rust-toolchain
Bumps [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) from 1f5cdb56c8779e3efa22473ce181ff83143b172c to 0e66bd3e6b38ec0ad5312288c83e47c143e6b09e.
- [Release notes](https://github.com/dtolnay/rust-toolchain/releases)
- [Commits](1f5cdb56c8...0e66bd3e6b)

---
updated-dependencies:
- dependency-name: dtolnay/rust-toolchain
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-27 07:46:45 +02:00
dependabot[bot]
5e6dd17ed9 cargo: bump whoami from 1.4.0 to 1.4.1
Bumps [whoami](https://github.com/ardaku/whoami) from 1.4.0 to 1.4.1.
- [Changelog](https://github.com/ardaku/whoami/blob/stable/CHANGELOG.md)
- [Commits](https://github.com/ardaku/whoami/compare/v1.4.0...v1.4.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-26 20:55:03 +02:00
dependabot[bot]
f454ab9444 cargo: bump libc from 0.2.146 to 0.2.147
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.146 to 0.2.147.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.146...0.2.147)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-26 20:54:22 +02:00
dependabot[bot]
210f72fcb0 cargo: bump clap from 4.3.5 to 4.3.8
Bumps [clap](https://github.com/clap-rs/clap) from 4.3.5 to 4.3.8.
- [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/v4.3.5...v4.3.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-26 20:53:25 +02:00
dependabot[bot]
0f153ef01c cargo: bump toml_edit from 0.19.10 to 0.19.11
Bumps [toml_edit](https://github.com/toml-rs/toml) from 0.19.10 to 0.19.11.
- [Commits](https://github.com/toml-rs/toml/compare/v0.19.10...v0.19.11)

---
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-06-26 20:45:35 +02:00
Martin von Zweigbergk
f64e4816df git: remove unused push_commit() 2023-06-26 14:28:51 +02:00
Martin von Zweigbergk
75f3537893 merge_tools: assume that conflict is 3-way
We check that the conflict to run the merge tool on is at most 3-way
already, and we don't store 1-way conflicts, so we should be able to
assume that it's exactly a 3-way conflict.
2023-06-26 13:47:33 +02:00
Martin von Zweigbergk
b8221d4e21 conflicts: add try_map() method
This simplifies `to_file_conflict()` and `try_resolve_file_conflict()`
a bit.
2023-06-26 13:47:33 +02:00
Martin von Zweigbergk
b8f6a48c66 merge: fast-path trivial merge of 1-way "conflicts"
I don't think we call `trivial_merge()` for 1-way "conflicts" yet, but
I'll probably end up doing that soon.
2023-06-26 13:47:33 +02:00
Martin von Zweigbergk
9c486ebe45 conflicts: add a method returning the resolved value, if resolved 2023-06-26 13:47:33 +02:00
Yuya Nishihara
453d3a11fc changelog: mention fixes for #924 and #1608 (racy change id / snapshot) 2023-06-26 14:24:37 +09:00
Yuya Nishihara
3c2657c393 cli: add hint for git-exporting forgotten branches
Inspired by d01ecc5c46 "more detailed message describing deleted branches."

And yes, "jj git export" does propagate "jj branch forget" to the underlying
Git repository, which strengthen my feeling that git::export_refs() should
also remove "forgotten" remote tracking refs.
2023-06-26 13:56:32 +09:00
Yuya Nishihara
72792a8dbe cli: say "(forgotten)" if branch is listed just because it's in git_refs
I thought we would need additional bookkeeping to detect forgotten branches,
but I was wrong. If a branch exists only in git_refs, it is forgotten (but not
yet exported.)
2023-06-26 13:56:32 +09:00
Yuya Nishihara
9d6020fab0 cli: move "(deleted)" branch labeling to caller
It only applies to local branches, and None doesn't always mean deleted as
we have pseudo "git" remote.
2023-06-26 13:56:32 +09:00
Yuya Nishihara
ca6b9828d1 id_prefix: only store first few bytes of keys in IdIndex
This eliminates indirect access through Vec<u8> and improves cache locality
while sorting the index entries. We can achieve a similar result by using
SmallVec<[u8; 24]> in place of Commit/ChangeId(Vec<u8>), but we would have
to determine a reasonable id length across backends. Indexing [u8; 4] performs
better, at the cost of the API and implementation complexity.

For temporary Commit/ChangeId allocation in general, I think a borrowed type
like Path/PathBuf will help.

Testing with my "linux" repo, this saves ~670ms needed to initialize both
change id index and disambiguation indexes.
2023-06-25 12:54:18 +09:00
Yuya Nishihara
b789ffb3fc id_prefix: inline IdIndex::resolve_prefix_range()
I'll rewrite resolve_prefix_range() to branch depending on the prefix length,
and the easiest way to do that is passing iterator to continuation function
instead of returning iterator as an either (or boxed) type.
2023-06-25 12:54:18 +09:00
Yuya Nishihara
7ada2196e1 id_prefix: store (CommitId, ChangeId) pairs separately in disambiguation index
I'm going to rewrite IdIndex to store only first few bytes of the key. A
separate table helps there.

At this point, it wouldn't make sense to convert usize to u32, but the new
index will store ([u8; 4], u32) pairs.
2023-06-25 12:54:18 +09:00
Yuya Nishihara
580d8bd92e id_prefix: introduce builder interface to IdIndex
It allows us to build multiple IdIndex instances within a single loop. As the
final sorting is heavy operation, I don't want to implement Default + Extend
for IdIndex to be compatible with Iterator::unzip().
2023-06-25 12:54:18 +09:00
Yuya Nishihara
3799aa44bb id_prefix: test resolve_prefix_with() instead of _to_values()
I'll remove resolve_prefix_to_values() method.
2023-06-25 12:54:18 +09:00
Yuya Nishihara
020aeff903 id_prefix: insert intermediate lookup state to resolve unique len from there 2023-06-25 12:54:18 +09:00