Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merged_tree: split function that merges trees without resolving conflicts #4250

Merged
merged 4 commits into from
Aug 11, 2024

Conversation

yuja
Copy link
Contributor

@yuja yuja commented Aug 10, 2024

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

lib/src/default_index/revset_engine.rs Outdated Show resolved Hide resolved
lib/src/merged_tree.rs Outdated Show resolved Hide resolved
lib/src/rewrite.rs Show resolved Hide resolved
lib/tests/test_revset.rs Outdated Show resolved Hide resolved
yuja added 2 commits August 11, 2024 11:42
If a null tree were written to the store, GitBackend would crash because of
invalid hash length.
@yuja yuja force-pushed the push-qwozyprmmtuo branch from 3f827f3 to 5394975 Compare August 11, 2024 02:44
yuja added 2 commits August 11, 2024 11:50
These tests would fail if trees are compared without resolving file conflicts.
This allows us to diff trees without fully resolving conflicts:

    let from_tree = merge_no_resolve(..);
    for (path, (from, to)) in from_tree.diff(to_tree, matcher) {
        let from = resolve_conflicts(from);
        if from == to {
            continue; // resolved file may be identical
        ...

I originally considered adding a matcher argument to merge() functions, but the
resulting API looked misleading. If merge() took a matcher, callers might expect
unmatched trees and files were omitted, not left unresolved. It's also slower
than diffing unresolved trees because merge(.., matcher) would have to write
partially resolved trees to the store.

Since "ancestor_tree" isn't resolved by itself, this patch has subtle behavior
change. For example, "jj diff -r9eaef582" in the "git" repository is no longer
empty. I think the new behavior is also technically correct, but I'm not pretty
sure.
@yuja yuja force-pushed the push-qwozyprmmtuo branch from 5394975 to b17d8ab Compare August 11, 2024 02:50
@yuja yuja merged commit c9e147c into jj-vcs:main Aug 11, 2024
17 checks passed
@yuja yuja deleted the push-qwozyprmmtuo branch August 11, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants