~jan0sch/darcs-book
Showing details for patch 1e1e517b5c1477044963d9c16ae162b08b184e89.
diff -rN -u old-darcs-book/en/08-rewriting-history.md new-darcs-book/en/08-rewriting-history.md --- old-darcs-book/en/08-rewriting-history.md 2024-11-23 12:43:04.228836381 +0000 +++ new-darcs-book/en/08-rewriting-history.md 2024-11-23 12:43:04.228836381 +0000 @@ -408,3 +408,165 @@ repository. This is particularly useful if you have applied local patches to your repository that clash with remote patches. To remove local-only patches just add the `--not-in-remote` flag. + +All your `rebase` are belong to us! +----------------------------------- + +Sometimes `amend` just does not cut it. We might need to go deeper because we +have spotted a mistake we have made in a patch further down our dependency +chain. Imagine the following situation. + +``` +$ darcs log +patch 7f4723c5a539c75fce70dd7a3e7b12fcb284aa7b +Author: raichoo@example.com +Date: Mon Aug 17 12:16:01 CEST 2020 + * C + +patch 7ed8dfe47953186ca4d97cee32898e926bf5eb7e +Author: raichoo@example.com +Date: Mon Aug 17 12:15:24 CEST 2020 + * B + +patch d3fbcaf6e187b1e582caf031d39f29ddf332570b +Author: raichoo@example.com +Date: Mon Aug 17 12:15:08 CEST 2020 + * A +``` + +As it turns out, I made a mistake in patch `B` which I want to repair before +pushing my changes to the remote repository. So let's try to `amend` `B`. + +``` +$ darcs amend +patch 7f4723c5a539c75fce70dd7a3e7b12fcb284aa7b +Author: raichoo@example.com +Date: Mon Aug 17 12:16:01 CEST 2020 + * C +Shall I amend this patch? [yNjk...], or ? for more options: n + +Skipping depended-upon patch: +patch 7ed8dfe47953186ca4d97cee32898e926bf5eb7e +Author: raichoo@example.com +Date: Mon Aug 17 12:15:24 CEST 2020 + * B + +Skipping depended-upon patch: +patch d3fbcaf6e187b1e582caf031d39f29ddf332570b +Author: raichoo@example.com +Date: Mon Aug 17 12:15:08 CEST 2020 + * A +Cancelling amend since no patch was selected. +``` + +Oh no! What happened? We cannot `amend` `B`. `darcs` does not even prompt it as +an option here. Why is that? Let's take a look at the dependency graph to shed a +little light onto the situation and things will become a little clearer. + +![](../img/dependencies-8.png) + +Ah! `C` depends on `B` and `A`, so we can not simply `amend` `B` because we +would pull the rug from under `C`'s feet (remember that `amend` changes patch +identity, but `C` already depends on `B`). What we could do is just `unrecord` +`C`, then `amend` `B` and `record` `C` again. That would work, but it's not a +very good approach if you have to go multiple patches deeper. You don't want to +re-`record` all of them again, it would be way too much work and also quite +error prone. + +Here is where `rebase` comes into play. As the name suggests, it allows us to +change the dependencies a patch it based on. Naturally this means we are changing +the patches identity that we are rebasing, since we are changing what they are +depending on. + +So how does it work? + +The `rebase` command allows us to `suspend` and `unsuspend` patches. Suspending +means that we putting a patch on the side, it doesn't really apply to our +repository anymore, but it is still floating around in a suspended state though. +So we want to work on `B`, that means that we first have to suspend `C`. + +``` +$ darcs rebase suspend +patch 7f4723c5a539c75fce70dd7a3e7b12fcb284aa7b +Author: raichoo@example.com +Date: Mon Aug 17 12:16:01 CEST 2020 + * C +Shall I suspend this patch? (1/3) [ynW...], or ? for more options: y +patch 7ed8dfe47953186ca4d97cee32898e926bf5eb7e +Author: raichoo@example.com +Date: Mon Aug 17 12:15:24 CEST 2020 + * B +Shall I suspend this patch? (2/3) [ynW...], or ? for more options: d +Rebase in progress: 1 suspended patch +``` + +In the last line tells us that there is one suspended patch, waiting for us to +take care of it. If we log take a look at our `log` we can see that `C` is no +longer part of our repository. This is going to happen with every command that +we issue at this point, just to make sure that we do not forget about the +patches we are currently rebasing. + +``` +$ darcs log +patch 7ed8dfe47953186ca4d97cee32898e926bf5eb7e +Author: raichoo@example.com +Date: Mon Aug 17 12:15:24 CEST 2020 + * B + +patch d3fbcaf6e187b1e582caf031d39f29ddf332570b +Author: raichoo@example.com +Date: Mon Aug 17 12:15:08 CEST 2020 + * A +Rebase in progress: 1 suspended patch +``` + +We can also take a look at all our suspended patches using `darcs rebase log`. + +``` +$ darcs rebase log +patch 0919c58f931ffcc93bc5fbe41f8fdcc0a9fab1ba +Author: raichoo@example.com +Date: Mon Aug 17 12:16:01 CEST 2020 + * C +Rebase in progress: 1 suspended patch +``` + +Perfect! `C` is waiting for us to finish our work. We can now do all the +operations we want without taking our suspended patch into account. You might +also have realized that the hash of the suspended patch has changed. This +happens every time we `suspend` a patch, so should not do this with patches you +have already published. + +We have now brought `B` into shape. It's time to `unsuspend` `C` again! + +``` +$ darcs rebase unsuspend +patch 0919c58f931ffcc93bc5fbe41f8fdcc0a9fab1ba +Author: raichoo@example.com +Date: Mon Aug 17 12:16:01 CEST 2020 + * C +Shall I unsuspend this patch? (1/1) [ynW...], or ? for more options: y +Do you want to Unsuspend these patches? [Yglqk...], or ? for more options: y +Rebase finished! + +$ darcs log +patch bcd766f6817c2c4757101db96f241e86cb47571f +Author: raichoo@example.com +Date: Mon Aug 17 14:20:14 CEST 2020 + * C + +patch 08d1ebf883423391e80152a9d0562b569df8b4cf +Author: raichoo@example.com +Date: Mon Aug 17 13:16:12 CEST 2020 + * B + +patch d3fbcaf6e187b1e582caf031d39f29ddf332570b +Author: raichoo@example.com +Date: Mon Aug 17 12:15:08 CEST 2020 + * A + +``` + +Great, we are back to where we started but we have adjusted `B` to our liking. +Once we `unsuspend` our patch, it changes its hash one last time and the +`rebase` is completed. diff -rN -u old-darcs-book/en/index.md new-darcs-book/en/index.md --- old-darcs-book/en/index.md 2024-11-23 12:43:04.228836381 +0000 +++ new-darcs-book/en/index.md 2024-11-23 12:43:04.228836381 +0000 @@ -64,6 +64,7 @@ * [Unrecording patches](chapter08.html#unrecording-patches) * [Unrecording individual changes](chapter08.html#unrecording-individual-changes) * [OB-LIT-E-RATE!](chapter08.html#ob-lit-e-rate) + * [All your `rebase` are belong to us!](chapter08.html#all-your-rebase-are-belong-to-us) * [tag! You're it!](chapter09.html) * [Pulling tags](chapter09.html#pulling-tags) * [A tale of dirty tags](chapter09.html#a-tale-of-dirty-tags)