Project

General

Profile

DevelopersProcess » History » Version 14

Robert Terzi, 12/01/2013 02:48 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
7 10 Dan Smith
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@. 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
<pre>
10
[ui]
11
username = Joe Bob <joebob@gmail.com>
12
[extensions]
13
hgext.mq=
14
hgext.patchbomb=
15 7 Dan Smith
16 1 Dan Smith
[email]
17
from = Joe Bob <joebob@gmail.com>
18
method = smtp
19
20
[smtp]
21
host = smtp.gmail.com
22
</pre>
23
24 13 Dan Smith
h2. Getting the code
25
26
<pre>
27
hg clone http://d-rats.com/hg/chirp.hg
28
cd chirp.hg
29
</pre>
30
31 3 Dan Smith
h2. Bug Tracking
32
33
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.
34
35 1 Dan Smith
h2. Submitting a patch
36
37 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.
38
39 14 Robert Terzi
You must include an Issue Number (#123) in the first line of the commit message to tie each patch to an issue for tracking purposes.
40
41 2 Dan Smith
h3. Making a change
42
43
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:
44
45
<pre>
46
% hg status -mar
47
M chirp/ic2820.py
48
% hg diff
49
diff -r a132c837fd25 chirp/ic2820.py
50
--- a/chirp/ic2820.py   Mon Dec 24 08:17:19 2012 -0800
51
+++ b/chirp/ic2820.py   Mon Dec 24 08:56:29 2012 -0800
52
@@ -16,6 +16,8 @@
53
 from chirp import chirp_common, icf, util, directory
54
 from chirp import bitwise
55
 
56
+# Just added a comment
57
+
58
 MEM_FORMAT = """
59
 struct {
60
   u32  freq;
61
</pre>
62
63
The first command shows me that @chirp/ic2820.py@ has been modified, and the second shows me the actual changes that have been made.
64
65
h3. Soft-committing a Change
66
67 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:
68 2 Dan Smith
69
<pre>
70 11 Tom Hayward
% hg qnew -ef mypatch     # Here an editor will open to compose a commit message
71 2 Dan Smith
% hg qapplied             # This shows that the patch is now applied
72 11 Tom Hayward
mypatch
73 2 Dan Smith
</pre>
74
75 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:
76 2 Dan Smith
77 11 Tom Hayward
| Command | Description |
78
| @hg export tip@           | This will show me the whole patch, with the commit message |
79 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. |
80
| @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.
81
82
See "Sending a Change" below.
83
84
85
h3. 
86
h3. Working with Patches (mq mercurial extension)
87
88
The following commands demonstrate how the mq extension to hg can be used for managing patches.
89
90
| Command | Description |
91
| @hg export tip@           | This will show me the whole patch, with the commit message |
92 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. |
93
| @hg qpop@                 | Remove it from the tree |
94
| @hg qapplied@             | This shows that no patches are applied |
95
| @hg qunapplied
96
mypatch@                   | This shows that our patch is not applied |
97
| @hg qpush@                | This adds the patch back to the tree |
98
| @hg qapplied
99
mypatch@                   | This shows that our patch is applied |
100
| @hg qpop@                 | This removes it again |
101
| @hg qdel mypatch@         | This deletes it permanently |
102 2 Dan Smith
103 12 Tom Hayward
If this tool intrigues you, you can learn how to use it here: http://mercurial.selenic.com/wiki/MqTutorial
104
105 4 Dan Smith
h3. Testing
106
107
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). To run the whole set, do this:
108
109
<pre>
110
% cd tests
111
% ./run_tests
112
</pre>
113
114 8 Dan Smith
Note that on Windows, you probably want to run the script like this:
115
116
<pre>
117 9 Dan Smith
C:\Users\Foo\chirp.hg\tests> python run_tests
118 8 Dan Smith
</pre>
119
120 4 Dan Smith
To run just a single driver's tests:
121
122
<pre>
123
% ./run_tests -d Icom_IC-2820H
124
</pre>
125
126
To run just a specific test:
127
128
<pre>
129
% ./run_tests -t Edges
130
</pre>
131
132
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 send a sample image to the development mailing list to accompany your patch submission.
133
134
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.
135 1 Dan Smith
136 14 Robert Terzi
h3. Sending a change (Submitting a patch)
137 2 Dan Smith
138
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:
139
140
<pre>
141
% hg export tip > add_comment.patch
142
</pre>
143
144
You can also configure the tool to email it directly, in which case you need only do:
145
146
<pre>
147
% hg email tip
148
</pre>
149 3 Dan Smith
150
You will be prompted for the destination address.
151
152
h2. Patch Guidelines
153
154 1 Dan Smith
h3. The Commit Message
155 3 Dan Smith
156 14 Robert Terzi
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:
157 3 Dan Smith
158
<pre>
159 14 Robert Terzi
[uv5r] Add support for firmware >= 291 Fixes #123
160 3 Dan Smith
</pre>
161
162
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.
163
164
h3. Scope
165
166
Guidelines:
167
168
 * Patches should be small and concise. Try to keep a single standing change to a single patch.
169
 * Don't fix several bugs in a single patch, unless there is a technical reason to do so.
170
 * Don't fix, cleanup, or change random whitespace in the patch unless that is the sole purpose of the patch.