docs/C - Misc. tutorials.txt
1.1 --- a/docs/C - Misc. tutorials.txt Sat Aug 14 16:37:11 2010 +0200
1.2 +++ b/docs/C - Misc. tutorials.txt Mon Jan 03 19:07:34 2011 +0100
1.3 @@ -91,3 +91,200 @@
1.4 before executing ct-ng build.
1.5 See http://www.gnu.org/software/make/manual/html_node/Libraries_002fSearch.html
1.6 as an explanation.
1.7 +
1.8 +
1.9 +Using Mercurial to hack crosstool-NG |
1.10 +-------------------------------------+
1.11 +
1.12 +Contributed by: Titus von Boxberg
1.13 +
1.14 +PREREQUISITES:
1.15 +
1.16 +Configuring Mercurial:
1.17 + You need mercurial with the following extensions:
1.18 + - mq : http://mercurial.selenic.com/wiki/MqExtension
1.19 + - patchbomb : http://mercurial.selenic.com/wiki/PatchbombExtension
1.20 + Usually, these two extensions are already part of the installation package.
1.21 + The mq extension maintains a separate queue of your local changes
1.22 + that you can change at any later time.
1.23 + With the patchbomb extension you can email those patches directly
1.24 + from your local repo.
1.25 +
1.26 + Your configuration file for mercurial, e.g. ~/.hgrc should contain
1.27 + at least the following sections (but have a look at `man hgrc`):
1.28 + # ---
1.29 + [email]
1.30 + # configure sending patches directly via Mercurial
1.31 + from = "Your Name" <your@email.address>
1.32 + # How to send email:
1.33 + method = smtp
1.34 +
1.35 + [smtp]
1.36 + # SMTP configuration (only for method=smtp)
1.37 + host = localhost
1.38 + tls = true
1.39 + username =
1.40 + password =
1.41 +
1.42 + [extensions]
1.43 + # The following lines enable the two extensions:
1.44 + hgext.mq =
1.45 + hgext.patchbomb =
1.46 + # ----
1.47 +
1.48 +Create your local repository as a clone:
1.49 + hg clone http://ymorin.is-a-geek.org/hg/crosstool-ng crosstool-ng
1.50 +
1.51 +Setting up the mq extension in your local copy:
1.52 + cd crosstool-ng
1.53 + hg qinit
1.54 +
1.55 +
1.56 +CREATING PATCHES:
1.57 +
1.58 +Recording your changes in the patch queue maintained by mq:
1.59 + # First, create a new patch entry in the patch queue:
1.60 + hg qnew -D -U -e short_patch_name1
1.61 + <edit patch description as commit message (see below for an example)>
1.62 +
1.63 + <now edit the ct-ng sources and check them>
1.64 +
1.65 + # if you execute `hg status` here, your modifications of the working
1.66 + # copy should show up.
1.67 +
1.68 + # Now the following command takes your modifications from the working copy
1.69 + # into the patch entry
1.70 + hg qrefresh -D [-e]
1.71 + <reedit patch description [-e] if desired>
1.72 +
1.73 + # Now your changes are recorded, and `hg status` should show a clean
1.74 + # working copy
1.75 +
1.76 +Repeat the above steps for all your modifications.
1.77 +The command `hg qseries` informs you about the content of your patch queue.
1.78 +
1.79 +
1.80 +CONTRIBUTING YOUR PATCHES:
1.81 +
1.82 +Once you are satisfied with your patch series, you can (you should!)
1.83 +contribute them back to upstream.
1.84 +This is easily done using the `hg email` command.
1.85 +
1.86 +`hg email` sends your new changesets to a specified list of recipients,
1.87 +each patch in its own email, all ordered in the way you entered them (oldest
1.88 +first). The command line flag --outgoing selects all changesets that are in
1.89 +your local but not yet in the upstream repository. Here, these are exactly
1.90 +the ones you entered into your local patch queue in the section above, so
1.91 +--outgoing is what you want.
1.92 +
1.93 +Each email gets the subject set to: "[PATCH x of n] <series summary>"
1.94 +where 'x' is the serial number in the email series, and 'n' is the total number
1.95 +of patches in the series. The body of the email is the complete patch, plus
1.96 +a handful of metadata, that helps properly apply the patch, keeping the log
1.97 +message, attribution and date, tracking file changes (move, delete, modes...)
1.98 +
1.99 +`hg email` also threads all outgoing patch emails below an introductory
1.100 +message. You should use the introductory message (command line flag --intro)
1.101 +to describe the scope and motivation for the whole patch series. The subject
1.102 +for the introductory message gets set to: "[PATCH 0 of n] <series summary>"
1.103 +and you get the chance to set the <series summary>.
1.104 +
1.105 +Here is a sample `hg email` complete command line:
1.106 +Note: replace " (at) " with "@"
1.107 +
1.108 + hg email --outgoing --intro \
1.109 + --to '"Yann E. MORIN" <yann.morin.1998 (at) anciens.enib.fr>' \
1.110 + --cc 'crossgcc (at) sourceware.org'
1.111 +
1.112 + # It then opens an editor and lets you enter the subject
1.113 + # and the body for the introductory message.
1.114 +
1.115 +Use `hg email` with the additional command line switch -n to
1.116 +first have a look at the email(s) without actually sending them.
1.117 +
1.118 +
1.119 +MAINTAINING YOUR PATCHES:
1.120 +
1.121 +When the patches are refined by discussing them on the mailing list,
1.122 +you may want to finalize and resend them.
1.123 +
1.124 +The mq extension has the idiosyncrasy of imposing a stack onto the queue:
1.125 +You can always reedit/refresh only the patch on top of stack.
1.126 +The queue consists of applied and unapplied patches
1.127 +(if you reached here via the above steps, all of your patches are applied),
1.128 +where the 'stack' consists of the applied patches, and 'top of stack'
1.129 +is the latest applied patch.
1.130 +
1.131 +The following output of `hg qseries` is now used as an example:
1.132 + 0 A short_patch_name1
1.133 + 1 A short_patch_name2
1.134 + 2 A short_patch_name3
1.135 + 3 A short_patch_name4
1.136 +
1.137 +You are now able to edit patch 'short_patch_name4' (which is top of stack):
1.138 + <Edit the sources>
1.139 + # and execute again
1.140 + hg qrefresh -D [-e]
1.141 + <and optionally [-e] reedit the commit message>
1.142 +
1.143 +If you want to edit e.g. patch short_patch_name2, you have to modify
1.144 +mq's stack so this patch gets top of stack.
1.145 +For this purpose see `hg help qgoto`, `hg help qpop`, and `hg help qpush`.
1.146 +
1.147 + hg qgoto short_patch_name2
1.148 + # The patch queue should now look like
1.149 + hg qseries
1.150 + 0 A short_patch_name1
1.151 + 1 A short_patch_name2
1.152 + 2 U short_patch_name3
1.153 + 3 U short_patch_name4
1.154 + # so patch # 1 (short_patch_name2) is top of stack.
1.155 + <now reedit the sources for short_patch_name2>
1.156 + # and execute again
1.157 + hg qrefresh -D [-e]
1.158 + <and optionally [-e] reedit the commit message>
1.159 + # the following command reapplies the now unapplied two patches:
1.160 + hg qpush -a
1.161 + # you can also use `hg qgoto short_patch_name4` to get there again.
1.162 +
1.163 +
1.164 +RESENDING YOUR REEDITED PATCHES:
1.165 +
1.166 +By mailing list policy, please resend your complete patch series.
1.167 +--> Go back to section "CONTRIBUTING YOUR PATCHES" and resubmit the full set.
1.168 +
1.169 +
1.170 +SYNCING WITH UPSTREAM AGAIN:
1.171 +
1.172 +You can sync your repo with upstream at any time by executing
1.173 + # first unapply all your patches:
1.174 + hg qpop -a
1.175 + # next fetch new changesets from upstream
1.176 + hg pull
1.177 + # then update your working copy
1.178 + hg up
1.179 + # optionally remove already upstream integrated patches (see below)
1.180 + hg qdelete <short_name_of_already_applied_patch>
1.181 + # and reapply your patches if any non upstream-integrated left (but see below)
1.182 + hg qpush -a
1.183 +
1.184 +Eventually, your patches get included into the upstream repository
1.185 +which you initially cloned.
1.186 +In this case, before executing the hg qpush -a from above
1.187 +you should manually "hg qdelete" the patches that are already integrated upstream.
1.188 +
1.189 +
1.190 +HOW TO FORMAT COMMIT MESSAGES (aka patch desciptions):
1.191 +
1.192 +Commit messages should look like (without leading pipes):
1.193 + |component: short, one-line description
1.194 + |
1.195 + |optional longer description
1.196 + |on multiple lines if needed
1.197 +
1.198 +Here is an example commit message (see revision a53a5e1d61db):
1.199 + |comp-libs/cloog: fix building
1.200 + |
1.201 + |For CLooG/PPL 0.15.3, the directory name was simply cloog-ppl.
1.202 + |For any later versions, the directory name does have the version, such as
1.203 + |cloog-ppl-0.15.4.