|
mathieu@183
|
1 |
<h1>How to submit new code to ns-3</h1>
|
|
mathieu@183
|
2 |
|
|
mathieu@183
|
3 |
<h2>Introduction</h2>
|
|
mathieu@183
|
4 |
|
|
mathieu@183
|
5 |
|
|
mathieu@183
|
6 |
<p>This document summarizes the steps to take to prepare code for submission
|
|
mathieu@183
|
7 |
to ns-3 as a new feature, such as a new feature of an existing simulation
|
|
mathieu@183
|
8 |
model, or a new model altogether. If you are interested in submitting a
|
|
mathieu@183
|
9 |
bugfix to an existing ns-3 feature, or new documentation, see the companion
|
|
mathieu@183
|
10 |
page <a href="bug-submission.html">How to submit a bug report</a> or
|
|
mathieu@183
|
11 |
<a href="doc-submission.html">How to submit documentation</a> to ns-3.</p>
|
|
mathieu@183
|
12 |
|
|
mathieu@183
|
13 |
<p>First, we actively encourage submission of new features to ns-3.
|
|
mathieu@183
|
14 |
Independent submissions are essential for open source projects, and
|
|
mathieu@183
|
15 |
you will also be credited as an author of future versions of ns-3.
|
|
mathieu@183
|
16 |
However, please keep in mind that there is already a large burden on the
|
|
mathieu@183
|
17 |
ns-3 maintainers to manage the flow of incoming contributions and maintain
|
|
mathieu@183
|
18 |
new and existing code. The goal of this document is thus to outline
|
|
mathieu@183
|
19 |
how you can help to minimize this burden and thus minimize the average
|
|
mathieu@183
|
20 |
time-to-merge of your code. Making sure that each code submission fulfills
|
|
mathieu@183
|
21 |
as many items as possible in the following checklist is the best way to
|
|
mathieu@183
|
22 |
ensure quick merging of your code.
|
|
mathieu@183
|
23 |
</p>
|
|
mathieu@183
|
24 |
|
|
mathieu@183
|
25 |
<p>
|
|
mathieu@183
|
26 |
In brief, we can summarize the guidelines as follows, and expand on them
|
|
mathieu@183
|
27 |
in detail below:
|
|
mathieu@183
|
28 |
<ul>
|
|
mathieu@183
|
29 |
<li>follow the ns-3 coding style
|
|
mathieu@183
|
30 |
<li>be licensed appropriately
|
|
mathieu@183
|
31 |
<li>write associated documentation, tests, examples
|
|
mathieu@183
|
32 |
<li>include a short description with each submission
|
|
mathieu@183
|
33 |
<li>minimize the size of each submission
|
|
mathieu@183
|
34 |
<li>changes must be coherent!
|
|
mathieu@183
|
35 |
<li>split your code into multi-part submissions
|
|
mathieu@183
|
36 |
<li>before sending a submission: ask yourself <i>if I were a reviewer, would I understand the submission?</i>
|
|
mathieu@183
|
37 |
<li>pick a submission tool:
|
|
mathieu@183
|
38 |
<ul>
|
|
mathieu@183
|
39 |
<li>a simple patch
|
|
mathieu@183
|
40 |
<li>a binary bundle
|
|
mathieu@183
|
41 |
<li>a hosted clone
|
|
mathieu@183
|
42 |
<li>patch emails
|
|
mathieu@183
|
43 |
</ul>
|
|
mathieu@183
|
44 |
<li>consider rewriting your development history
|
|
mathieu@183
|
45 |
</ul>
|
|
mathieu@183
|
46 |
<p>
|
|
mathieu@183
|
47 |
If you do not have the time to follow through the process to include your
|
|
mathieu@183
|
48 |
code in the main tree, please see <a href="#out-of-tree">below</a> about contributing
|
|
mathieu@183
|
49 |
ns-3 code that is not maintained in the main tree.
|
|
mathieu@183
|
50 |
</p>
|
|
mathieu@183
|
51 |
|
|
mathieu@183
|
52 |
<h2>Licensing and coding style</h2>
|
|
mathieu@183
|
53 |
|
|
mathieu@183
|
54 |
<h3>Licensing, copyright, and authorship</h3>
|
|
mathieu@183
|
55 |
|
|
mathieu@183
|
56 |
<p>
|
|
mathieu@183
|
57 |
All code submitted must conform to the project licensing framework, which
|
|
mathieu@183
|
58 |
is GNU GPLv2 compatibility. All new source files must contain a
|
|
mathieu@183
|
59 |
license statement. All modified source files must either conform to
|
|
mathieu@183
|
60 |
the license of the original file or (in rare cases) may add a
|
|
mathieu@183
|
61 |
license to the original license.
|
|
mathieu@183
|
62 |
|
|
mathieu@183
|
63 |
<p>Note that it is incumbent upon the submitter to make sure that the licensing
|
|
mathieu@183
|
64 |
attribution is correct and that the code is suitable for ns-3 inclusion.
|
|
mathieu@183
|
65 |
<i>Do not</i> include code (even snippets) from sources that have incompatible
|
|
mathieu@183
|
66 |
licenses.
|
|
mathieu@183
|
67 |
|
|
mathieu@183
|
68 |
<p>If you are writing a new file or making large modifications (more than 20 or 30 lines)
|
|
mathieu@183
|
69 |
to an existing file, include a copyright statement in the header, such as:
|
|
mathieu@183
|
70 |
<tt>Copyright 2009 John Doe</tt>. Do not use the phrase <tt>All rights reserved.</tt>.
|
|
mathieu@183
|
71 |
Optionally, you may also add a comment to help us track you down in case of problems in
|
|
mathieu@183
|
72 |
the code such as <tt>Author: john_doe@example.edu</tt>. However, do not create a chain of authors by
|
|
mathieu@183
|
73 |
appending to this list in the header such as <tt>Modified by Jane Doe 02/04/09</tt>;
|
|
mathieu@183
|
74 |
we use Mercurial change history to log who is changing what file.
|
|
mathieu@183
|
75 |
|
|
mathieu@183
|
76 |
<p>You may append any contributors to the <tt>AUTHORS</tt> file as you see fit.
|
|
mathieu@183
|
77 |
|
|
mathieu@183
|
78 |
<h3>Coding style</h3>
|
|
mathieu@183
|
79 |
|
|
mathieu@183
|
80 |
<p>
|
|
mathieu@183
|
81 |
Whatever code you submit, make sure that you follow the ns-3 <a href="http://www.nsnam.org/codingstyle.html">coding style</a>.
|
|
mathieu@183
|
82 |
|
|
mathieu@183
|
83 |
<p>Some of the rules it describes might seem arbitrary to you and you
|
|
mathieu@183
|
84 |
might disagree with these rules because the resulting code layout
|
|
mathieu@183
|
85 |
looks ugly to you. Even so, we ask you to consider carefully the
|
|
mathieu@183
|
86 |
purpose of a coding style: the purpose is to ensure that the overall
|
|
mathieu@183
|
87 |
codebase is consistently indented and laid out to make it easier for a
|
|
mathieu@183
|
88 |
trained eye to deal with large amounts of code.
|
|
mathieu@183
|
89 |
|
|
mathieu@183
|
90 |
<p>So, whether you disagree with our layout rules, or you are unsure
|
|
mathieu@183
|
91 |
about whether a specific piece of code matches the rules, focus
|
|
mathieu@183
|
92 |
on making sure that the coding style of your code matches the coding
|
|
mathieu@183
|
93 |
style of any surrounding ns-3 code.
|
|
mathieu@183
|
94 |
|
|
mathieu@183
|
95 |
<p>Of course, minor style errors and uncertainties can be easily
|
|
mathieu@183
|
96 |
corrected during reviews, but code submissions with a widescale
|
|
mathieu@183
|
97 |
ignorance of the ns-3 coding style will likely be bounced back until
|
|
mathieu@183
|
98 |
this step is taken.
|
|
mathieu@183
|
99 |
|
|
mathieu@183
|
100 |
<h3>Whitespace changes</h3>
|
|
mathieu@183
|
101 |
|
|
mathieu@183
|
102 |
<p>Do not ever submit code which contains whitespace/tab changes mixed
|
|
mathieu@183
|
103 |
with other non-whitespace changes. Generally, it's a good idea to avoid
|
|
mathieu@183
|
104 |
submitting whitespace changes at all, but, if you really must, submit
|
|
mathieu@183
|
105 |
a single change consisting only of whitespace changes.
|
|
mathieu@183
|
106 |
|
|
mathieu@183
|
107 |
<h2>Completing your code submission</h2>
|
|
mathieu@183
|
108 |
|
|
mathieu@183
|
109 |
<p>Often we have observed that contributors will provide nice new classes
|
|
mathieu@183
|
110 |
implementing a new model, but will fail to include supporting test
|
|
mathieu@183
|
111 |
code, example scripts, and documentation. Therefore, we ask people
|
|
mathieu@183
|
112 |
submitting the code (who are in the best position to do this type of
|
|
mathieu@183
|
113 |
work) to provide documentation, test code, and example scripts.
|
|
mathieu@183
|
114 |
|
|
mathieu@183
|
115 |
<p>Note that you may want to go through multiple phases of code reviews,
|
|
mathieu@183
|
116 |
and all of this supporting material may not be needed at the first stage (e.g.
|
|
mathieu@183
|
117 |
when you want some feedback on public API header declarations only, before
|
|
mathieu@183
|
118 |
delving into implementation). However, when it times come to merge your
|
|
mathieu@183
|
119 |
code, you should be prepared to provide these things, as fits your
|
|
mathieu@183
|
120 |
contribution (maintainers will provide some guidance here).
|
|
mathieu@183
|
121 |
|
|
mathieu@183
|
122 |
<h3>Including examples</h3>
|
|
mathieu@183
|
123 |
|
|
mathieu@183
|
124 |
<p>For many submissions, it will be important to include at least one example
|
|
mathieu@183
|
125 |
that exercises the new code, so the reviewer understands how it is intended
|
|
mathieu@183
|
126 |
to be used. For final submission, please consider to add as many examples
|
|
mathieu@183
|
127 |
as you can that will help new users of your code. The <tt>samples/</tt> and <tt>examples/</tt>
|
|
mathieu@183
|
128 |
directories are places for these files.
|
|
mathieu@183
|
129 |
|
|
mathieu@183
|
130 |
<h3>Testing</h3>
|
|
mathieu@183
|
131 |
|
|
mathieu@183
|
132 |
<p>Every new code should include automated tests. These should, where
|
|
mathieu@183
|
133 |
appropriate, be unit tests of model correctness, and may be validation
|
|
mathieu@183
|
134 |
tests of stochastic behavior. The test code should try to cover as
|
|
mathieu@183
|
135 |
much model code as possible, and should be checked as much as possible
|
|
mathieu@183
|
136 |
by regression tests. The project is still refining the testing framework
|
|
mathieu@183
|
137 |
and will add more detail to this section later, but suffice it to say
|
|
mathieu@183
|
138 |
for now that new features should come with test code to match; otherwise
|
|
mathieu@183
|
139 |
it risks falling into disrepair over time.
|
|
mathieu@183
|
140 |
|
|
mathieu@183
|
141 |
<p>
|
|
mathieu@183
|
142 |
TODO: Add a reference (perhaps a manual chapter), with some examples and
|
|
mathieu@183
|
143 |
samples, of how to write good ns-3 tests.
|
|
mathieu@183
|
144 |
|
|
mathieu@183
|
145 |
<h3>Documentation</h3>
|
|
mathieu@183
|
146 |
|
|
mathieu@183
|
147 |
<p>If you add a new features, or make changes to existing features, you
|
|
mathieu@183
|
148 |
need to update existing or write new documentation and example code.
|
|
mathieu@183
|
149 |
Consider the following checklist:
|
|
mathieu@183
|
150 |
<ul>
|
|
mathieu@183
|
151 |
<li>doxygen should be added to the header files, and should be checked
|
|
mathieu@183
|
152 |
for doxygen errors
|
|
mathieu@183
|
153 |
<li>incompatible API changes must be documented in <tt>CHANGES.html</tt>
|
|
mathieu@183
|
154 |
<li>new features should be described in <tt>RELEASE_NOTES</tt>
|
|
mathieu@183
|
155 |
<li>new API or changes to existing API must update the inline doxygen
|
|
mathieu@183
|
156 |
documentation in header files
|
|
mathieu@183
|
157 |
<li>consider updating or adding a new section to the tutorial in <tt>doc/tutorial/</tt>
|
|
mathieu@183
|
158 |
<li>consider updating or adding a new section to the manual in <tt>doc/manual/</tt>
|
|
mathieu@183
|
159 |
<li>update the <tt>AUTHORS</tt> list as appropriate
|
|
mathieu@183
|
160 |
</ul>
|
|
mathieu@183
|
161 |
|
|
mathieu@183
|
162 |
<h2>Preparing your code for review</h2>
|
|
mathieu@183
|
163 |
|
|
mathieu@183
|
164 |
<h3>Description</h3>
|
|
mathieu@183
|
165 |
|
|
mathieu@183
|
166 |
<p>For each code submission, include a description of what your code is
|
|
mathieu@183
|
167 |
doing, and why. Ideally, you should be able to provide a summary
|
|
mathieu@183
|
168 |
description in a 5-line paragraph with a 1-line (15 word) subject. If
|
|
mathieu@183
|
169 |
you fix a bug filed in our <a href="http://www.nsnam.org/bugzilla">bugzilla database</a>,
|
|
mathieu@183
|
170 |
the subject should include first the bug number, and then, the bug title.
|
|
mathieu@183
|
171 |
For example: <tt>bug 558: qos-tag.h is gone missing from wscript</tt>
|
|
mathieu@183
|
172 |
|
|
mathieu@183
|
173 |
<p>Bonus points go to submitters who provide a description of their
|
|
mathieu@183
|
174 |
testing strategy.
|
|
mathieu@183
|
175 |
|
|
mathieu@183
|
176 |
<h3>Minimize the size of each submission</h3>
|
|
mathieu@183
|
177 |
|
|
mathieu@183
|
178 |
<p>Each submission should be as small as possible. Ideally, each submission
|
|
mathieu@183
|
179 |
should deal with one issue only. If your description of your submission
|
|
mathieu@183
|
180 |
includes words such as <i>and</i>, it is a big red warning sign that you
|
|
mathieu@183
|
181 |
should think about splitting your submission in two separate smaller
|
|
mathieu@183
|
182 |
submissions, if the changes are not intertwined.
|
|
mathieu@183
|
183 |
|
|
mathieu@183
|
184 |
<h3>Coherent changes</h3>
|
|
mathieu@183
|
185 |
|
|
mathieu@183
|
186 |
<p>Each submission should be a coherent whole: if you need to edit ten
|
|
mathieu@183
|
187 |
files to get a feature to work, then, the submission should contain all
|
|
mathieu@183
|
188 |
the changes for these ten files. Of course, if you can split the feature
|
|
mathieu@183
|
189 |
in sub-features, then, you should do it to decrease the size of the
|
|
mathieu@183
|
190 |
submission as per the previous item.
|
|
mathieu@183
|
191 |
|
|
mathieu@183
|
192 |
<p>For example, if you have made changes to optimized a module and to fix
|
|
mathieu@183
|
193 |
a bug in another module, make sure you separate these two sets of changes
|
|
mathieu@183
|
194 |
in two separate submissions.
|
|
mathieu@183
|
195 |
|
|
mathieu@183
|
196 |
<h3>Multi-part submissions</h3>
|
|
mathieu@183
|
197 |
|
|
mathieu@183
|
198 |
<p>If you are working on a large new feature or a large refactoring, and
|
|
mathieu@183
|
199 |
because you will attempt to minimize the size of your submissions, you
|
|
mathieu@183
|
200 |
will have to split your large work in multiple separate submissions.
|
|
mathieu@183
|
201 |
|
|
mathieu@183
|
202 |
<p>Ideally, these submissions will be started by a detailed explanation
|
|
mathieu@183
|
203 |
of the overall plan such that code reviewers can review each submission
|
|
mathieu@183
|
204 |
separately but within a large context. This kind of work typically is
|
|
mathieu@183
|
205 |
split in multiple dependent steps where each step depends on the previous
|
|
mathieu@183
|
206 |
one. If this is the case, make it very clear in your initial explanation.
|
|
mathieu@183
|
207 |
If you can, minimize dependencies between each step such that reviewers
|
|
mathieu@183
|
208 |
can merge each step separately without having to consider the impact of
|
|
mathieu@183
|
209 |
merging one submission on other submissions.
|
|
mathieu@183
|
210 |
|
|
mathieu@183
|
211 |
<h3>Before sending a submission</h3>
|
|
mathieu@183
|
212 |
|
|
mathieu@183
|
213 |
<p>When you send a submission for review and merging in ns-3, before
|
|
mathieu@183
|
214 |
you hit the 'Send' button of your email client, ask yourself one
|
|
mathieu@183
|
215 |
last time: <i>If I were a reviewer, and I had to review that submission,
|
|
mathieu@183
|
216 |
what would I do ?</i>. Specifically, make sure that you have provided
|
|
mathieu@183
|
217 |
enough context to allow someone else to understand what you did and why.
|
|
mathieu@183
|
218 |
Keep in mind that your reviewer does not have access to a readable
|
|
mathieu@183
|
219 |
dump of your brain: he has access only to your code, and your emails.
|
|
mathieu@183
|
220 |
|
|
mathieu@183
|
221 |
<h3>Submission tools</h3>
|
|
mathieu@183
|
222 |
|
|
mathieu@183
|
223 |
<p>
|
|
mathieu@183
|
224 |
There are many ways to submit a piece of code. Some of them are not
|
|
mathieu@183
|
225 |
appropriate:
|
|
mathieu@183
|
226 |
<ul>
|
|
mathieu@183
|
227 |
<li>do not send us a modified version of each file you have changed
|
|
mathieu@183
|
228 |
<li>do not send us a .zip or .tar.gz file by email with a copy of
|
|
mathieu@183
|
229 |
every modified file
|
|
mathieu@183
|
230 |
<li>do not send us a patch against an unspecified version of ns-3
|
|
mathieu@183
|
231 |
</ul>
|
|
mathieu@183
|
232 |
|
|
mathieu@183
|
233 |
<p>Others are more appropriate:
|
|
mathieu@183
|
234 |
<ol>
|
|
mathieu@183
|
235 |
<li>a simple patch
|
|
mathieu@183
|
236 |
<li>patch reviews at <a href="http://codereview.appspot.com">codereview</a>
|
|
mathieu@183
|
237 |
<li>a binary bundle
|
|
mathieu@183
|
238 |
<li>a hosted clone
|
|
mathieu@183
|
239 |
<li>patchbombs
|
|
mathieu@183
|
240 |
</ol>
|
|
mathieu@183
|
241 |
|
|
mathieu@183
|
242 |
<ol>
|
|
mathieu@183
|
243 |
<li><b>a simple patch</b>
|
|
mathieu@183
|
244 |
|
|
mathieu@183
|
245 |
<p>Patches can be attached to a bug report or sent to our developer mailing-lists.
|
|
mathieu@183
|
246 |
|
|
mathieu@183
|
247 |
<p>The UNIX <tt>diff</tt> tool is the most common way of producing a patch: a
|
|
mathieu@183
|
248 |
patch is a text-based representation of the difference between
|
|
mathieu@183
|
249 |
two text files or two directories with text files in them. If you have
|
|
mathieu@183
|
250 |
two files, <tt>original.cc</tt>, and, <tt>modified.cc</tt>, you can generate a patch
|
|
mathieu@183
|
251 |
with the command <tt>diff -u original.cc modified.cc</tt>. If you wish to
|
|
mathieu@183
|
252 |
produce a patch between two directories, use the command
|
|
mathieu@183
|
253 |
<tt>diff -uprN original modified</tt>.
|
|
mathieu@183
|
254 |
|
|
mathieu@183
|
255 |
<p>Make sure you specify to the reviewer where the original files came
|
|
mathieu@183
|
256 |
from and make sure that the resulting patch file does not contain
|
|
mathieu@183
|
257 |
unexpected content by performing a final inspection of the patch
|
|
mathieu@183
|
258 |
file yourself.
|
|
mathieu@183
|
259 |
|
|
mathieu@183
|
260 |
<p>Patches such as this are sufficient for simple bug fixes or very simple
|
|
mathieu@183
|
261 |
small features.
|
|
mathieu@183
|
262 |
|
|
mathieu@183
|
263 |
<li><b>patch reviews at <a href="http://codereview.appspot.com">codereview</a></b>
|
|
mathieu@183
|
264 |
|
|
mathieu@183
|
265 |
<p>The best way to submit a larger patch for consideration is to request
|
|
mathieu@183
|
266 |
a patch review:
|
|
mathieu@183
|
267 |
|
|
mathieu@183
|
268 |
<ol>
|
|
mathieu@183
|
269 |
<li>download <a href="http://codereview.appspot.com/static/upload.py">upload.py</a>
|
|
mathieu@183
|
270 |
<li>record the changes you want to request a review for in a mercurial
|
|
mathieu@183
|
271 |
repository: <tt>hg commit ...</tt>
|
|
mathieu@183
|
272 |
<li>within the mercurial repository, run upload.py. Make sure you specify
|
|
mathieu@183
|
273 |
<tt>ns-3-reviews@googlegroups.com</tt> as a CC.
|
|
mathieu@183
|
274 |
<li>announce your review request on ns-developers
|
|
mathieu@183
|
275 |
</ol>
|
|
mathieu@183
|
276 |
|
|
mathieu@183
|
277 |
<p>When you send a tree without a detailed summary of your changes, it
|
|
mathieu@183
|
278 |
would help if you could send a list of the changesets you want to merge.
|
|
mathieu@183
|
279 |
To generate it, first merge with ns-3-dev and then, from your modified
|
|
mathieu@183
|
280 |
directory, run <tt>hg outgoing -p http://code.nsnam.org/ns-3-dev</tt>
|
|
mathieu@183
|
281 |
|
|
mathieu@183
|
282 |
<p>If you already pulled changes from ns-3-dev into your private repository
|
|
mathieu@183
|
283 |
after you started doing your private modifications, there is an issue to
|
|
mathieu@183
|
284 |
be considered. upload.py does not let you specify a range of revisions,
|
|
mathieu@183
|
285 |
nor a set of changesets. So if you just run <tt>upload.py</tt> in your private
|
|
mathieu@183
|
286 |
repository, the changesets pulled from ns-3-dev will also be published
|
|
mathieu@183
|
287 |
on codereview, which is, of course, not desirable.
|
|
mathieu@183
|
288 |
|
|
mathieu@183
|
289 |
<p>A possible workaround is to pull your changes into a temporary
|
|
mathieu@183
|
290 |
repository which is an up-to-date clone of ns-3-dev. The following code
|
|
mathieu@183
|
291 |
should do the trick. This code assumes that your private repository is in
|
|
mathieu@183
|
292 |
path DEV_BRANCH_WITH_NEW_FEATURE, and that it is in sync with ns-3-dev.
|
|
mathieu@183
|
293 |
|
|
mathieu@183
|
294 |
<pre>
|
|
mathieu@183
|
295 |
hg clone http://code.nsnam.org/ns-3-dev ns-3-tmp
|
|
mathieu@183
|
296 |
cd ns-3-tmp
|
|
mathieu@183
|
297 |
export REVNO=`hg tip -q | sed 's/:.*$//'`
|
|
mathieu@183
|
298 |
hg pull DEV_BRANCH_WITH_NEW_FEATURE
|
|
mathieu@183
|
299 |
hg merge
|
|
mathieu@183
|
300 |
hg commit -m "merged new feature"
|
|
mathieu@183
|
301 |
upload.py --rev=$REVNO --cc=ns-3-reviews@googlegroups.com
|
|
mathieu@183
|
302 |
</pre>
|
|
mathieu@183
|
303 |
|
|
mathieu@183
|
304 |
<li><b>Binary bundles</b>
|
|
mathieu@183
|
305 |
|
|
mathieu@183
|
306 |
|
|
mathieu@183
|
307 |
<p>ns-3 uses <a href="http://www.selenic.com/mercurial/">mercurial</a> as its
|
|
mathieu@183
|
308 |
version control tool: a quick introduction to using it can be found on our
|
|
mathieu@183
|
309 |
<a href="http://www.nsnam.org/mercurial.html.">homepage</a>.
|
|
mathieu@183
|
310 |
Further extensive documentation and manuals are available from the mercurial
|
|
mathieu@183
|
311 |
<a href="http://www.selenic.com/mercurial/">homepage</a>.
|
|
mathieu@183
|
312 |
|
|
mathieu@183
|
313 |
<p>If you get used to use mercurial to record your daily/hourly work using
|
|
mathieu@183
|
314 |
mercurial in a local clone of the ns-3 main repository, and if you want to
|
|
mathieu@183
|
315 |
share that work with other people to get initial feedback about your work,
|
|
mathieu@183
|
316 |
your implementation approach, and start a high-level discussion about it,
|
|
mathieu@183
|
317 |
you can easily package all your local work history as a single binary bundle
|
|
mathieu@183
|
318 |
file with the <tt>hg bundle</tt> command and send this file over email.
|
|
mathieu@183
|
319 |
|
|
mathieu@183
|
320 |
<li><b>Hosted clones</b>
|
|
mathieu@183
|
321 |
|
|
mathieu@183
|
322 |
|
|
mathieu@183
|
323 |
<p>If your bundles grow large in size, it can become tricky to send them over
|
|
mathieu@183
|
324 |
email: hosting a clone of your mercurial repository is a simple way to work
|
|
mathieu@183
|
325 |
around this. If you have a host with a static ip address and/or a hostname,
|
|
mathieu@183
|
326 |
you can run <tt>hg serve</tt> within your repository in this host and send instead
|
|
mathieu@183
|
327 |
to your co-workers a url to that repository: if I run <tt>hg serve -d -p 8080</tt>
|
|
mathieu@183
|
328 |
on my local ns-3-dev clone, I could send the url <tt>http://diese.inria.fr:8080/</tt>
|
|
mathieu@183
|
329 |
to my co-workers to allow them to pull all my development history from there.
|
|
mathieu@183
|
330 |
|
|
mathieu@183
|
331 |
<p>If you don't have a static ip address or hostname, or are located behind
|
|
mathieu@183
|
332 |
a NAT or a firewall, you have to use a third-party hosting provider for your
|
|
mathieu@183
|
333 |
code. A small list of hosting providers is available
|
|
mathieu@183
|
334 |
<a href="http://www.selenic.com/mercurial/wiki/index.cgi/MercurialHosting">there</a>
|
|
mathieu@183
|
335 |
|
|
mathieu@183
|
336 |
|
|
mathieu@183
|
337 |
<p>We can also provide hosting to ns-3 developers on <a href="http://code.nsnam.org/">code.nsnam.org</a>
|
|
mathieu@183
|
338 |
should none of the above alternative work for you.
|
|
mathieu@183
|
339 |
|
|
mathieu@183
|
340 |
<li><b>Patchbombs</b>
|
|
mathieu@183
|
341 |
|
|
mathieu@183
|
342 |
<p>Patchbombs are a nice way to perform a request for a detailed
|
|
mathieu@183
|
343 |
review. Make sure you enable the patchbomb extension in your ~/.hgrc:
|
|
mathieu@183
|
344 |
<pre>
|
|
mathieu@183
|
345 |
[extensions]
|
|
mathieu@183
|
346 |
hgext.patchbomb =
|
|
mathieu@183
|
347 |
</pre>
|
|
mathieu@183
|
348 |
Make sure you configure your patchbomb extension correctly:
|
|
mathieu@183
|
349 |
<tt>man 5 hgrc</tt> and look in the [email] and [smtp] sections
|
|
mathieu@183
|
350 |
|
|
mathieu@183
|
351 |
Finally:
|
|
mathieu@183
|
352 |
<pre>
|
|
mathieu@183
|
353 |
hg email -i -t ns-developers@isi.edu http://code.nsnam.org/ns-3-dev
|
|
mathieu@183
|
354 |
</pre>
|
|
mathieu@183
|
355 |
|
|
mathieu@183
|
356 |
<p>Beware that generating too many emails with this tool without doing
|
|
mathieu@183
|
357 |
proper <i>history rewriting</i> to produce clean easy-to-review patches will
|
|
mathieu@183
|
358 |
be considered rude.
|
|
mathieu@183
|
359 |
|
|
mathieu@183
|
360 |
</ol>
|
|
mathieu@183
|
361 |
|
|
mathieu@183
|
362 |
<h3>History rewriting</h3>
|
|
mathieu@183
|
363 |
|
|
mathieu@183
|
364 |
<p>The idea behind history rewriting is to request a code submitter to
|
|
mathieu@183
|
365 |
re-arrange their repository history prior to merging in the main
|
|
mathieu@183
|
366 |
ns-3 repository.
|
|
mathieu@183
|
367 |
|
|
mathieu@183
|
368 |
<p>For example, let's say that during development of a new feature, you
|
|
mathieu@183
|
369 |
decide to use your mercurial repository as a fancy version-enabled
|
|
mathieu@183
|
370 |
backup system: you do a lot of work, and regularly commit it to save it.
|
|
mathieu@183
|
371 |
When you are done implementing and testing that new feature, the resulting
|
|
mathieu@183
|
372 |
repository history as shown with <tt>hg log</tt> will look very verbose, and
|
|
mathieu@183
|
373 |
will most likely contain a lot of commit messages such as <i>fix bug</i>.
|
|
mathieu@183
|
374 |
Clearly, none of these commits are very helpful and there is little point
|
|
mathieu@183
|
375 |
in keeping them around: they make it painful to use the annotate, and bisect
|
|
mathieu@183
|
376 |
commands, and will make review of the final mercurial tree harder than it
|
|
mathieu@183
|
377 |
need to be.
|
|
mathieu@183
|
378 |
|
|
mathieu@183
|
379 |
<p>A simple way to work around these problems is to ask each contributor to
|
|
mathieu@183
|
380 |
re-structure their commit history before submitting their tree for review:
|
|
mathieu@183
|
381 |
<ul>
|
|
mathieu@183
|
382 |
<li>pointless backup commits are deleted from the history
|
|
mathieu@183
|
383 |
<li>commits are re-organized in sub-feature commits
|
|
mathieu@183
|
384 |
<li>each commit is made buildable
|
|
mathieu@183
|
385 |
<li>etc.
|
|
mathieu@183
|
386 |
</ul>
|
|
mathieu@183
|
387 |
|
|
mathieu@183
|
388 |
<ol>
|
|
mathieu@183
|
389 |
<li><b>Rewrite a new history from scratch</b>
|
|
mathieu@183
|
390 |
|
|
mathieu@183
|
391 |
<p>Once you are done with a new feature, you can generate one final patch
|
|
mathieu@183
|
392 |
with the mercurial <tt>diff</tt> command and apply it to a clean repository
|
|
mathieu@183
|
393 |
as one single commit with a nice new commit message.
|
|
mathieu@183
|
394 |
|
|
mathieu@183
|
395 |
<p>A variant on the above is to split the final commit in multiple smaller
|
|
mathieu@183
|
396 |
commits, each of which addresses one aspect of the final feature and
|
|
mathieu@183
|
397 |
make sure that each commit is still buildable.
|
|
mathieu@183
|
398 |
|
|
mathieu@183
|
399 |
<li><b>Build clean history from the start</b>
|
|
mathieu@183
|
400 |
|
|
mathieu@183
|
401 |
<p>Instead of using mercurial as a powerful backup system and trying to go back
|
|
mathieu@183
|
402 |
later, some users prefer to use tools such as 'mq' or 'pbranch' to split
|
|
mathieu@183
|
403 |
their work from the start in a set of separate entities and still record
|
|
mathieu@183
|
404 |
somewhere their day-to-day development history.
|
|
mathieu@183
|
405 |
|
|
mathieu@183
|
406 |
<p>More information on these tools:
|
|
mathieu@183
|
407 |
<ul>
|
|
mathieu@183
|
408 |
<li><a href="http://hgbook.red-bean.com/read/managing-change-with-mercurial-queues.html">Managing change with mercurial queues</a>
|
|
mathieu@183
|
409 |
<li><a href="http://hgbook.red-bean.com/read/advanced-uses-of-mercurial-queues.html">Advanced uses of mercurial queues</a>
|
|
mathieu@183
|
410 |
<li>The <a href="http://arrenbrecht.ch/mercurial/pbranch/">Pbranch</a> extension.
|
|
mathieu@183
|
411 |
</ul>
|
|
mathieu@183
|
412 |
|
|
mathieu@183
|
413 |
</ol>
|
|
mathieu@183
|
414 |
|
|
mathieu@183
|
415 |
<h2>Submitting out-of-tree code</h2>
|
|
mathieu@183
|
416 |
|
|
mathieu@183
|
417 |
<p>TODO: Write about how contributors can send a tarball
|
|
mathieu@183
|
418 |
for archiving at code.nsnam.org if they do not want to go through
|
|
mathieu@183
|
419 |
the process for main-tree code. Write about src/contrib.
|