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

Commits on Nov 13, 2024

  1. cli: git sync - Proof of concept

    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
    essiene committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    a31e01d View commit details
    Browse the repository at this point in the history