TutorialOnNetBeansMercurialClone

Tutorial | Cloning Using Mercurial In NetBeans 6.1

Contributed By; Tushar Joshi

[[{TableOfContentsTitle=TableOfContents} | {TableOfContents title='Table of Contents'}]]

Introduction


In this tutorial, I would be listing down steps to teach you on How to Clone a Project made in NetBeans IDE using Mercurial.

Firstly, I tried experimenting in NetBeans IDE 6.1 Beta for Mercurial support. Now as the NetBeans IDE 6.1 Release Candidate 1 which was made available some time back. So, I tried to work with this version and found some changes in the arrangements of the Mercurial menu.

If you try to run any Mercurial command on NetBeans IDE, when Mercurial is not installed or not available in the Windows executable search path, then NetBeans shows a dialog box saying no support for Mercurial.

File:nbmer00_TutorialOnNetBeansMercurialClone.png


Using Mercurial


Mercurial should be already installed to see the things in this tutorial happening. In an earlier blog post of mine, I had covered the installation of Mercurial on Windows. The version of Mercurial, I have installed was not the version NetBeans was expecting so it displayed a dialog box saying "This module was not expecting this Mercurial version", but it allows to continue with the version we have.

File:nbmer01_TutorialOnNetBeansMercurialClone.png

Choosing Yes, will tell NetBeans to try anyway.

Create a Sample Project

I created a new sample project "BankExample" for the test run. After right-clicking on the project name we can see menu with Versioning > Initialize Mercurial Project.

File:nbmer02_TutorialOnNetBeansMercurialClone.png


Initialize Mercurial Project

Choosing this option will initialize Mercurial repository in the project directory. Mercurial will create a folder named ".hg" in the project folder. This is the Mercurial repository where it will store all the configuration and version control material.

You can see the Mercurial initialization output on the output window.

File:nbmer03_TutorialOnNetBeansMercurialClone.png

Unlike Subversion, Mercurial will not create ".hg" folder in all the sub folders. This is one feature I liked very much of Mercurial.

The Mercurial repository is created but the files in the directory are not yet tracked by the Mercurial system. We must commit all the files to the repository first to tell Mercurial to keep version information, which it does in terms of change-sets.

Viewing Project Explorer

The project explorer shows visual clues by showing icons with the file and package names.

File:nbmer04_TutorialOnNetBeansMercurialClone.png


Commit...

We can commit the files by right-clicking the project and choosing the Mercurial > Commit... option

File:nbmer05_TutorialOnNetBeansMercurialClone.png

The commit dialog box shows all the files that will be committed to the repository. Here we have choice to change the behavior of the commit command for different files. We can set some files not to commit. We are required to type a message for commit.

File:nbmer06_TutorialOnNetBeansMercurialClone.png

We should commit our code often as we develop the project. This commit is made in the local Mercurial repository crested in the project folder. This is just like maintaining our repository locally with the project.


Clone Other...

To check the sharing options of the Mercurial version control system we should clone the project repository. Cloning makes a replica of the project repository and also sets a reference to the original copy of the repository as default push and pull target. Once the project is cloned then the original and the cloned copy can share the version information by commands push and pull.

The command for cloning is available at top menu, Versioning > Mercurial > Clone (project name)

File:nbmer07_TutorialOnNetBeansMercurialClone.png

NetBeans suggest a name for the clone and also offers to make the new cloned project as main project.

File:nbmer08_TutorialOnNetBeansMercurialClone.png

We can see the project cloned in folder "BankExample_clone0" and opened in the NetBeans IDE side by side to the original project.

File:nbmer09_TutorialOnNetBeansMercurialClone.png


Push To - Default Option

When I changed a file in the cloned project and committed to the repository I can now check pushing the information back to the original repository.

Again, opening menu Versioning > Mercurial > Share > Push to - default option will allow me to push the changes to the original repository from where I had cloned this repository.

File:nbmer10_TutorialOnNetBeansMercurialClone.png

Conclusion


Ideally the projects will be made available on web for sharing by people. People can share the updates to the originally repository by cloning the projects on their workstations. The local copy can be updated by update or pull command from the original repository any time.

Thanks for following the tutorial, hope it might help you get going with Mercurial now!

See Also

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo