Checking in modifications

After creating and adding a project with Subversion the next step is to send the code and file modifications to it.

Getting ready

For this recipe we will need a Subversion server or an account from some Subversion provider, such as Sourceforge.

Configuring NetBeans accordingly to work with Subversion and a Java project are necessary for this recipe.

For explanations on how to create a Subversion account on Sourceforge and add a project to Subversion, refer to the Getting Ready section in the beginning of this chapter.

This recipe can also be used with a previously created project, in the case of on-going development.

How to do it...

Carry out the following steps in order to delete NBCookbookSVN.java:

  1. Right-click on the .java file and select Delete.
  2. On the Delete dialog check Safe Delete and click on Refactor.

In order to add a new class you will have to execute the following steps:

  1. Right-click on the Sources Package, select New and Java Class....
  2. On the New Java Class dialog, under Name and Location enter Class Name as Person.
  3. Enter nbcookbooksvn as Package and click on Finish.

And finally, to commit the changes:

  1. Right-click on the Sources Package, then Subversion and Commit....
  2. On the Commit dialog, under Commit Message, enter First commit and click on the Commit button.
How to do it...

How it works...

Adding and deleting a file are two distinct actions that are usually performed by Subversion in the command line.

So when we commit all changes we are not just sending the files to the server, but also deleting and creating new ones on it.

It works the same way whether only code is added, files modified or files deleted/created.

NetBeans highlights files with different colors depending on whether they are new, marked for deletion, or have modifications.

The colors are:

  • Gray: Shows that the current file is not yet sent to version control.
  • Blue: When the local file was modified.
  • Green: Shows that the file has been added locally.
  • Red: Conflicts between the local and server copy of the file.

The same coloring scheme can be related to lines of code inside a file. Code lines can also be marked with blue, green, and red indicating the same behavior as explained in the bullet points above.

In the following screenshot NetBeans shows the archives that are synced with the server and not-modified with the blue icon.

Note that Person.java is written in with a green color, since it is a newly added locally, and NBCookbookSVN.java is marked as gray.

How it works...

The little blue icon looking like a small glass means that changes (creation, modification, and deletion) have occurred to the indicated package.

Since Person.java was not sent to the server, the file is shown without the blue icon.

There's more...

Ways to track changes in the code the and NetBeans diff window are explained as follows.

Show changes

Many times, changes to one particular feature in the project affect many different files. So many that it is hard to keep track of what has been changed.

To see the changes to the local files compared to the ones in the server is easy:

  1. Right-click on the Source Packages node.
  2. Select Subversion and Show Changes.
  3. A new view is launched.
Show changes

We can see which files were altered, the status of these files, and the path.

The icons placed on top of the Subversion view are there to help the developer filter the view of the changes.

The first three actions, represented by the icons (left to right) are:

Show changes
  • Show Both Locally and Remotely Modified Files
  • Show Locally Modified Files
  • Show Remotely Modified Files

These three icons will change the way the files are presented in the view.

The other four icons are:

Show changes

They are responsible for the following actions (left to right):

  • Refresh Status: Checks if there was any other modifications to files
  • Diff All: Opens a window, same place where the code editor is, with the changes for the listed files
  • Update All: Brings the latest changes from the server to the local copy
  • Commit All: Sends all the local changes to the server

So besides the previously mentioned way of committing changes to Subversion, this window provides another way of doing it.

Diff window

The Diff window is where all the differences between the local copy and the copy on the svn server are shown.

It is possible to call this window by clicking on the Diff All button when Show Changes pane is on, or by right-clicking the project node then selecting Subversion and finally Diff.

Diff window

The screenshot above shows those modifications and the path of each one of those. The left and right panes show the specific locations where modifications were made in both local and remote files.

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

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