ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

6813 commits

Author SHA1 Message Date
Martin von Zweigbergk
3acb89e7cc merged_tree: remove TreeDiffEntry::source 2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
721aa1238c copies: add a separate diff stream item type with copy info
The goal is to have the new item type know if it represent a copy, a
rename, a deleted rename source, or a regular copy-unrelated item.
2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
70598498b0 merged_tree: provide separate version of diff_stream() with copy info
I plan to provide a richer version of `TreeDiffEntry` with copy info
(and to make `TreeDiffEntry` itself "poorer"). Most callers want to
know about copies/renames, but at least working copy implementations
probably don't. This patch adds separate `diff_stream()` and
`diff_stream_with_copies()` so we can provide the simpler interface
for callers that don't need copy info.
2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
bce8550db1 merged_tree: inline next_impl() and poll_next_impl() 2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
ad86dd1c1b copies: inline adjust_for_copy_tracking()
We now have only one caller, and it's in a different module, so it
makes more sense to move it there.
2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
e670837ff6 copies: implement copy support in MergedTree::diff_stream() as adapter
The support for copy tracing is already simply added to the stream
just before yielding the item, so we can easily implement it as a
stream adapter. That ensures that we use the same logic for the
iterator- and stream-based versions. More importantly, it enables
further cleanups and a simpler interface.
2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
fd9a236be5 copies: move CopyRecords to new copies module
Copy/rename handling is complicated. It seems worth having a module
for it. I'm going to add more content to it next.
2024-08-18 22:16:41 -07:00
Yuya Nishihara
6101a66a76 diff: inline Diff::default_refinement() in diff()
There are no callers other than tests and benches.
2024-08-19 11:54:58 +09:00
Yuya Nishihara
864dd73856 tests: use diff::diff() instead of Diff::default_refinement()
Diff::default_refinement() will be removed.
2024-08-19 11:54:58 +09:00
Yuya Nishihara
db0a4bccc5 diff: make diff() function accept any number of inputs
So that more tests can leverage diff::diff() helper.

I also removed the fast path for identical inputs. This function is only used by
tests and benches, and production code usually compares content hashes first.
2024-08-19 11:54:58 +09:00
Martin von Zweigbergk
aa0fbd9f3f drop "support" for legacy tree config
The tree-level conflicts have worked well in practice and we don't
want to allow users to use legacy trees for new commits. We don't
really support legacy trees very well since 0590f8bece anyway.
2024-08-18 07:19:50 -07:00
Essien Ita Essien
e2a5c83e5c Follow ups on post-submission comments for #4282.
* Derive a bunch of standard and useful traits for `movement_util::Direction`
  as it is a simple type. Importantly `Copy`.
* Return `&'static str` from Direction.cmd()
* Refactor out `MovementArgs` to reduce the number of arguments
  to `movement_util::move_to_commit`.
* Implement `From<&NextArgs/&PrevArgs>` for MovementArgs

Part of #3947
2024-08-18 10:43:08 +01:00
Yuya Nishihara
1be955ea4e diff: simplify conditions whether to emit color-words context lines
This appears to fix redundant "    ..." line for empty diffs.
2024-08-18 12:40:07 +09:00
Yuya Nishihara
9beb57018a diff: split color-words diffing to line-based and refinement stages
This allows us to select rendering function hunk by hunk. For example, a hunk
with lots of small changes could be rendered without interleaving left/right
words. Another good thing is that context line handling can be simplified as
the whole context hunk is available.
2024-08-18 12:40:07 +09:00
Yuya Nishihara
59745fb67f files: allow DiffLineIterator users to specify and retrieve line numbers
The added functions will be used in order to iterate middle hunks which don't
start from line_number = 1.
2024-08-18 12:40:07 +09:00
Yuya Nishihara
2be8e596e2 diff: extract Diff::by_word() function
I'm going to split color-words diffs to by_line() and by_word() stages.

Perhaps, Diff::default_refinement() can be removed once all non-test callers
are migrated.
2024-08-18 12:40:07 +09:00
Benjamin Tan
f258664a2f rewrite: move_commits: do not remove parents of target commits which are outside the target set
This ensures consistency between the commands `jj rebase -r a::` and `jj
rebase -s a`.
2024-08-17 23:27:47 +08:00
Benjamin Tan
e5493e0fc0 rebase: modify tests to include commit's parent branch in log output 2024-08-17 23:27:47 +08:00
Martin von Zweigbergk
749a284354 working_copy: delete path() method from trait
We don't currently use the `path()` method. Not all working copies
even have a relevant path. For example, working copies on Google's
server don't.
2024-08-16 16:55:14 -07:00
Essien Ita Essien
237b41e738 next/prev: refactor movement utilities into cli/src/movement_utils.rs
The code in both cli/src/commands/{next,prev}.rs is identical except
for the direction of movement. This commit pull the parts that make
sense out into cli/src/movement_util.rs so it's easier to see the
differences.

