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

rebase -s: add support for --insert-after and --insert-before #3607

Closed
wants to merge 1 commit into from

Conversation

bnjmnt4n
Copy link
Member

@bnjmnt4n bnjmnt4n commented May 1, 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

@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-nptwtmlksnsm branch from cac8365 to 21ee85d Compare August 16, 2024 18:51
@bnjmnt4n bnjmnt4n changed the title rebase -s, -d: add support for --insert-after and --insert-before rebase -s: add support for --insert-after and --insert-before Aug 16, 2024
@bnjmnt4n bnjmnt4n marked this pull request as ready for review August 16, 2024 19:03
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-nptwtmlksnsm branch from 21ee85d to 26380e1 Compare August 17, 2024 15:38
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just a partial review so far

Comment on lines 520 to 544
// Compute the roots of `target_commits` if not provided.
let target_roots: HashSet<_> = if target_roots.is_empty() {
connected_target_commits_internal_parents
.iter()
.filter(|(commit_id, parents)| {
target_commit_ids.contains(commit_id) && parents.is_empty()
})
.map(|(commit_id, _)| commit_id.clone())
.collect()
} else {
target_roots.iter().cloned().collect()
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test case?

.map(|(commit_id, _)| commit_id.clone())
.collect();
// Compute the roots of `target_commits` if not provided.
let target_roots: HashSet<_> = if target_roots.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make target_roots an Option instead so it's consistent (but useless, iiuc) with an empty list

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, target_commits and target_roots could be enum Revisions(_)|Roots(_)? I assume some connectivity checks can be skipped if Roots(_).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, target_commits and target_roots could be enum Revisions(_)|Roots(_)? I assume some connectivity checks can be skipped if Roots(_).

That's definitely an option. I was thinking that since this was a library function, we might want to allow customizing consumers to specify the target set of commits and the new roots of the set anyway. WDYT? Otherwise we can also change this to an enum like you suggested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think library function should support weird setup such as roots out of the target commits. If we can optimize for common configuration or guard against invalid parameters, I would choose restricted enum than free parameters. (They can be separate function entry points if that makes sense.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it's fine to revisit this tweak in a separate PR? I think it would be easier for me to follow up after these commits are merged, then have to individually go back and edit each commit to update the API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't mean the optimization for Root(..) should be added in this PR. I just meant the argument can be changed to Option or Revisions(_)|Roots(_).

cli/src/commands/rebase.rs Outdated Show resolved Hide resolved
cli/src/commands/rebase.rs Outdated Show resolved Hide resolved
cli/src/commands/rebase.rs Outdated Show resolved Hide resolved
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-nptwtmlksnsm branch 2 times, most recently from 80c684f to 4e23829 Compare August 24, 2024 14:57
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-nptwtmlksnsm branch 4 times, most recently from df412a6 to 5c8ab13 Compare October 13, 2024 19:14
@bnjmnt4n bnjmnt4n force-pushed the bnjmnt4n/push-nptwtmlksnsm branch from 5c8ab13 to 1a8f649 Compare October 14, 2024 10:36
@bnjmnt4n bnjmnt4n closed this Oct 14, 2024
@bnjmnt4n bnjmnt4n deleted the bnjmnt4n/push-nptwtmlksnsm branch October 14, 2024 10:38
@bnjmnt4n bnjmnt4n restored the bnjmnt4n/push-nptwtmlksnsm branch October 14, 2024 10:43
@bnjmnt4n
Copy link
Member Author

Oops, I accidentally force-pushed the wrong change to this branch, then deleted and recreated the branch but looks like this PR can no longer be reopened. Will recreate this.

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.

3 participants