-
Notifications
You must be signed in to change notification settings - Fork 322
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
rewrite.rs: fix working copy position after jj rebase --abandon-empty
#2901
Conversation
The `edit` argument seems to be true if and only if the old commit was *not* abandoned. So, I flipped its value and renamed it to `abandoned_old_commit`.
I think I'll end up changing that code for the fix for #2600 anyway. I think your commit is fine as is. |
Thanks! |
I think this is actually buggy if the working copy is empty and you do Lines 294 to 300 in 7c87fe2
so the references (and the working copy) will not be updated properly when that call abandons a commit. Ideally, DescendantRebaser should keep track of this information internally, e.g. I will try to write a test and then fix it that way, but I'm not 100% sure it will work. It's confusing to me that Another alternative would be to backout this PR for now. The old behavior is wrong, but not dangerous. This is the kind of thing that bothers me about the API: details that should be governed by the rewrite crate leak out into the CLI crate, and we pretty much have to think about every use of the rewrite crate when changing anything in it. |
This mostly reverts martinvonz#2901 as well as its fixup martinvonz#2903. The related bug is reopened, see martinvonz#2869 (comment). The problem is that while the fix did fix martinvonz#2896 in most cases, it did reintroduce the more severe bug martinvonz#2760 in one case, if the working copy is the commit being rebased. For example, suppose you have the tree ``` root -> A -> B -> @ (empty) -> C ``` ### Before this commit #### Case 1 `jj rebase -s B -d root` would work perfectly before this commit, resulting in ``` root -> A \-------B -> C \- @ (new, empty) ``` #### Case 2 Unfortunately, if you run `jj rebase -s @ -d A`, you'd have the following result (before this commit), which shows the reintroduction of martinvonz#2760: ``` root -> A @ -> C \-- B ``` with the working copy at `A`. The reason for this is explained in martinvonz#2901 (comment). ### After this commit After this commit, both case 1 and case 2 will be wrong in the sense of martinvonz#2896, it will not exhibit the worse bug martinvonz#2760. Case 1 would result in: ``` root -> A \-------B -> @ (empty) -> C ``` Case 2 would result in: ``` root -> A -> @ -> C \-- B ``` with the working copy remaining a descendant of A
This mostly reverts martinvonz#2901 as well as its fixup martinvonz#2903. The related bug is reopened, see martinvonz#2869 (comment). The problem is that while the fix did fix martinvonz#2896 in most cases, it did reintroduce the more severe bug martinvonz#2760 in one case, if the working copy is the commit being rebased. For example, suppose you have the tree ``` root -> A -> B -> @ (empty) -> C ``` ### Before this commit #### Case 1 `jj rebase -s B -d root --abandon-empty` would work perfectly before this commit, resulting in ``` root -> A \-------B -> C \- @ (new, empty) ``` #### Case 2 Unfortunately, if you run `jj rebase -s @ -d A --abandon-empty`, you'd have the following result (before this commit), which shows the reintroduction of martinvonz#2760: ``` root -> A @ -> C \-- B ``` with the working copy at `A`. The reason for this is explained in martinvonz#2901 (comment). ### After this commit After this commit, both case 1 and case 2 will be wrong in the sense of martinvonz#2896, but it will no longer exhibit the worse bug martinvonz#2760 in the second case. Case 1 would result in: ``` root -> A \-------B -> @ (empty) -> C ``` Case 2 would result in: ``` root -> A -> @ -> C \-- B ``` with the working copy remaining a descendant of A
This mostly reverts martinvonz#2901 as well as its fixup martinvonz#2903. The related bug is reopened, see martinvonz#2869 (comment). The problem is that while the fix did fix martinvonz#2896 in most cases, it did reintroduce the more severe bug martinvonz#2760 in one case, if the working copy is the commit being rebased. For example, suppose you have the tree ``` root -> A -> B -> @ (empty) -> C ``` ### Before this commit #### Case 1 `jj rebase -s B -d root --abandon-empty` would work perfectly before this commit, resulting in ``` root -> A \-------B -> C \- @ (new, empty) ``` #### Case 2 Unfortunately, if you run `jj rebase -s @ -d A --abandon-empty`, you'd have the following result (before this commit), which shows the reintroduction of martinvonz#2760: ``` root -> A @ -> C \-- B ``` with the working copy at `A`. The reason for this is explained in martinvonz#2901 (comment). ### After this commit After this commit, both case 1 and case 2 will be wrong in the sense of martinvonz#2896, but it will no longer exhibit the worse bug martinvonz#2760 in the second case. Case 1 would result in: ``` root -> A \-------B -> @ (empty) -> C ``` Case 2 would result in: ``` root -> A -> @ -> C \-- B ``` with the working copy remaining a descendant of A
This mostly reverts martinvonz#2901 as well as its fixup martinvonz#2903. The related bug is reopened, see martinvonz#2869 (comment). The problem is that while the fix did fix martinvonz#2869 in most cases, it did reintroduce the more severe bug martinvonz#2760 in one case, if the working copy is the commit being rebased. For example, suppose you have the tree ``` root -> A -> B -> @ (empty) -> C ``` ### Before this commit #### Case 1 `jj rebase -s B -d root --abandon-empty` would work perfectly before this commit, resulting in ``` root -> A \-------B -> C \- @ (new, empty) ``` #### Case 2 Unfortunately, if you run `jj rebase -s @ -d A --abandon-empty`, you'd have the following result (before this commit), which shows the reintroduction of martinvonz#2760: ``` root -> A @ -> C \-- B ``` with the working copy at `A`. The reason for this is explained in martinvonz#2901 (comment). ### After this commit After this commit, both case 1 and case 2 will be wrong in the sense of martinvonz#2869, but it will no longer exhibit the worse bug martinvonz#2760 in the second case. Case 1 would result in: ``` root -> A \-------B -> @ (empty) -> C ``` Case 2 would result in: ``` root -> A -> @ -> C \-- B ``` with the working copy remaining a descendant of A
This mostly reverts martinvonz#2901 as well as its fixup martinvonz#2903. The related bug is reopened, see martinvonz#2869 (comment). The problem is that while the fix did fix martinvonz#2869 in most cases, it did reintroduce the more severe bug martinvonz#2760 in one case, if the working copy is the commit being rebased. For example, suppose you have the tree ``` root -> A -> B -> @ (empty) -> C ``` ### Before this commit #### Case 1 `jj rebase -s B -d root --skip-empty` would work perfectly before this commit, resulting in ``` root -> A \-------B -> C \- @ (new, empty) ``` #### Case 2 Unfortunately, if you run `jj rebase -s @ -d A --skip-empty`, you'd have the following result (before this commit), which shows the reintroduction of martinvonz#2760: ``` root -> A @ -> C \-- B ``` with the working copy at `A`. The reason for this is explained in martinvonz#2901 (comment). ### After this commit After this commit, both case 1 and case 2 will be wrong in the sense of martinvonz#2869, but it will no longer exhibit the worse bug martinvonz#2760 in the second case. Case 1 would result in: ``` root -> A \-------B -> @ (empty) -> C ``` Case 2 would result in: ``` root -> A -> @ -> C \-- B ``` with the working copy remaining a descendant of A
This mostly reverts #2901 as well as its fixup #2903. The related bug is reopened, see #2869 (comment). The problem is that while the fix did fix #2869 in most cases, it did reintroduce the more severe bug #2760 in one case, if the working copy is the commit being rebased. For example, suppose you have the tree ``` root -> A -> B -> @ (empty) -> C ``` ### Before this commit #### Case 1 `jj rebase -s B -d root --skip-empty` would work perfectly before this commit, resulting in ``` root -> A \-------B -> C \- @ (new, empty) ``` #### Case 2 Unfortunately, if you run `jj rebase -s @ -d A --skip-empty`, you'd have the following result (before this commit), which shows the reintroduction of #2760: ``` root -> A @ -> C \-- B ``` with the working copy at `A`. The reason for this is explained in #2901 (comment). ### After this commit After this commit, both case 1 and case 2 will be wrong in the sense of #2869, but it will no longer exhibit the worse bug #2760 in the second case. Case 1 would result in: ``` root -> A \-------B -> @ (empty) -> C ``` Case 2 would result in: ``` root -> A -> @ -> C \-- B ``` with the working copy remaining a descendant of A
Fixes #2869.
I did this somewhat mechanically. Let me know if I missed some situation where this could do the wrong thing. This could happen especially if the rename in the first commit doesn't match the actual meaning of the argument.