Part of #3947
2024-08-16 23:21:00 +01:00
Essien Ita Essien
c6335ca655 next/prev: Add jj log output to more prev_next tests.
Add gratuitous `jj log` output to more points in the tests.
This makes it easier to understand the intended changes
by literally visualizing the commit tree we are after each movement.

This is at least useful for me since I find the new+squash workflow
confusing.

Test behaviour is not changed.

Part of #3947
2024-08-16 21:28:48 +01:00
Austin Seipp
5eab5c8d75 github: build on macos-13 for x86_64
We all noticed that x86 macOS binaries are no longer being provided on release,
due to `macos-11` runners going the way of the Dodo a while back. Nobody
alterted us to this, funny enough.

After some quick discussion, we concluded some things:

- x86 macOS runners are likely oversubscribed, and hurt CI latency badly
- `macos-12` is also deprecated; `macos-13` is the best x86 runner available
- GitHub probably isn't going to expand macOS runner capacity; `macos-13` will
one day go away
- Some people are still using `jj` on Intel Macs. We didn't get alerted because
they do their own builds for now, but may not always do that.
- We can just try to build on `macos-13` and make it optional for merges.

So that's what this does. It might be mergeable outright, but we can also use it
to measure build latency impacts.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-08-16 14:23:09 -05:00
dependabot[bot]
62095894d3 cargo: bump the cargo-dependencies group across 1 directory with 4 updates
Bumps the cargo-dependencies group with 4 updates in the / directory: [clap](https://github.com/clap-rs/clap), [libc](https://github.com/rust-lang/libc), [serde](https://github.com/serde-rs/serde) and [serde_json](https://github.com/serde-rs/json).


Updates `clap` from 4.5.15 to 4.5.16
- [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.5.15...clap_complete-v4.5.16)

Updates `libc` from 0.2.155 to 0.2.156
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Changelog](https://github.com/rust-lang/libc/blob/0.2.156/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.155...0.2.156)

Updates `serde` from 1.0.207 to 1.0.208
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.207...v1.0.208)

