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

FR: Generalizable and reusable "rebase behavior" #4708

Open
arxanas opened this issue Oct 24, 2024 · 2 comments
Open

FR: Generalizable and reusable "rebase behavior" #4708

arxanas opened this issue Oct 24, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@arxanas
Copy link
Contributor

arxanas commented Oct 24, 2024

Is your feature request related to a problem? Please describe.

There's been a proliferation of flags added to various commands that create or rebase commits. For example, --insert-before/--insert-after should be added to many commands, but hasn't been yet. Rebasing is a core competency and reason to use jj. I think we should invest in a unified flexible design to control "rebase behavior" rather than add more flags.

Most commands that create or rebase commits could reuse some of these options, including:

  • jj abandon
  • jj commit
  • jj describe
  • jj duplicate
  • jj new
  • jj parallelize
  • jj rebase
  • jj split
  • jj squash

Describe the solution you'd like

Roughly speaking jj rebase --dest X (and similar for other commands) should accept an expression representing "rebase behavior" (and also accept a revset for backward compatibility and the common case).

As an example, suppose you're using a "mega-merge" strategy. You have a bunch of commits in X that you want to insert before the mega-merge commit as standalone commits. You want to take this opportunity to also write some helpful messages for each commit. If this wouldn't merge cleanly, then you want to abort the operation rather than produce conflicts. An example invocation might look like this:

$ jj rebase -r X -d 'behavior(after=trunk(), before=@, topology="horizontal", empty="keep", message="prompt", merge="abort")'

However, if you have a commit in X and you need to split it as part of doing the mega-merge, then maybe you'll issue an invocation like this:

$ jj split -r X -d 'behavior(after=trunk(), before=@, topology="horizontal", message="prompt", merge="ours")'

To demonstrate the general applicability of this design, see the issues linked below.

Given a commit set X that's being rebased, the following are some relevant axes to control rebase behavior:

Describe alternatives you've considered

  • Preserve current behavior. Add flags to each command that might need them. I think it's extra work overall and results in a less flexible/coherent system. However, command-line flags are generally more discoverable/accessible than the revset language.

Additional context

This also covers some use-cases for #3814, but is not a complete substitute.

@arxanas arxanas added the enhancement New feature or request label Oct 24, 2024
@joyously
Copy link

This seems like a lot of options. Hopefully, all will be considered in the context of undo and of simultaneous access (scripts in two windows).

@arxanas
Copy link
Contributor Author

arxanas commented Oct 25, 2024

This seems like a lot of options. Hopefully, all will be considered in the context of undo and of simultaneous access (scripts in two windows).

I don't think we need to do anything special to support undo for this design. I believe we basically snapshot the repo before and after the operation, without regard to which operations actually ran. Simultaneous modifications are a problem, but not specific to this either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants