Search code examples
version-controlmergeplasticscm

Re-apply a merge in Plastic after changes were lost?


In our source control, one commit accidentally undid several merged branches of changes. I'm assuming what happened was the developer copied the files to another location outside of source control, modified them there, updated the workspace to the latest changeset, then copied in his changes. This effectively reverted multiple changes to the affected files, but plastic just sees it as regular code updates.

Is there any way to re-apply the lost changes? Simply selecting 'merge' gives the message "The merge search has finished, merge destination already contains source changes." since, again, plastic is unaware that these changes were lost.


Solution

  • You will need to run a subtractive merge from the wrongly changeset created containing the bad revisions. The Plastic SCM subtractive merge system will undo all the content introduced resulting in what you had before that certain changeset.

    Example

    Subtractive merge of changeset #92

    In the figure above, we need to delete the change done by changeset “92”, imagine this is the one where your coworker introduced the bad revisions, on the other hand we need to keep “93”, “94” and “95”.

    We can’t just revert to “92” since we’d lose “93”, “94” and “95”.

    What subtractive does is the following: 96=91–92+93+94+95.

    It is an extremely powerful tool to “disintegrate” tasks too. See this.

    How to run a subtractive merge

    First you need to switch your workspace to the affected branch then you'll want to right click changeset 92, "Advanced Merge -> Subtractive merge from this changeset", continue processing the merge operation and you are done, the bad changes are not there anymore. Finally you just need to checkin the result to the repository.

    Notice how the merge operation proposes the files your coworker changed as merge candidates, all those changes are automatically undone so you'll not need to re-merge the source branch.