August 27, 2010

Rename support on merge

I'm going to go back to the basics today and describe how Plastic handles renames during merge with two different cases:
  • Rename a file, modify it in parallel in a second branch and check how the two branches are correctly merged back, which means: the result file is renamed and it contains the changes from the two branches.
  • Divergent merging: what if we rename a file in one branch and also in a second one to a different name and we merge back?

    As simple as it might sound, renaming during merging is one of the points where most of the SCMs break... And the good news is that Plastic simply excels there.

    Handling renames during merge


    The scenario is very simple:
  • Create branch task003, rename and modify file agent.cs there
  • Create branch task004 (in parallel with task003) and modify agent.cs there
  • Merge back both branches to main
    The expected result is: getting agent.cs renamed and including the changes from the two branches.

    This is what Plastic does, but systems like Subversion dramatically fail: SVN will create two files as result and won't directly merge the changes...

    The following screencast shows Plastic in action dealing with this example:



    Divergent renaming


    The scenario is the following:
  • Rename a file on a branch
  • Rename the file to a different name, in parallel, on a different branch
  • Merge the branches together

    Plastic is able to detect the double rename and come up with a solution: choose one of the names or propose a new one. But Plastic won't end up creating two files and leaving you alone to handle further merging (changes on the files) yourself.

    Interestingly this is exactly what Mercurial does: it will create two files with the two names and warn you to solve the situation somehow.



    Check it in action here:

  • No comments:

    Post a Comment