Creating a Mercurial project

Mercurial is one of the new breed of version control systems called DVCS (Distributed Version Control Systems) that use distributed repositories residing in every developers machine, instead of centralized ones as is the case with Subversion.

Let's take a look at how to integrate Mercurial and NetBeans.

Getting ready

In this recipe we will assume that no Mercurial repository is available on the local machine.

We first need to create an account in a Mercurial repository provider.

So for this recipe to work we will need to visit and create an account in http://sourceforge.net.

Under Sourceforge we will host our free Mercurial repositories, which will be enough for our needs.

Keep in mind that, while using Sourceforge to test this recipe, it is necessary to enable Mercurial since it is not enabled by default.

Visit the link below for more information:

https://sourceforge.net/apps/trac/sourceforge/wiki/Mercurial#Management

Once the account and a new project have been created in Sourceforge, we need to configure NetBeans to use Mercurial.

  1. On the toolbar click on Tools then Options.
  2. In the Options dialog click on the Miscellaneous button.
  3. Then click on the Versioning tab.
  4. Under Versioning Systems click on Mercurial.
  5. Navigate to Mercurials's installation folder by clicking Browse... and select it.
  6. Leave all the other options with their default values and click OK.

We will now have to configure the Mercurial repository in NetBeans.

On the toolbar click on Team, then Mercurial and Properties.

Enter the Mercurial default-pull, default-push, and username to the dialog box and click on OK.

Getting ready

Carry out the following steps in order to create a project:

  1. Create a New Project, by either clicking on File and then New Project by pressing Ctrl+Shift+N.
  2. On New Project window on categories side choose Java and on Projects side select Java Application and click Next >.
  3. Under Name and Location: Under Project Name enter NBCookbookHG and click Finish.

How to do it...

Now to initialize our project:

  1. Right-click project node, select Mercurial and Initialize Mercurial Project.
  2. On the Repository root path click leave the default value and click OK.
  3. In order to commit your project: Right-click on the project and select Mercurial then select Commit....
  4. On the commit window under Commit Message enter first commit, then click on commit.

How it works...

Once the repository has been configured NetBeans will perform a check against the Mercurial server. When this is finished, the project in NetBeans will look slightly different.

How it works...

The file highlighted in green denotes that it is a new file that has not yet been committed to the server.

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

There's more...

Let's check the server for modifications.

Status of server files

Before doing the commit it is possible to have a look at the status of the newly-created project.

This is useful to check changes against the server and find out which files have been created, deleted, or modified.

  1. Right-click on the project node.
  2. Select Mercurial then Status.
Status of server files
..................Content has been hidden....................

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