DevelopersProcess

Version 27 (Nicolas Pike, 03/15/2018 04:59 pm)

1 1 Dan Smith
h1. CHIRP Development Process
2 6 Dan Smith
3 5 Dan Smith
{{>toc}}
4 6 Dan Smith
5 1 Dan Smith
h2. Mercurial Configuration
6 1 Dan Smith
7 15 Robert Terzi
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:
8 1 Dan Smith
9 23 Aaron P
h3. @chirp.hg/.hg/hgrc@
10 23 Aaron P
11 1 Dan Smith
<pre>
12 1 Dan Smith
[ui]
13 1 Dan Smith
username = Joe Bob <joebob@gmail.com>
14 1 Dan Smith
[extensions]
15 1 Dan Smith
hgext.mq=
16 1 Dan Smith
hgext.patchbomb=
17 7 Dan Smith
18 1 Dan Smith
[email]
19 1 Dan Smith
from = Joe Bob <joebob@gmail.com>
20 1 Dan Smith
method = smtp
21 16 Tom Hayward
to = chirp_devel@intrepid.danplanet.com
22 23 Aaron P
# Add a bcc if you want a copy of the email
23 23 Aaron P
# bcc = Joe Bob <joebob@gmail.com>
24 1 Dan Smith
25 1 Dan Smith
[smtp]
26 1 Dan Smith
host = smtp.gmail.com
27 16 Tom Hayward
port = 587
28 16 Tom Hayward
tls = True
29 1 Dan Smith
</pre>
30 1 Dan Smith
31 13 Dan Smith
h2. Getting the code
32 13 Dan Smith
33 13 Dan Smith
<pre>
34 13 Dan Smith
hg clone http://d-rats.com/hg/chirp.hg
35 13 Dan Smith
cd chirp.hg
36 13 Dan Smith
</pre>
37 13 Dan Smith
38 3 Dan Smith
h2. Bug Tracking
39 3 Dan Smith
40 3 Dan Smith
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.
41 3 Dan Smith
42 1 Dan Smith
h2. Submitting a patch
43 1 Dan Smith
44 2 Dan Smith
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.
45 2 Dan Smith
46 25 Dan Smith
You must include an Issue Number (#123) somewhere in the commit message to tie each patch to an issue for tracking purposes.
47 14 Robert Terzi
48 2 Dan Smith
h3. Making a change
49 2 Dan Smith
50 2 Dan Smith
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:
51 2 Dan Smith
52 2 Dan Smith
<pre>
53 2 Dan Smith
% hg status -mar
54 2 Dan Smith
M chirp/ic2820.py
55 2 Dan Smith
% hg diff
56 2 Dan Smith
diff -r a132c837fd25 chirp/ic2820.py
57 2 Dan Smith
--- a/chirp/ic2820.py   Mon Dec 24 08:17:19 2012 -0800
58 2 Dan Smith
+++ b/chirp/ic2820.py   Mon Dec 24 08:56:29 2012 -0800
59 2 Dan Smith
@@ -16,6 +16,8 @@
60 2 Dan Smith
 from chirp import chirp_common, icf, util, directory
61 2 Dan Smith
 from chirp import bitwise
62 2 Dan Smith
 
63 2 Dan Smith
+# Just added a comment
64 2 Dan Smith
+
65 2 Dan Smith
 MEM_FORMAT = """
66 2 Dan Smith
 struct {
67 2 Dan Smith
   u32  freq;
68 2 Dan Smith
</pre>
69 2 Dan Smith
70 2 Dan Smith
The first command shows me that @chirp/ic2820.py@ has been modified, and the second shows me the actual changes that have been made.
71 2 Dan Smith
72 2 Dan Smith
h3. Soft-committing a Change
73 2 Dan Smith
74 11 Tom Hayward
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:
75 2 Dan Smith
76 2 Dan Smith
<pre>
77 11 Tom Hayward
% hg qnew -ef mypatch     # Here an editor will open to compose a commit message
78 2 Dan Smith
% hg qapplied             # This shows that the patch is now applied
79 11 Tom Hayward
mypatch
80 2 Dan Smith
</pre>
81 2 Dan Smith
82 11 Tom Hayward
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:
83 2 Dan Smith
84 11 Tom Hayward
| Command | Description |
85 11 Tom Hayward
| @hg export tip@           | This will show me the whole patch, with the commit message |
86 14 Robert Terzi
| @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. |
87 15 Robert Terzi
| @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. |
88 14 Robert Terzi
89 15 Robert Terzi
90 14 Robert Terzi
See "Sending a Change" below.
91 14 Robert Terzi
92 14 Robert Terzi
93 14 Robert Terzi
h3. Working with Patches (mq mercurial extension)
94 14 Robert Terzi
95 14 Robert Terzi
The following commands demonstrate how the mq extension to hg can be used for managing patches.
96 14 Robert Terzi
97 14 Robert Terzi
| Command | Description |
98 14 Robert Terzi
| @hg export tip@           | This will show me the whole patch, with the commit message |
99 11 Tom Hayward
| @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. |
100 11 Tom Hayward
| @hg qpop@                 | Remove it from the tree |
101 11 Tom Hayward
| @hg qapplied@             | This shows that no patches are applied |
102 11 Tom Hayward
| @hg qunapplied
103 11 Tom Hayward
mypatch@                   | This shows that our patch is not applied |
104 11 Tom Hayward
| @hg qpush@                | This adds the patch back to the tree |
105 11 Tom Hayward
| @hg qapplied
106 11 Tom Hayward
mypatch@                   | This shows that our patch is applied |
107 11 Tom Hayward
| @hg qpop@                 | This removes it again |
108 11 Tom Hayward
| @hg qdel mypatch@         | This deletes it permanently |
109 20 Aaron P
| @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 |
110 2 Dan Smith
111 19 Aaron P
If this tool intrigues you, you can learn how to use it here: https://www.mercurial-scm.org/wiki/MqTutorial
112 12 Tom Hayward
113 4 Dan Smith
h3. Testing
114 4 Dan Smith
115 26 Dan Smith
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).
116 1 Dan Smith
117 26 Dan Smith
In order to run the tests you will need tox installed:
118 26 Dan Smith
119 1 Dan Smith
<pre>
120 26 Dan Smith
% sudo pip install tox
121 1 Dan Smith
</pre>
122 8 Dan Smith
123 26 Dan Smith
To run the whole set, do this:
124 8 Dan Smith
125 9 Dan Smith
<pre>
126 26 Dan Smith
% tox
127 8 Dan Smith
</pre>
128 4 Dan Smith
129 4 Dan Smith
To run just a single driver's tests:
130 4 Dan Smith
131 1 Dan Smith
<pre>
132 26 Dan Smith
% tox -e driver -- -d Icom_IC-2820H
133 4 Dan Smith
</pre>
134 4 Dan Smith
135 4 Dan Smith
To run just a specific test:
136 4 Dan Smith
137 4 Dan Smith
<pre>
138 26 Dan Smith
% tox -e driver -- -t Edges
139 4 Dan Smith
</pre>
140 18 Brian Dickman
141 4 Dan Smith
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.
142 4 Dan Smith
143 1 Dan Smith
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.
144 15 Robert Terzi
145 2 Dan Smith
h3. Sending a change
146 2 Dan Smith
147 2 Dan Smith
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:
148 2 Dan Smith
149 2 Dan Smith
<pre>
150 2 Dan Smith
% hg export tip > add_comment.patch
151 2 Dan Smith
</pre>
152 2 Dan Smith
153 2 Dan Smith
You can also configure the tool to email it directly, in which case you need only do:
154 2 Dan Smith
155 2 Dan Smith
<pre>
156 2 Dan Smith
% hg email tip
157 3 Dan Smith
</pre>
158 3 Dan Smith
159 3 Dan Smith
You will be prompted for the destination address.
160 22 Dan Smith
161 17 Brian Dickman
h2. Setting up *GMail* for patchbomb email
162 23 Aaron P
163 23 Aaron P
h3. Without two factor identification
164 21 Dan Smith
165 23 Aaron P
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.
166 23 Aaron P
167 17 Brian Dickman
h3. With two factor identification
168 22 Dan Smith
169 17 Brian Dickman
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:
170 17 Brian Dickman
171 17 Brian Dickman
https://myaccount.google.com/security/signinoptions/two-step-verification/enroll-welcome
172 21 Dan Smith
173 17 Brian Dickman
With TFA enabled, you can add app-specific passwords, like one for mercurial:
174 17 Brian Dickman
175 17 Brian Dickman
https://security.google.com/settings/security/apppasswords
176 17 Brian Dickman
177 27 Nicolas Pike
With these steps complete, add the app-specific password to your hgrc
178 27 Nicolas Pike
179 27 Nicolas Pike
@[smtp]
180 27 Nicolas Pike
host = smtp.gmail.com
181 27 Nicolas Pike
port = 587
182 27 Nicolas Pike
tls = True
183 27 Nicolas Pike
username = myemailaddress@gmail.com
184 27 Nicolas Pike
password = appspecificpassword
185 27 Nicolas Pike
@
186 27 Nicolas Pike
187 27 Nicolas Pike
and you should be all set.
188 27 Nicolas Pike
189 3 Dan Smith
190 3 Dan Smith
h2. Patch Guidelines
191 1 Dan Smith
192 3 Dan Smith
h3. The Commit Message
193 14 Robert Terzi
194 3 Dan Smith
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:
195 3 Dan Smith
196 14 Robert Terzi
<pre>
197 3 Dan Smith
[uv5r] Add support for firmware >= 291 Fixes #123
198 3 Dan Smith
</pre>
199 3 Dan Smith
200 3 Dan Smith
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.
201 24 Dan Smith
202 24 Dan Smith
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.
203 3 Dan Smith
204 3 Dan Smith
h3. Scope
205 3 Dan Smith
206 3 Dan Smith
Guidelines:
207 3 Dan Smith
208 3 Dan Smith
 * Patches should be small and concise. Try to keep a single standing change to a single patch.
209 3 Dan Smith
 * Don't fix several bugs in a single patch, unless there is a technical reason to do so.
210 1 Dan Smith
 * Don't fix, cleanup, or change random whitespace in the patch unless that is the sole purpose of the patch.