CHIRP Development Process

Mercurial Configuration

Make sure that your mercurial tool is configured properly for CHIRP. This means having the correct username and email address specified, as well as the MQ extension enabled (for most cases). You can do this in your global mercurial configuration file, or in the one in the repository you're working on, which is .hg/hgrc in the top level chirp.hg directory. You may also want to ensure that it has the patchbomb configuration enabled, which allows easy emailing out of mercurial itself. You probably want the following lines in your config file:

chirp.hg/.hg/hgrc

[ui]
username = Joe Bob <joebob@gmail.com>
[extensions]
hgext.mq=
hgext.patchbomb=

[email]
from = Joe Bob <joebob@gmail.com>
method = smtp
to = chirp_devel@intrepid.danplanet.com
# Add a bcc if you want a copy of the email
# bcc = Joe Bob <joebob@gmail.com>

[smtp]
host = smtp.gmail.com
port = 587
tls = True

Getting the code

hg clone http://d-rats.com/hg/chirp.hg
cd chirp.hg

Bug Tracking

All changes should have a bug created on the tracker before submission. The server hosting the repository will not allow changesets to be pushed that do not contain a bug number (see below). It is perfectly reasonable to create a bug, assign it to yourself, and then close it before sending the patch.

Submitting a patch

Changes to CHIRP are welcome, but they should be in the correct format, and sent as a patch to the mailing list. The correct way to do this is to clone the upstream repository, make your changes there, and then soft-commit them as MQ patches to the tree. The following assumes you have cloned the repository and are in the resulting directory.

You must include an Issue Number (#123) somewhere in the commit message to tie each patch to an issue for tracking purposes.

Making a change

Edit one of the files to make a change. For this example, I'll use chirp/ic2820.py. Assuming I have made a change, the following commands help me see what has been done:

% hg status -mar
M chirp/ic2820.py
% hg diff
diff -r a132c837fd25 chirp/ic2820.py
--- a/chirp/ic2820.py   Mon Dec 24 08:17:19 2012 -0800
+++ b/chirp/ic2820.py   Mon Dec 24 08:56:29 2012 -0800
@@ -16,6 +16,8 @@
 from chirp import chirp_common, icf, util, directory
 from chirp import bitwise

+# Just added a comment
+
 MEM_FORMAT = """ 
 struct {
   u32  freq;

The first command shows me that chirp/ic2820.py has been modified, and the second shows me the actual changes that have been made.

Soft-committing a Change

You can commit a change directly to your tree, but it becomes a little more complicated to make changes to it if necessary, and it creates a fork when the change is actually accepted upstream. An easy way to mitigate this is to soft-commit your changes as MQ patches. Assuming you have made the change above, the following example shows the process for committing that into a patch:

% hg qnew -ef mypatch     # Here an editor will open to compose a commit message
% hg qapplied             # This shows that the patch is now applied
mypatch

This example takes the changes I made above, and commits them into a new patch called mypatch. I can now look at the patch in its entirety, as well as add or remove it from my local tree:

Command Description
hg export tip This will show me the whole patch, with the commit message
hg export tip > mypatch.patch This will save the patch, including commit message, to mypatch.patch. You can then attach this file to an email to chirp_devel for submission.
hg email tip If hg is correctly configured with your email address, name and SMTP server, it will automatically generate an email with the patch included. It will prompt you for the To: address.

See "Sending a Change" below.

Working with Patches (mq mercurial extension)

The following commands demonstrate how the mq extension to hg can be used for managing patches.

Command Description
hg export tip This will show me the whole patch, with the commit message
hg export tip > mypatch.patch This will save the patch, including commit message, to mypatch.patch. You can then attach this file to an email for submission.
hg qpop Remove it from the tree
hg qapplied This shows that no patches are applied
hg qunapplied
mypatch
This shows that our patch is not applied
hg qpush This adds the patch back to the tree
hg qapplied
mypatch
This shows that our patch is applied
hg qpop This removes it again
hg qdel mypatch This deletes it permanently
hg strip --keep --rev . Made an actual commit instead of using mq? This will unstage the last commit, similar to git reset --soft HEAD~1

If this tool intrigues you, you can learn how to use it here: https://www.mercurial-scm.org/wiki/MqTutorial

Testing

CHIRP has a modest test suite used to validate driver behavior in the tests/ directory. Before submitting a patch, please ensure that all the tests run and pass (or at least pass as well as before you made the change).

In order to run the tests you will need tox installed:

% sudo pip install tox

To run the whole set, do this:

% tox

To run just a single driver's tests:

% tox -e driver -- -d Icom_IC-2820H

To run just a specific test:

% tox -e driver -- -t Edges

If you are adding a new driver, you will need to add an image to the tests/images/ directory which is correctly named for your model. These do not communicate well in patch form, so just attach your test image to the issue on the tracker and send a heads-up to the devel list so it can be snagged into the repo.

Note: Please make sure that all the tests run, not just the one that affects your driver. Several of the drivers play off each other and sometimes changes to one will break another.

Sending a change

There are two ways to do this. First, you can export the patch to a text file and email it to the list with your normal mailer. This is how:

% hg export tip > add_comment.patch

You can also configure the tool to email it directly, in which case you need only do:

% hg email tip

You will be prompted for the destination address.

Setting up GMail for patchbomb email

Without two factor identification

If you have a gmail account, setup the port and TLS enable as shown above. You can use your regular gmail username and password if you have not enabled two-factor authentication.

With two factor identification

If it bugs you to have your gmail password in a text file (and it should), you can enroll in two-factor auth with google, but be aware that it will affect the usage of your account. You can enroll here:

https://myaccount.google.com/security/signinoptions/two-step-verification/enroll-welcome

With TFA enabled, you can add app-specific passwords, like one for mercurial:

https://security.google.com/settings/security/apppasswords

With these steps complete, add the app-specific password to your hgrc, and you should be all set.

Patch Guidelines

The Commit Message

The commit message should have a first line that stands on its own and describes the patch briefly. If it pertains to a specific driver, put that driver's short name in brackets at the beginning. An issue number from the issue tracking system must be included to tie the submitted patch to an open issue. For example:

[uv5r] Add support for firmware >= 291 Fixes #123

After the first line, more descriptive text may be added (and is appreciated) about what and why the change is being made. At the end, you must include a bug number in the format #XXX. This lets the system correlate changes to bugs, which helps during release time.

If your first line is not completely self-explanatory (like the one above) then you should have a second paragraph explaining what is being changed and why, especially if it's not a straightforward "add support for XXX" type of patch.

Scope

Guidelines:

  • Patches should be small and concise. Try to keep a single standing change to a single patch.
  • Don't fix several bugs in a single patch, unless there is a technical reason to do so.
  • Don't fix, cleanup, or change random whitespace in the patch unless that is the sole purpose of the patch.