Using Support for Mercurial Queues in Apache NetBeans

This tutorial needs a review. You can edit it in GitHub following these contribution guidelines.

The NetBeans IDE provides support for the Mercurial Queues extension. The IDE’s Mercurial Queues support allows you to create, review or switch between patches within the IDE, as well as refresh patches with local modifications as you fix bugs or update to a new base revision. This document demonstrates how to perform basic patch-specific tasks in the IDE by guiding you through the standard workflow when using Mercurial versioning software for managing patches.

Enabling the Mercurial Queues Support

Since Mercurial Queues is an extension, you must explicitly enable it before you can use it. To start running Mercurial Queues on your Mercurial repository, you need to complete the following steps:

  1. On your system , browse to the .hgrc file. The default location of the .hgrc file on OS X and Linux is $HOME/.hgrc , on Windows - %USERPROFILE%\Mercurial.ini .

  2. Add the lines below to your .hgrc file.

     [extensions]
     hgext.mq =
  1. Save the file.

Creating a Patch

To create a patch, you need to complete the following steps:

  1. In the Projects window, select a versioned project and choose Team > Queues > Create Patch (alternatively, right-click the project name and select Mercurial > Queues > Create Patch from the pop-up menu). The Create Patch dialog box displays.

create patch small
  1. Specify the name for a patch in the Patch Name text field.

  2. Provide the description of a patch in the Patch Message field. Alternatively, choose either of the following options and click OK afterwards:

    • click the Recent Messages button (recent) to select a message from a list of most recent commit messages

    • click the Load Template button (load) to select a message template for a commit message.

The provided description of a patch will be used as a commit message when turning the patch into a permanent changeset.
  1. Select files to be included into the patch in the Files To Include In Patch table.

  2. (Optional) Specify information pertinent to an issue related to the created patch using the fields of the Update Issue area.

  3. Click Create Patch. A new patch is created and added to the .hg/patches directory.

Refreshing a Patch With Local Modifications

To save your progress into the patch you are creating , you need to complete the following steps:

  1. Choose Team > Queues > Refresh Patch from the main menu (alternatively, right-click the project name and select Mercurial > Queues > Refresh Patch from the pop-up menu). The Refresh Patch dialog box displays.

refresh patch small
  1. Provide the description of a patch in the Patch Message field. Alternatively, choose either of the following options and click OK afterwards:

    • click the Recent Messages button (recent) to select a message from a list of most recent commit messages

    • click the Load Template button (load) to select a message template for a commit message.

The provided description of a patch will be used as a commit message when turning the patch into a permanent changeset.
  1. Select files to be included into the patch in the Files To Include In Patch table.

  2. (Optional) In the Update Issue area, specify information pertinent to an issue related to the changes being committed.

  3. Click Refresh Patch. The patch you are working on is updated.

Comparing Patch Revisions

To generate a patch for review and compare revisions of a patch side by side, you need to complete the following steps:

  1. Choose Team > Queues > Diff from the main menu (alternatively, right-click the project name and select Mercurial > Queues > Diff from the pop-up menu). The Diff Viewer displays differences found in the current patch and all your uncommitted/unrefreshed local changes in side-by-side panels:

qdiff small
  1. Review and revise differences found in the compared files using either Graphical or Textual Diff Viewer.

The Graphical Diff Viewer highlights changes in the files using the following color encoding.
Blue (       ) Indicates lines that have been changed since the earlier patch.

Green (       )

Indicates lines that have been added since the earlier patch.

Red (       )

Indicates lines that have been removed since the earlier patch.

The following icons enable you to make changes directly within the Graphical Diff Viewer.

Icon Name Function

replace

Replace

Inserts the highlighted text from the previous patch into the current patch.

replace all

Replace All

Reverts current version of a patch to the state of its selected previous version.

remove

Remove

Removes the highlighted text from the current version of a patch so that it mirrors the previous version of a patch.

Switching Between Patches

To switch to a particular patch in a patch queue series, you need to complete the following steps:

To switch between patches there must be no local modifications in the working copy, otherwise the switch fails.
  1. Choose Team > Queues > Go To Patch from the main menu (alternatively, right-click the project name and select Mercurial > Queues > Go To Patch from the pop-up menu). The Go To Patch dialog box displays a list of all patches available in a stack.

go patch
Names of applied patches display in bold. Choose Team > Queues > Pop All Patches to remove the applied patches from the top of the stack and update the working directory to undo the effects of the applied patches.
  1. Select the required patch and click Go. The IDE applies the changes contained in the selected patch to the chosen project, file, or folder.

Finishing Applied Patches

Once your work on a patch is done, it can be turned into a permanent changeset. To turn all applied patches in a patch queue series into regular changesets, complete the following steps:

To apply all saved patches in the repository, choose Team > Queues > Push All Patches from the main menu.
  1. Choose Team > Queues > Finish Patches from the main menu (alternatively, right-click the project name and select Mercurial > Queues > Finish Patches from the pop-up menu). The Finish Patches dialog box displays.

finish patches
  1. Select the name of a patch to be finished in the patches field.

All patches in the series before the selected patch will also be finished.
  1. Click Finish Patches. The IDE turns all applied patches up to the selected patch into regular changesets.

Summary

This tutorial showed how to perform basic patch-specific tasks in the IDE by guiding you through the standard workflow when using Mercurial versioning software for managing patches. It demonstrated how to enable the Mercurial Queues support in the NetBeans IDE and perform basic tasks on patches while introducing you to some of the Mercurial specific features included in the IDE.