Resolving conflicts in Subversion

Code conflicts will arise when the local copy has different contents in the same location as the content that is present in the server.

The resolution of conflicts in version control systems is a painful fact that every developer must face sooner or later.

Let's check how to solve code conflicts with Subversion and NetBeans.

Getting ready

For more information on how to setup NetBeans and Subversion, please refer to the first Getting Ready section at the beginning of this chapter.

How to do it...

  1. Right-click the project node, select Subversion and Resolve Conflicts....
  2. The Merge Conflicts Resolvers pops-up, click on the code to be accepted and then on OK.
  3. Choose the correct option by clicking on Accept and click on OK.
    Getting ready
  4. When asked to Save, click on Yes.

How it works...

As mentioned in the introduction of this recipe, a conflict will arise whenever different code is present in the same line in both local and remote copies. In the previous screenshot we have introduced conflicts.

NetBeans presents the developer with a window divided in three parts. The Local Working File is the file which we are editing and, most probably, started the conflict; the Remote File is the one in the Subversion server; and the Result After Merge, the lower pane, is how the file will look after the conflict is resolved.

In our particular case we resolve the conflict by accepting the changes from the server and merging them, automatically, when the Accept button on the Remote File side was clicked.

In the following screenshot, blue indicates changes since the first version, and green that changes that have been added since the previous version. Red indicates lines removed since the previous version.

How it works...

Resolving conflicts turns the previously red highlighted sections of code into blue and green.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.116.69