This document is a simple primer for anyone who has no experience using Mercurial, and wants to get set up working with NB sources as quickly as possible. The steps below provide some useful background information, then show how to install and configure Hg, and provide a simple workflow use-case in the IDE.
The following diagram shows how you can expect to work with Hg in NetBeans IDE:
The following structural diagram indicates how the shared repo, local repo, and working directory are unique elements, and how the commands you use in the IDE can affect each of them. Note that when you use Fetch, you are traversing three paths in one action: pull, update (or merge then update), and commit.
This diagram is not to be confused with the workflow diagram above: specifically, after you commit changes to the local repo, your next step is to pull from the shared repo, not push!
Before stepping through the workflow example, understand how the following Hg terms correlate to CVS commands and match the options provided in the IDE's context-sensitive menu:
Prebuilt, binary packages exist for most platforms: http://www.selenic.com/mercurial/wiki/index.cgi/BinaryPackages. If a package is not available for your platform, or if you want to download and build from sources, you will also need a Python interpreter and C compiler. See here for more details.
Hg client version 1.0.1 is recommended for working in the IDE (as of May 2008).
It is recommended that you install NetBeans IDE 6.1, where Mercurial support is already included. There is also a downloadable module for NetBeans IDE 6.0, but it is not as mature or full-featured.
Note: Currently (20 Feb, 2008) the IDE presents you with a warning dialog stating that you are not using the correct client version:
If you are using 0.9.5 or later, you are fine. Click OK to continue.
If the IDE can't find the executable, a pop-up warning displays immediately after you've installed the plugin. The IDE searches for the Hg executable on your computer's $PATH. If installation did not add the executable to the $PATH variable, or if you installed to a unique location, you'll need to specify this manually in the IDE.
You can set the path in the IDE by choosing Tools > Options from the main menu, then Miscellaneous > Versioning > Mercurial. Enter the path in the text field. If you are using a Mac, try /usr/local/bin, otherwise look at this entry in Igor Minor's blog.
You can configure the Hg client directly through the IDE. Basic configuration requires that you specify your NetBeans username, and activate certain Hg extensions that allow you more convenience when working with Mercurial. Several Hg extensions are packaged with the client, namely Fetch.
To configure the Hg client, open the Mercurial Options window (Tools > Options from main menu. Then: Miscellaneous > Versioning > Mercurial).
Note: The Mercurial Options window allows you to make changes to the Hg configuration file located in your user directory. On Linux, this is the .hgrc}} file located your home directory. On Windows, this is the hgrc file located in: C:\Documents and Settings\my name\Application Data\Mercurial. Declarations to the Hg config file located in your user directory take precedence over declarations in the global configuration file (Mercurial.ini on Windows), which is located in your Hg installation directory.
http://<myUsername>@hg.netbeans.org/main/
where <myUsername> is your NetBeans username.
Note: If you are running Windows, be careful of the path length that you specify; i.e., C:\Documents and Settings\myName\My Documents\NetBeans\etc\etc can cause an unsuccessful clone due to very long file paths! Try using C:\ instead.
Also note that the default clone name is main, which matches the name of the NB shared repository. Click Finish to initiate the clone. Output is generated in the Output window, however be aware that the output does not list any files or directories that are being pulled from the remote repo. A clone can take anywhere between 1 and 5 hours to complete depending on connectivity, and requires approx. 800 MB of space. One way to see whether content is actually being pulled is to navigate to the local repo's location on your system's explorer and periodically refresh the size of folder to make sure it is increasing. The output for a successful clone looks similar to the following:
Mercurial Clone --------------- adding changesets adding manifests adding file changes ... 75298 files updated, 0 files merged, 0 files removed, 0 files unresolved The number of output lines is greater than 500; see message log for complete output INFO Clone From: http://myName@hg.netbeans.org/main INFO To: C:\hg-repo\main INFO: End of Clone
Note: Upon completing the clone, the IDE confronts you with a dialog that asks: "When working with this Clone, if you are doing any Merges or Reverts Mercurial may generate additional files with extensions, .orig, .chg and .rej. Would you like the IDE to automatically ignore them by adding these extensions to the clone's .hgignore file?" Click No. The expressions are already in the .hgignore file. Clicking Yes will duplicate those entries and ensure that you will have to commit and push a change to .hgignore, which will cause scorn and embarrassment.
Before you begin stepping through the workflow, you need to specify the default protocols for pulling changes from, and pushing changes to the shared repository. You can do this by opening the Hg Properties Editor (Mercurial > Properties). Note that the Properties Editor is associated with the clone you are working in. Therefore, changes you make in the Properties Editor are recorded in the hgrc file located in the .hg directory found in the top-level folder of your clone.
The Properties Editor should open with the default push and pull locations set to the URL you specified when cloning. Modify your default-push entry by add your NetBeans password and changing the protocol to https.
Important: Use http to pull, and https to push (as shown below). Also note that you only need your password for default-push:
You should see a similar message to the following in the Output window, indicating that your local repository has been updated to include changes from your working directory:
Mercurial Commit
----------------
Committing 3 files to repository for General Online Help:
C:\hg-repo\main\usersguide\javahelp\org\netbeans\modules\usersguide\files\files_icons.html
C:\hg-repo\main\usersguide\javahelp\org\netbeans\modules\usersguide\files\files_properties.html
C:\hg-repo\main\usersguide\javahelp\org\netbeans\modules\usersguide\files\files_ignore-files.html
INFO: End of Commit
In order to verify what changesets were created from committing changes to your local repo, you can choose Mercurial > Show Out. This is a handy command because after you commit changes, all modified files return to their 'unchanged' state in the IDE (i.e., versioning badges disappear and color coding for file names returns to black).
The below capture indicates that 3 files have been committed within the usersguide/files folders of the user's local repository:
Before you can push changes that you have committed locally to the shared repository, you need to bring your local repository in sync with the shared repository. You can most easily do this with the Fetch command. This is similar to performing an update prior to committing in CVS. However, it is more involved since an HG setup has three levels (shared repository, local repository, working directory) whereas CVS only has two (repository, working directory).
When you perform a Fetch, the Hg client actually performs three (or four) actions: pull, update and commit (or: pull, merge (if necessary), then update and commit the merge). If new changesets are received, Fetch will merge them into your working directory, then perform a commit in order to create the most recent changeset (i.e., tip) in your local repository.
Note: It is also possible to run pull, merge (if necessary), then update and commit sequence of commands separately. However, this is not recommended. Any advantage gained doing this is small and the risks of getting something wrong are significant. If you do opt to use these commands instead of fetch, remember that the IDE runs Pull with the -u option, which means that the update command follows the pull.
Mercurial Fetch --------------- INFO: Running Fetch for C:\hg-repo\main pulling from http://tgiunipero@hg.netbeans.org/main searching for changes adding changesets adding manifests adding file changes added 11 changesets with 58 changes to 57 files (+1 heads) merging with new head 68065:b04a33653113 58 files updated, 0 files merged, 0 files removed, 0 files unresolved new changeset 68066:377b8c7d19fd merges remote changes with local INFO: End of Mercurial Fetch
The output indicates that 11 changesets were pulled from the shared repository and merged into the local repo. (Note that the working directory is also updated to reflect changes, but this is not indicated in the output. A new changeset is created that merges the current state of the shared repository with that of the local repository. Note that the local ID of this changeset is 68066. This changeset is listed below in the push, as it is now the most current version of the repository (i.e., tip).
Note: If merge conflicts arise when you perform a Push or Fetch, you will need to sort these out manually in the Source Editor.
Important: If merge conflicts arise in files that you never intended to touch, take this as a sign of trouble. You should STOP and ask someone for HELP.
After you perform a successful Fetch, your local repository becomes in sync with the tip (i.e., most recent changeset in the repository). You are now ready to push any new changesets that you've created in your local repo to the shared repository. To do so, choose Versioning > Push to - default.
Note that all changes must be committed to your local repository prior to being pushed. If not, Mercurial prevents you from performing a Push.
Mercurial Push -------------- INFO Changesets to push: comparing with https://tgiunipero:***@hg.netbeans.org/main searching for changes changeset: 68054:6ab9355c2f2c user: tgiunipero@netbeans.org date: Tue Feb 19 02:40:53 2008 +0100 files: usersguide/javahelp/org/netbeans/modules/usersguide/files/files_icons.html usersguide/javahelp/org/netbeans/modules/usersguide/files/files_ignore-files.html usersguide/javahelp/org/netbeans/modules/usersguide/files/files_properties.html description: minor fix.
The Push concludes, listing one more changeset, which is the one created by the merge from the previous Fetch. Finally, there is closing information indicating a successful push:
changeset: 68066:377b8c7d19fd tag: tip parent: 68054:6ab9355c2f2c parent: 68065:b04a33653113 user: tgiunipero@netbeans.org date: Tue Feb 19 03:16:42 2008 +0100 description: Automated merge with http://hg.netbeans.org/main pushing to https://tgiunipero:***@hg.netbeans.org/main searching for changes adding changesets adding manifests adding file changes added 2 changesets with 3 changes to 3 files notify: sending 1 subscribers 1 changes INFO Push To: https://tgiunipero:HzQm9CIu@hg.netbeans.org/main INFO From: C:\hg-repo\main
...with the following output:
Mercurial Fetch --------------- INFO: Running Fetch for C:\hg-repo\main ERROR Command failed: Command: [hg, --config, extensions.fetch=, fetch, --repository, C:\hg-repo\main] Output: [abort: outstanding uncommitted changes] INFO: End of Mercurial Fetch
This can happen if you have not committed all changes in your working directory. Try committing changes then retry Fetch.
This can happen if someone has pushed to the shared repo since the time that you last fetched (or pulled). Try performing a Fetch again, then Push.
Mercurial Push -------------- ERROR Command failed: Command: [hg, outgoing, -v, --repository, F:\NBsource\main, https://username:****@hg.netbeans.org/main/] Output: [comparing with https://username:***@hg.netbeans.org/main/, abort: error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol] INFO: End of Mercurial Push
This can happen if MSIE is adding global proxy settings to your computer. Try opening MSIE, then: Tools > Internet Options, chose Connections tab, click LAN Settings button, and uncheck the "Use Proxy server for your LAN" box.
The instructions presented here are not exhaustive. If you are searching for more in-depth info, the following list shows some good places to start. The first two links are particularly useful:
selenic.com
wiki.netbeans.org
| HgWorkflow.png | ![]() |
48136 bytes |
| HgWorkflow2.png | ![]() |
90788 bytes |
| clientVersionConflict.png | ![]() |
8515 bytes |
| commandFailed.png | ![]() |
7076 bytes |
| commitIcon.png | ![]() |
593 bytes |
| confirmMergeAfterPull.png | ![]() |
14256 bytes |
| hg-prop-editor.png | ![]() |
9790 bytes |
| hgExtEditor.png | ![]() |
9451 bytes |
| hgMenu.png | ![]() |
13129 bytes |
| hgShowOut.png | ![]() |
7560 bytes |
| hgVersioningWin.png | ![]() |
8368 bytes |
| structuralDiagram.png | ![]() |
15202 bytes |
| unableToPush.png | ![]() |
6726 bytes |