-
Notifications
You must be signed in to change notification settings - Fork 339
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
Implement jj sync
command
#1039
Comments
I could also imagine some related curation tools for e.g. moving a local branch to "draft mode" to not be published or synced yet. |
This is also one of the areas jj was dinged in the comparison table at https://blog.waleedkhan.name/git-ui-features/#data. |
IMHO |
I think |
Hmm, that's a good point. On the other hand, I don't think we've had any confusion about that at Google with our
I think Git's use of "pull" for "fetch+rebase/merge" is quite confusing. I prefer hg's use of |
That's not representative, because ~everybody at Google has used Perforce/Piper. FWIW, VSCode has a "Sync" button that pulls and pushes... |
True. (I have practically not used it, but I still have run
Oh, that's a good data point! We'd still have to think of a better name then... There's |
IMHO, |
Graphite also uses "sync" to refer to this same kind of "pull-and-restack" operation: https://docs.graphite.dev/guides/graphite-cli/syncing-and-resolving-conflicts Do we envision jj ever would support that kind of bidirectional "pull + push"? If so, maybe we have a command called sync that defaults to |
I skipped Piper and went straight to Fig, and found |
Now that #1288 is in, you can get part of the way to Another, simpler, alternative if you're OK with rebasing everything not on main: |
We discussed Summary: While I was initially sceptical of the namespaced approach, I now think it is the right solution for this problem. The only issue I see, if we take the forge-specific approach, is that some layering issue may pop up. But if we implement something like |
We will need this in the `jj git sync` command to perform a fetch that behaves the same as the `jj git fetch` command. Fetch extract the function in this commit, so diffs are easier to review. A later commit will move this function (and associated functions) out to cli/src/git_util.rs Part of: #1039
We will need this in the `jj git sync` command to perform a fetch that behaves the same as the `jj git fetch` command. Fetch extract the function in this commit, so diffs are easier to review. A later commit will move this function (and associated functions) out to cli/src/git_util.rs Part of: #1039
We will need this in the `jj git sync` command to perform a fetch that behaves the same as the `jj git fetch` command. Part of: #1039
* map old heads -> new heads * rebase * roots are candidates with parents with updated heads. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
* First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. Issue: #1039
* map old heads -> new heads * rebase * roots are candidates with parents with updated heads. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [ ] Rebase * [X] Build old -> new map * [ ] transform descendants ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [ ] Rebase * [X] Build old -> new map * [ ] transform descendants ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * implement CommitRewritter::repo() to return an immutable reference. * transform_descendants() roots are candidates with parents in update_record. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039
Similarly to `git_fetch`, this will be used in `jj git sync`, so moving this out to maintain the same behaviour across `fetch` command and `sync`. * Refactor out `get_fetch_remotes` to `git_util.rs`. * inline the different `get_*_remote*` functions into `get_fetch_remotes`; The resulting function is still small enough to be easily readable. * Move `get_single_remote` into `git_util.rs` and update call sites. * Use common FetchArgs to pass arguments both to `get_fetch_remotes` and `git_fetch` * Update use references All tests still pass. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants # git sync: Setup scaffolding ## Details * First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. * Set up some tracing guards which will help debugging when run with --debug. # git sync: Get branch heads and fetch from remote. ## Details * For branch heads, we grab local branches matching the pattern specified in args. * Pre-fetch heads query tx.base_repo() while post-fetch heads query tx.repo(); tx.repo() is the in memory Mutable repo which is updated after a fetch in a transaction. * We fetch from all branches from all configured remotes. --all_remotes affects if we use `git.fetch` or all repo remotes. # git sync: Build candidate commits. ## Details * Candidate commits (parent_id, child_id) are: * branch commits * and their descendants * which are not found in untracked remote branches # git sync: Build update record ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. # git sync: unhide `jj git sync` ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG # git sync: Rebase commits onto new branch heads. ## Details * implement CommitRewritter::repo() to return an immutable reference. * transform_descendants() roots are candidates with parents in update_record. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
Similarly to `git_fetch`, this will be used in `jj git sync`, so moving this out to maintain the same behaviour across `fetch` command and `sync`. * Refactor out `get_fetch_remotes` to `git_util.rs`. * inline the different `get_*_remote*` functions into `get_fetch_remotes`; The resulting function is still small enough to be easily readable. * Move `get_single_remote` into `git_util.rs` and update call sites. * Use common FetchArgs to pass arguments both to `get_fetch_remotes` and `git_fetch` * Update use references All tests still pass. Issue: #1039
Similarly to `git_fetch`, this will be used in `jj git sync`, so moving this out to maintain the same behaviour across `fetch` command and `sync`. * Refactor out `get_fetch_remotes` to `git_util.rs`. * inline the different `get_*_remote*` functions into `get_fetch_remotes`; The resulting function is still small enough to be easily readable. * Move `get_single_remote` into `git_util.rs` and update call sites. * Use common FetchArgs to pass arguments both to `get_fetch_remotes` and `git_fetch` * Update use references All tests still pass. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants # git sync: Setup scaffolding ## Details * First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. * Set up some tracing guards which will help debugging when run with --debug. # git sync: Get branch heads and fetch from remote. ## Details * For branch heads, we grab local branches matching the pattern specified in args. * Pre-fetch heads query tx.base_repo() while post-fetch heads query tx.repo(); tx.repo() is the in memory Mutable repo which is updated after a fetch in a transaction. * We fetch from all branches from all configured remotes. --all_remotes affects if we use `git.fetch` or all repo remotes. # git sync: Build candidate commits. ## Details * Candidate commits (parent_id, child_id) are: * branch commits * and their descendants * which are not found in untracked remote branches # git sync: Build update record ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. # git sync: unhide `jj git sync` ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG # git sync: Rebase commits onto new branch heads. ## Details * implement CommitRewritter::repo() to return an immutable reference. * transform_descendants() roots are candidates with parents in update_record. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants # git sync: Setup scaffolding ## Details * First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. * Set up some tracing guards which will help debugging when run with --debug. # git sync: Get branch heads and fetch from remote. ## Details * For branch heads, we grab local branches matching the pattern specified in args. * Pre-fetch heads query tx.base_repo() while post-fetch heads query tx.repo(); tx.repo() is the in memory Mutable repo which is updated after a fetch in a transaction. * We fetch from all branches from all configured remotes. --all_remotes affects if we use `git.fetch` or all repo remotes. # git sync: Build candidate commits. ## Details * Candidate commits (parent_id, child_id) are: * branch commits * and their descendants * which are not found in untracked remote branches # git sync: Build update record ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. # git sync: unhide `jj git sync` ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG # git sync: Rebase commits onto new branch heads. ## Details * implement CommitRewritter::repo() to return an immutable reference. * transform_descendants() roots are candidates with parents in update_record. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants # git sync: Setup scaffolding ## Details * First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. * Set up some tracing guards which will help debugging when run with --debug. # git sync: Get branch heads and fetch from remote. ## Details * For branch heads, we grab local branches matching the pattern specified in args. * Pre-fetch heads query tx.base_repo() while post-fetch heads query tx.repo(); tx.repo() is the in memory Mutable repo which is updated after a fetch in a transaction. * We fetch from all branches from all configured remotes. --all_remotes affects if we use `git.fetch` or all repo remotes. # git sync: Build candidate commits. ## Details * Candidate commits (parent_id, child_id) are: * branch commits * and their descendants * which are not found in untracked remote branches # git sync: Build update record ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. # git sync: unhide `jj git sync` ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG # git sync: Rebase commits onto new branch heads. ## Details * implement CommitRewritter::repo() to return an immutable reference. * transform_descendants() roots are candidates with parents in update_record. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants # git sync: Setup scaffolding ## Details * First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. * Set up some tracing guards which will help debugging when run with --debug. # git sync: Get branch heads and fetch from remote. ## Details * For branch heads, we grab local branches matching the pattern specified in args. * Pre-fetch heads query tx.base_repo() while post-fetch heads query tx.repo(); tx.repo() is the in memory Mutable repo which is updated after a fetch in a transaction. * We fetch from all branches from all configured remotes. --all_remotes affects if we use `git.fetch` or all repo remotes. # git sync: Build candidate commits. ## Details * Candidate commits (parent_id, child_id) are: * branch commits * and their descendants * which are not found in untracked remote branches # git sync: Build update record ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. # git sync: unhide `jj git sync` ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG # git sync: Rebase commits onto new branch heads. ## Details * implement CommitRewritter::repo() to return an immutable reference. * transform_descendants() roots are candidates with parents in update_record. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
Similarly to `git_fetch`, this will be used in `jj git sync`, so moving this out to maintain the same behaviour across `fetch` command and `sync`. * Refactor out `get_fetch_remotes` to `git_util.rs`. * inline the different `get_*_remote*` functions into `get_fetch_remotes`; The resulting function is still small enough to be easily readable. * Move `get_single_remote` into `git_util.rs` and update call sites. * Use common FetchArgs to pass arguments both to `get_fetch_remotes` and `git_fetch` * Update use references All tests still pass. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants # git sync: Setup scaffolding ## Details * First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. * Set up some tracing guards which will help debugging when run with --debug. # git sync: Get branch heads and fetch from remote. ## Details * For branch heads, we grab local branches matching the pattern specified in args. * Pre-fetch heads query tx.base_repo() while post-fetch heads query tx.repo(); tx.repo() is the in memory Mutable repo which is updated after a fetch in a transaction. * We fetch from all branches from all configured remotes. --all_remotes affects if we use `git.fetch` or all repo remotes. # git sync: Build candidate commits. ## Details * Candidate commits (parent_id, child_id) are: * branch commits * and their descendants * which are not found in untracked remote branches # git sync: Build update record ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. # git sync: unhide `jj git sync` ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG # git sync: Rebase commits onto new branch heads. ## Details * implement CommitRewritter::repo() to return an immutable reference. * transform_descendants() roots are candidates with parents in update_record. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants # git sync: Setup scaffolding ## Details * First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. * Set up some tracing guards which will help debugging when run with --debug. # git sync: Get branch heads and fetch from remote. ## Details * For branch heads, we grab local branches matching the pattern specified in args. * Pre-fetch heads query tx.base_repo() while post-fetch heads query tx.repo(); tx.repo() is the in memory Mutable repo which is updated after a fetch in a transaction. * We fetch from all branches from all configured remotes. --all_remotes affects if we use `git.fetch` or all repo remotes. # git sync: Build candidate commits. ## Details * Candidate commits (parent_id, child_id) are: * branch commits * and their descendants * which are not found in untracked remote branches # git sync: Build update record ## Details Build a record of old branch heads mapped to the new branch heads. This record will be used to derive the candidates that need rebasing. # git sync: unhide `jj git sync` ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG # git sync: Rebase commits onto new branch heads. ## Details * implement CommitRewritter::repo() to return an immutable reference. * transform_descendants() roots are candidates with parents in update_record. * simplify parent merge * drop newly emptied commits * update new parents from the updated heads set if the old parents are ancestors. Issue: #1039
jj should have a command to sync all of my branches (or some subset) with a remote via merge or rebase, in a single operation.
Since that could cause a lot of big changes at once, it'd be nice to show a preview of changes that will be performed and prompt to confirm and/or output a very clear summary of what all changed from that sync operation.
The text was updated successfully, but these errors were encountered: