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

RFC: commit_builder: add public interface that writes temporary commit to store #4127

Merged
merged 7 commits into from
Jul 23, 2024

Conversation

yuja
Copy link
Contributor

@yuja yuja commented Jul 20, 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

yuja added 7 commits July 23, 2024 10:15
It's not wrong that String::clone_from() could potentially be cheaper.
I'm going to extract an inner builder that is free from &mut MutableRepo
lifetime.
…commit

I'll add another write() method that doesn't consume self, which will have to
clone self.commit.
This allows us to construct a builder, format description template with an
intermediate commit, then write() a final commit object to the repo.

I originally considered removing mut_repo from CommitBuilder at all, but
rewriter APIs rely on that CommitBuilder has &mut_repo, and splitting them
would make call sites uglier.

The inner builder methods are based on &mut Self instead of Self, because it's
easier to wrap, and users of the inner builder will bind it to a named variable
anyway.
…store

In order to render description template, we'll need a Commit object that
represents the old state (with new tree and parents) before updating the
commit description. The added functions will help generate an intermediate
Commit object.

Alternatively, we can create an in-memory Commit object with some fake
CommitId. It should be lightweight, but might cause weird issue because the
fake id wouldn't be found in the store.

I think it's okay to write a temporary commit and rely on GC as we do for
merge trees. However, I should note that temporary commits are more likely to
be preserved as they are pinned by no-gc refs until "jj util gc".
I think this makes it clear that the builder doesn't add any rewrite records
to the mut_repo.
@yuja yuja force-pushed the push-qustslrzqkwk branch from 5d127ae to b54ff86 Compare July 23, 2024 09:14
@yuja yuja enabled auto-merge (rebase) July 23, 2024 09:20
@yuja yuja merged commit 626aa90 into jj-vcs:main Jul 23, 2024
17 checks passed
@yuja yuja deleted the push-qustslrzqkwk branch July 23, 2024 09:22
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