{"id":4428,"date":"2015-02-19T19:25:03","date_gmt":"2015-02-20T00:25:03","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=4428"},"modified":"2015-02-19T19:25:03","modified_gmt":"2015-02-20T00:25:03","slug":"managing-conflicts-in-simulink-projects","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2015\/02\/19\/managing-conflicts-in-simulink-projects\/","title":{"rendered":"Managing Conflicts in Simulink Projects"},"content":{"rendered":"<p><em>This week we are welcoming guest blogger Tim Hosey from the Simulink Project development team.<\/em><\/p>\r\n\r\n<p><strong>Introduction<\/strong><\/p>\r\n\r\n<p>In this blog post I will highlight how <a title=\"https:\/\/www.mathworks.com\/discovery\/simulink-projects.html (link no longer works)\">Simulink Project<\/a> can be used to manage conflicts that occur when two users submit changes to the same Simulink model using a source control tool.<\/p>\r\n\r\n<p>A conflict arises when two users make changes to the same file. The first user to submit their changes to the source control system experiences no problem, but the second user\u2019s changes are considered to be in conflict with the first user\u2019s changes; so the source control tool prevents the second user from committing their file until they have merged their changes into the first user\u2019s version of the file.<\/p>\r\n\r\n<p><strong>Environment set up<\/strong><\/p>\r\n\r\n<p>In order to show how conflict resolution can be performed with Simulink Project I have set up a modified version of our <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/try-simulink-project-tools-with-the-airframe-project.html\">Airframe demo<\/a>.<\/p>\r\n\r\n<p>I created two working copies called demo1 and demo2 which are checked out from an SVN repository created by running the above demo. User 1 will use the folder demo1 and user 2 will use the folder demo 2.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/initialSetup.png\" alt=\"Two users, two working copies\" \/><\/p>\r\n\r\n<p>Here is a screenshot of what the project looks like when user 1 opens their copy of the project in the working copy demo1.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/initialProject.png\" alt=\"Initial Project\" \/><\/p>\r\n\r\n<p><strong>Binary case<\/strong><\/p>\r\n\r\n<p>I have set up my SVN config file to consider slx files binary, see our documentation about <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/set-up-svn-source-control.html\">how to set up SVN source control<\/a>.<\/p>\r\n\r\n<p>The project contains a model called vertical_channel.slx which looks like this:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/initialModel.png\" alt=\"Initial Model\" \/><\/p>\r\n\r\n<p>User 1 modifies this model to change the sign of both the sum block and the feedback gain, so that it now looks like this:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/modifiedModel1.png\" alt=\"Modified Model from User 1\" \/><\/p>\r\n\r\n<p>User 1 then commits his changes using the modified files view.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/commit.png\" alt=\"Commit of Modified Model from User 1\" \/><\/p>\r\n\r\n<p>This trivial change was easy to make and commit to the SVN repository, but as we are about to see when user 2 makes a change to his copy of this file, submitting the change is going to be much more difficult.<\/p>\r\n\r\n<p>User 2 hasn\u2019t performed any update so his project looks the same as user 1\u2019s project before he made his change.<\/p>\r\n\r\n<p>User 2 opens the vertical channel model and adds a scope to his model so that it looks like this:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/modifiedModel2.png\" alt=\"Modified Model from User 2\" \/><\/p>\r\n\r\n<p>When user 2 tries to commit they get the following error:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/failedCommit.png\" alt=\"Error commit failed\" \/><\/p>\r\n\r\n<p>This error tells him that he doesn\u2019t have the latest version of vertical_channel.slx so he can\u2019t commit his changes to it. To get the latest version he performs an update. This causes a problem because the changes in his working copy conflict with the changes made between the version of the file that has and the latest version in the repository submitted by user 1. User 2\u2019s change is now in conflict with the change submitted to the repository by user 1. The project marks this file as conflicted user 2\u2019s project. <\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/projectConflict.png\" alt=\"conflict\" \/><\/p>\r\n\r\n<p>Because we registered .slx files as binary with SVN, the SVN update did not attempt change the content of the file vertical_channel.slx, it still contains user 2\u2019s addition of the scope to the original model.<\/p>\r\n\r\n<p>User 2 can use Simulink Project to resolve the conflict as follows:<\/p>\r\n\r\n<ol>\r\n\t<li>First the user needs to view the conflict, he can do this by right clicking on the file and selecting \u2018view conflicts\u2019 in the Simulink Project\u2019s file context menu. If <a href=\"https:\/\/www.mathworks.com\/products\/SL_reportgenerator\/\">Simulink Report Generator<\/a> is installed a <a title=\"https:\/\/www.mathworks.com\/help\/rptgenext\/model-comparison.html (link no longer works)\">Simulink XML comparison<\/a> will be used to show the conflicts between user 1\u2019s version of the model and user 2\u2019s version.\r\n<br><br>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/compareXML.png\" alt=\"Model Comparison\" \/><br><\/li>\r\n\r\n\t<li>User 2 can then easily select and merge the changes from user 1 that they want to include in their version of the file.\r\n<br><br>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/merge.png\" alt=\"Model Merge\" \/><br><\/li>\r\n\r\n\t<li>Once user 2 is happy with the resultant merged file he can right click on the file in the project\u2019s file context menu and select \u2018mark conflict resolved\u2019. Now the conflicted file is marked as modified and can be submitted to the SVN repository.\r\n<br><br>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/conflictResolved.png\" alt=\"Conflict Resolved\" \/><br><\/li>\r\n<\/ol>\r\n\r\n<p>When user 1 performs an update he now gets the merged model in his working copy:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2015Q1\/finalModel.png\" alt=\"Final Merged Model\" \/><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Do you often need to merge Simulink models? Let us know by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=4428&#comment\">comment here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/simulink\/files\/feature_image\/initialSetup.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"Merging Simulink model changes from two users\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>This week we are welcoming guest blogger Tim Hosey from the Simulink Project development team.\r\n\r\nIntroduction\r\n\r\nIn this blog post I will highlight how Simulink Project can be used to manage... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2015\/02\/19\/managing-conflicts-in-simulink-projects\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":4458,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[65,24,33,63],"tags":[420,378],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/4428"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=4428"}],"version-history":[{"count":13,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/4428\/revisions"}],"predecessor-version":[{"id":4457,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/4428\/revisions\/4457"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media\/4458"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=4428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=4428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=4428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}