Updates `serde_json` from 1.0.124 to 1.0.125
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.124...1.0.125)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-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>
2024-08-16 12:26:14 -05:00
Yuya Nishihara
be35ab164c tests: restore snapshots of line/word-oriented diff hunks
test_diff_basic() is now testing file-level changes such as renames.
2024-08-16 22:16:36 +09:00
Matt Kulukundis
2f2e5fb72a copy-tracking: implement copy tracking for external tools 2024-08-16 07:48:43 -04:00
dependabot[bot]
7baf6675e7 github: bump github/codeql-action in the github-dependencies group
Bumps the github-dependencies group with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.26.1 to 3.26.2
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](29d86d22a3...429e197704)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-16 18:50:11 +08:00
Yuya Nishihara
085e17e1cc files: micro-optimzie DiffLine::reset_line() to not clone hunks 2024-08-16 09:30:30 +09:00
Yuya Nishihara
a973c7b0ea files: replace precomputed has_left/right_content flags with functions
I don't think the iteration cost would matter here, and it doesn't make sense
that has_left/right_content are cached whereas is_unmodified() isn't.
2024-08-16 09:30:30 +09:00
Yuya Nishihara
cca5277184 diff: clarify that DiffLine hunk doesn't have [left, right] diff pair
This will simplify users of line.hunks[] which I'm going to add.
2024-08-16 09:30:30 +09:00
Yuya Nishihara
ac27365290 files: ensure that DiffLineIterator hunk has exactly two inputs
I've made the constructor public, so let's add more sanity checks.
2024-08-16 09:30:30 +09:00
Matt Kulukundis
95e8dd51eb copy-tracking: add support for diff --git 2024-08-15 11:03:39 -04:00
dependabot[bot]
5694f235dd github: bump github/codeql-action in the github-dependencies group
Bumps the github-dependencies group with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.26.0 to 3.26.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](eb055d739a...29d86d22a3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-15 09:11:31 -05:00
Yuya Nishihara
78c0128ec3 files: make DiffLineIterator accept generic DiffLine iterator
I'm thinking of adding some heuristics to render hunks containing lots of
small word changes differently, in a similar manner to the unified diffs. This
patch might help add some pre/post-processing at consumer.

files::diff() is inlined to caller to get around 'self borrowing.
2024-08-15 20:06:12 +09:00
Yuya Nishihara
f85792288f files: replace Vec + index access with iterator in DiffLineIterator 2024-08-15 20:06:12 +09:00
Yuya Nishihara
54f5c01eae files: use imported DiffHunk type in DiffLineIterator 2024-08-15 20:06:12 +09:00
Yuya Nishihara
a62c8776e8 diff: move empty content optimization from diff() to Diff::for_tokenizer()
unchanged_ranges() already has the fast path for empty content, but we can
also disable tokenization.
2024-08-15 20:06:12 +09:00
Yuya Nishihara
73e4daf5ce tests: add more empty content diff samples 2024-08-15 20:06:12 +09:00
Yuya Nishihara
8b222e4038 cli: propagate BackendError from tree diffs 2024-08-15 20:02:56 +09:00
Benjamin Tan
ab604b4ecd rewrite::move_commits(): preserve order of parent commits
When rebasing a new child commit on top of the moved commit(s), the
order of the new child commit's parent commits is now correctly
preserved if the original parent commit is now a parent of the moved
commit(s).

Closes #3969.
2024-08-15 17:51:03 +08:00
Benjamin Tan
4a17b9fbe4 rebase: modify tests to avoid printing commit and change IDs
I think they were adding too much noise to commit diffs. Only the tests
focused on skipping rebasing will include the commit and change IDs,
other tests will omit them.
2024-08-15 17:51:03 +08:00
Matt Kulukundis
0b179dcbde copy-tracking: implement copy-tracking for --types 2024-08-14 20:48:43 -04:00
Matt Kulukundis
eccc3e235d copy-tracking: diff --name-only is a no-op 2024-08-14 19:52:19 -04:00
dependabot[bot]
49577f7f75 cargo: bump indexmap from 2.3.0 to 2.4.0 in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [indexmap](https://github.com/indexmap-rs/indexmap).


Updates `indexmap` from 2.3.0 to 2.4.0
- [Changelog](https://github.com/indexmap-rs/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/indexmap-rs/indexmap/compare/2.3.0...2.4.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>
2024-08-15 00:57:34 +08:00
Benjamin Tan
41e99ccdbf diff_util: add copy records tracking to DiffRenderer::show_patch
This allow `jj show --summary` and other commands to include copy
tracking information.
2024-08-14 23:16:17 +08:00
Benjamin Tan
f983021814 cli: add basic tests for show command 2024-08-14 23:16:17 +08:00
Matt Kulukundis
b67b774ba7 fix: small clippy warning 2024-08-14 10:21:28 -04:00
Essien Ita Essien
a6d8009097 Define builtin_immutable_heads() as a default revset alias.
* Add `builtin_immutable_heads()` in the `revsets.toml`.
* Redefine `immutable_heads()` in terms of `builtin_immutable_heads()`
* Warn if user redefines `builtin_immutable_heads()`, `mutable()` or
  `immutable()`.
* Update module constant in revset_util.rs from BUILTIN_IMMUTABLE_HEADS
  to USER_IMMUTABLE_HEADS to avoid confusion since it points at
  `immutable_heads()` **and** we now have a revset-alias
  literally named `builtin_immutable_heads()`.
* Add unittest
* Update CHANGELOG
* Update documentation.

Fixes: #4162
2024-08-14 11:32:16 +01:00
Matt Kulukundis
ec99a17ae8 copy-tracking: improve --summary and add --stat
- add support for copy tracking to `diff --stat`
- switch `--summary` to match git's output more closely
- rework `show_diff_summary` signature to be more consistent
2024-08-13 21:37:45 -04:00
dependabot[bot]
f5a25d7805 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [clap_complete](https://github.com/clap-rs/clap) and [serde](https://github.com/serde-rs/serde).


Updates `clap_complete` from 4.5.14 to 4.5.16
- [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.5.14...clap_complete-v4.5.16)

Updates `serde` from 1.0.206 to 1.0.207
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.206...v1.0.207)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-13 11:58:14 -07:00
Aaron Bull Schaefer
e803bed845 config: expand tilde in ssh key filepaths
Add home directory expansion for SSH key filepaths. This allows the
`signing.key` configuration value to work more universally across both
Linux and macOS without requiring an absolute path.

This moved and renamed the previous `expand_git_path` function to a more
generic location, and the prior use was updated accordingly.
2024-08-13 08:06:43 -07:00