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

PoC: Implement jj git sync - v1 #4824

Draft
wants to merge 1 commit into
base: essiene/pmwupzxmwsqz
Choose a base branch
from

Conversation

essiene
Copy link
Collaborator

@essiene essiene commented Nov 10, 2024

This is not meant to be merged in this form.
I am bashing everything on the head with a large bat, until it works. Once everything works nicely in this draft, I will break it up into smaller tested pieces that are intended to be merged.

  • Grab current heads and build a set of [(Parent, Child)...]
  • Start a transaction.
  • Fetch in the transaction.
  • Grab current heads on transaction:
    • Transaction MutableRepo should be updated after fetch.
    • Build a Map where old heads are the keys and the new heads are values.
      • If old == new, skip it.
      • This way if nothing changed, we end up with an empty map and avoid bugs downstream (index.is_ancestor returns true if old == new).
    • Relationship is figured out by index.is_ancestor(old_head_id, new_head_id) in a loop.
  • Check if rebase is needed.
    • old_heads.set_diffence(new_heads) gives old heads that are no longer heads, which would mean, their descendants need to be rebased.
  • Find children needing rebase:
    • Build list of rebase specs with: (commit, old_parent, new_parent)
    • IMPORTANT: Not YET handling parent commits deleted in remotes.
  • Perform simple rebase which abandons emptied commits.

Part of: #1039

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

@essiene essiene force-pushed the essiene/tknsxroqylmx branch 2 times, most recently from 9720683 to a28c7e1 Compare November 11, 2024 21:27
@essiene essiene force-pushed the essiene/tknsxroqylmx branch 4 times, most recently from 344f0ae to 1225a22 Compare November 12, 2024 20:36
@essiene essiene force-pushed the essiene/tknsxroqylmx branch 2 times, most recently from 4aa68ec to e4de5bc Compare November 13, 2024 22:48
This is not meant to be merged in this form.
I am bashing everything on the head with a large bat, until it works.
Once everything works nicely in this draft, I will break it up into
smaller tested pieces that are intended to be merged.

* Grab current heads and build a set of [(Parent, Child)...]
* Start a transaction.
* Fetch in the transaction:
    It's extremely  important to fetch *all* branches from *all* remotes.
    This is because if we don't fetch all branches, when we start rebasing,
    a root branch may be merged upstream with contents of a branch we didn't
    fetch, so we end up with conflicts. It's safest to always fetch all branches
    and then only rebase what we need.
* Grab current heads on transaction:
  * Transaction MutableRepo should be updated after fetch.
  * Build a Map where old heads are the keys and the new heads are values.
    * If old == new, skip it.
    * This way if nothing changed, we end up with an empty map and avoid bugs
      downstream (index.is_ancestor returns true if old == new).
  * Relationship is figured out by index.is_ancestor(old_head_id, new_head_id) in a loop.
* Check if rebase is needed.
  * old_heads.set_diffence(new_heads) gives old heads that are no longer heads, which would
    mean, their descendants need to be rebased.
* Find children needing rebase:
  * Build list of rebase specs with: (commit, new_parent)
    * commit is the immdiate child of old_heads needing rebase.
* call repo_mut.transform_descendants with a rewritter closure.
  * simplify_merge
  * rewrite commits matching the rebase_specs
  * for all other commits, if any new_parents match old_heads in our old -> new mapping,
    update those to point at the updated heads.
  * rebase with emptying newly emptied commits.


Issue: #1039
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.

1 participant