Spelling fixes; tweak explanation of commit messages.
[emacs.git] / admin / notes / repo
blob601c41062fda05f689b0d63de47f34916a61bb77
1 NOTES ON COMMITTING TO EMACS'S REPOSITORY    -*- outline -*-
3 * Use conventions in commit messages
5 Commit messages should follow conventions used in modern distributed
6 version control systems.
8 - Start with a self-contained topic line, preferably no longer than 75 chars.
10 - Make the second line blank, if there are two or more lines.
12 - Follow the blank line with ChangeLog-like entries for the specific
13   changes you made, if any.  As long as Emacs maintains ChangeLog
14   files, just copy the entries you made in them to the commit message
15   after the blank line.  Often, the first line of a ChangeLog entry
16   can serve as the topic line, so you can merely insert a blank line
17   after it.
19 - Use UTF-8 encoding in the commit message.
21 * Commit to the right branch
23 You can view the available Emacs branches at
25 http://bzr.savannah.gnu.org/r/emacs/
27 Development normally takes places on the trunk.
28 Sometimes specialized features are developed on separate branches
29 before possibly being merged to the trunk.
31 Development is discussed on the emacs-devel mailing list.
33 Sometime before the release of a new major version of Emacs
34 a "feature freeze" is imposed on the trunk.  No new features may be
35 added after this point.  This is usually some months before the release.
37 Shortly before the release, a release branch is created, and the
38 trunk is then free for development.
40 For example, "emacs-23" for Emacs 23.2 and later, "EMACS_23_1_RC" for
41 23.1, "EMACS_22_BASE" for 22.x, and "EMACS_21_1_RC" for 21.x.
43 Consult emacs-devel for exactly what kinds of changes are allowed
44 on what branch at any time.
46 ** elpa
48 This branch does not contain a copy of Emacs, but of the Emacs Lisp
49 package archive (elpa.gnu.org).  See admin/notes/elpa for further
50 explanation, and the README file in the branch for usage
51 instructions.
53 * Install changes only on one branch, let them get merged elsewhere if needed.
55 In particular, install bug-fixes only on the release branch (if there
56 is one) and let them get synced to the trunk; do not install them by
57 hand on the trunk as well.  E.g. if there is an active "emacs-24" branch
58 and you have a bug-fix appropriate for the next emacs-24.x release,
59 install it only on the emacs-24 branch, not on the trunk as well.
61 Installing things manually into more than one branch makes merges more
62 difficult.
64 http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01124.html
66 The exception is, if you know that the change will be difficult to
67 merge to the trunk (eg because the trunk code has changed a lot).
68 In that case, it's helpful if you can apply the change to both trunk
69 and branch yourself (when committing the branch change, indicate
70 in the commit log that it should not be merged to the trunk; see below).
72 * Installing changes from your personal branches.
74 If your branch has only a single commit, or many different real
75 commits, it is fine to do a merge.  If your branch has only a very
76 small number of "real" commits, but several "merge from trunks", it is
77 preferred that you take your branch's diff, apply it to the trunk, and
78 commit directly, not merge.  This keeps the history cleaner.
80 In general, when working on some feature in a separate branch, it is
81 preferable not to merge from trunk until you are done with the
82 feature.  Unless you really need some change that was done on the
83 trunk while you were developing on the branch, you don't really need
84 those merges; just merge once, when you are done with the feature, and
85 Bazaar will take care of the rest.  Bazaar is much better in this than
86 CVS, so interim merges are unnecessary.
88 Or use shelves; or rebase; or do something else.  See the thread for
89 yet another fun excursion into the exciting world of version control.
91 http://lists.gnu.org/archive/html/emacs-devel/2010-04/msg00086.html
93 * Installing changes from gnulib
95 Some of the files in Emacs are copied from gnulib.  To synchronize
96 these files from the version of gnulib that you have checked out into
97 a sibling directory of your branch, type "admin/merge-gnulib"; this
98 will check out the latest version of gnulib if there is no sibling
99 directory already.  It is a good idea to run "bzr status" afterwards,
100 so that if a gnulib module added a file, you can record the new file
101 using "bzr add".  After synchronizing from gnulib, do a "make" in the
102 usual way.
104 To change the set of gnulib modules, change the GNULIB_MODULES
105 variable in admin/merge-gnulib before running it.
107 If you remove a gnulib module, or if a gnulib module
108 removes a file, then remove the corresponding files by hand.
110 * Backporting a bug-fix from the trunk to a branch (e.g. "emacs-24").
112 Indicate in the commit log that there is no need to merge the commit
113 to the trunk.  Anything that matches `bzrmerge-skip-regexp' will do;
114 eg start the commit message with "Backport:".  This is helpful for the
115 person merging the release branch to the trunk.
117 http://lists.gnu.org/archive/html/emacs-devel/2010-05/msg00262.html
119 * How to merge changes from emacs-24 to trunk
121 The following description uses bound branches, presumably it works in
122 a similar way with unbound ones.
124 0) (This step is only necessary if using bzr older than 2.4.0.)
125 Get the bzr changelog_merge plugin:
127 cd ~/.bazaar/plugins
128 bzr branch http://bazaar.launchpad.net/~spiv/bzr-changelog-merge/trunk changelog_merge
130 This plugin should make merging ChangeLogs smoother.  It merges new
131 entries to the top of the file, rather than trying to fit them in
132 mid-way through.  Newer versions of the plugin should also be able to
133 deal with changes to *old* ChangeLog entries, that should not be
134 floated to the head of the file (see launchpad#723968).
136 It is included in bzr from 2.4.0 onwards, so remember to delete the
137 copy in ~/.bazaar if you upgrade bzr.
139 Maybe the default Emacs behavior without this plugin is better,
140 though, it's not clear yet.
142 1) Get clean, up-to-date copies of the emacs-24 and trunk branches.
143 Check for any uncommitted changes with bzr status.
145 2) M-x cd /path/to/trunk
147 The first time only, do this:
148 cd .bzr/branch
149 Add the following line to branch.conf:
150 changelog_merge_files = ChangeLog
152 3) load admin/bzrmerge.el
154 4) M-x bzrmerge RET /path/to/emacs-24 RET
156 It will prompt about revisions that should be skipped, based on the
157 regexp in bzrmerge-missing.  If there are more revisions that you know
158 need skipping, you'll have to do that by hand.
160 5) It will stop if there are any conflicts.  Resolve them.
161 Using smerge-mode, there are menu items to skip to the next conflict,
162 and to take either the trunk, branch, or both copies.
164 6) After resolving all conflicts, you might need to run the bzmerge
165 command again if there are more revisions still to merge.
167 Do not commit (or exit Emacs) until you have run bzrmerge to completion.
169 Before committing, check bzr status and bzr diff output.
170 If you have run bzrmerge enough times, the "pending merge tip" in bzr
171 status should be the last revision from the emacs-24 branch, and
172 bzr status -v should show all the revisions you expect to merge.
174 (Note that it will also show "skipped" revisions.  This is expected,
175 and is due to a technical limitation of bzr.  The log data for those
176 revisions gets merged, the actual changes themselves do not.
177 http://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00609.html )
179 Notes:
181 1) If a file is modified in emacs-24, and deleted in the trunk, you
182 get a "contents conflict".  Assuming the changes don't need to be in
183 the trunk at all, use `bzr resolve path/to/file --take-this' to keep the
184 trunk version.  Prior to bzr 2.2.3, this may fail.  You can just
185 delete the .OTHER etc files by hand and use bzr resolve path/to/file.
187 * Sanity-checking branch merges
189 Inspect the ChangeLog entries (e.g. in case too many entries have been
190 included or whitespace between entries needs fixing).  bzrmerge tries
191 to fix up the dates to today's date, but it only does this where there
192 are conflicts.  If you used the changelog_merge plugin, there won't be
193 any conflicts, and (at time of writing) you will need to adjust dates
194 by hand.  In any case, if someone made multiple ChangeLog entries on
195 different days in the branch, you may wish to collapse them all to a
196 single entry for that author in the trunk (because in the trunk they
197 all appear under the same date).  Obviously, if there are multiple
198 changes to the same file by different authors, don't break the logical
199 ordering in doing this.
201 You may see conflicts in autoload md5sums in comments.  Strictly
202 speaking, the right thing to do is merge everything else, resolve the
203 conflict by choosing either the trunk or branch version, then run
204 `make -C lisp autoloads' to update the md5sums to the correct trunk
205 value before committing.
207 * Re-adding a file that has been removed from the repository
209 It's easy to get this wrong. Let's suppose you've done:
211 bzr remove file; bzr commit
213 and now, sometime later, you realize this was a mistake and file needs
214 to be brought back.  DON'T just do:
216 bzr add file; bzr commit
218 This restores file, but without its history (`bzr log file' will be
219 very short).  This is because file gets re-added with a new file-id
220 (use `bzr file-id file' to see the id).
222 Instead of adding the file, try:
224 bzr revert -rN file; bzr commit
226 where revision N+1 is the one where file was removed.
228 You could also try `bzr add --file-ids-from', if you have a copy of
229 another branch where file still exists.
231 * Undoing a commit (uncommitting)
233 It is possible to undo/remove a bzr commit (ie, to uncommit).
234 Only do this if you really, really, need to.  For example, if you
235 somehow made a commit that triggers a bug in bzr itself.
236 Don't do it because you made a typo in a commit or the log.
238 If you do need to do this, do it as soon as possible, because the
239 longer you leave it, the more work is involved.
241 0. First, tell emacs-devel that you are going to do this, and suggest
242 people not commit anything to the affected branch for the duration.
244 In the following, replace USER with your Savannah username, and
245 BRANCH with the name of the branch.
246 Let's assume that revno 100 is the bad commit, and that there have
247 been two more commits after that (because nothing is ever easy).
249 1. Ensure your copy of the branch is up-to-date (for a bound
250 branch, bzr up; for an unbound branch, bzr pull) and has no local
251 changes (bzr st).
253 2. Make a record of the commits you are going to undo:
254 bzr diff -c 102 > /tmp/102.diff
257 Also record the commit message, author, and any --fixes information.
259 3. Most Emacs branches are set up to prevent just this kind of thing.
260 So we need to disable that protection:
262 bzr config append_revisions_only=False \
263   -d bzr+ssh://USER@bzr.savannah.gnu.org/emacs/BRANCH/
265 4. Undo the commits:
266 bzr uncommit -r -4
268 This will show the commits it is going to undo, and prompt you to confirm.
270 5. If using an unbound branch:
271 bzr push --overwrite
273 6. Now, replay the commits you just undid (obviously, fix whatever it
274 was in the bad commit that caused the problem):
276 patch -p0 < /tmp/100.diff
277 bzr commit --author ... --fixes ... -F /tmp/100.log
280 7. If using an unbound branch:
281 bzr push
283 8. Finally, re-enable the branch protection:
284 bzr config append_revisions_only=True \
285   -d bzr+ssh://USER@bzr.savannah.gnu.org/emacs/BRANCH/
287 9. Tell emacs-devel that it is ok to use the branch again.
288 Anyone with local changes should back them up before doing anything.
290 For a bound branch, bzr up will convert any of the undone commits to a
291 pending merge. Just bzr revert these away.
293 For an unbound branch, bzr pull will complain about diverged branches
294 and refuse to do anything.  Use bzr pull --overwrite.
296 * Loggerhead
298 Loggerhead is the bzr tool for viewing a repository over http (similar
299 to ViewVC).  The central version is at http://bzr.savannah.gnu.org/lh/emacs,
300 but if you just like the way this interface presents data, then if
301 you have your own copy of the repository, you can operate your own
302 Loggerhead server in stand-alone mode, and so help to reduce the load
303 on Savannah:
305   bzr branch lp:loggerhead ~/.bazaar/plugins/loggerhead
306   cd /path/to/emacs/bzr
307   bzr serve --http
309 You may need to install some Python dependencies to get this command to work.
310 For example, on RHEL6 I needed:
312   yum install python-paste python-simplejson
313   yum --enablerepo=epel install python-simpletal
315 Then point your web-browser to http://127.0.0.1:8080/ .
317 * Bisecting
319 This is a semi-automated way to find the revision that introduced a bug.
321 First, get the bzr bisect plugin if you do not have it already:
323   cd ~/.bazaar/plugins
324   bzr branch lp:bzr-bisect bisect
326 `bzr help bisect' should work now.
328 It's probably simplest to make a new copy of the branch to work in
329 from this point onwards.
331 Identify the last known "good" revision where the relevant issue is
332 NOT present (e.g. maybe Emacs 24.1).  Let's say this is revision 1000.
334   bzr bisect start
335   bzr bisect no -r 1000
337 At this point, bzr will switch to the mid-point of revision 1000 and
338 the current revision.  If you know that the issue was definitely
339 present in some specific revision (say 2000), you can use:
341   bzr bisect yes -r 2000
343 Now bzr switches to revision 1500.
345 Now test whether the issue is present.  You might need to rebuild
346 Emacs to do this, or if you know the problem is in a specific Lisp
347 file, you might be able to get away with just loading that one file in
348 current Emacs.
350 If the issue is present, use
352   bzr bisect yes
354 If it is not, use
356   bzr bisect no
358 Repeat until you zero-in on the specific revision.
360 When finished, use
362   bzr bisect reset
364 or simply delete the entire branch if you created it just for this.
366 ** Some tips for speeding up bisections:
368 *** Use ./configure --without-all --cache-file=/tmp/config.cache
369 (assuming the thing you are testing for does not need a feature that
370 --without-all disables).
372 *** Rather than `make', use `make -C lib && make -C src bootstrap-emacs
373 && make -C src emacs', to avoid compiling the non-essential lisp files
374 (unless the thing you are testing for only shows up in compiled files;
375 if so compile just the relevant ones).  Obviously use whatever make -j
376 option is appropriate for your system.
378 * Commit emails
380 ** Old method: bzr-hookless-email
381 https://launchpad.net/bzr-hookless-email
383 Runs hourly via cron.  Must ask Savannah admins to enable/disable it
384 for each branch.  Stores the last revision that it mailed as
385 last_revision_mailed in branch.conf on the server.  Breaks with bzr 2.6:
387 http://lists.gnu.org/archive/html/savannah-hackers-public/2013-05/msg00000.html
389 Fix from https://bugs.launchpad.net/bzr-hookless-email/+bug/988195
390 only partially works.  Breaks again on every merge commit:
392 https://lists.ubuntu.com/archives/bazaar/2013q2/075520.html
393 http://lists.gnu.org/archive/html/savannah-hackers-public/2013-05/msg00024.html
395 You can force it to skip the merge commit by changing the value for
396 last_revision_mailed, eg:
398 bzr config last_revision_mailed=xfq.free@gmail.com-20130603233720-u1aumaxvf3o0rlai -d bzr+ssh://USERNAME@bzr.savannah.gnu.org/emacs/trunk/
400 ** New method: bzr-email plugin
401 https://launchpad.net/bzr-email
402 http://lists.gnu.org/archive/html/savannah-hackers-public/2013-06/msg00007.html
404 Runs on commit.  Projects can enable it themselves by using `bzr
405 config' to set post_commit_to option for a branch.  See `bzr help email'
406 (if you have the plugin installed) for other options.
408 The From: address will be that of your Savannah account, rather than
409 your `bzr whoami' information.
411 Note: if you have the bzr-email plugin installed locally, then when
412 you commit to the Emacs repository it will also try to send a commit
413 email from your local machine.  If your machine is not configured to
414 send external mail, this will just fail.  In any case, you may prefer
415 to either remove the plugin from your machine, or disable it for Emacs
416 branches.  You can do this either by editing branch.conf in your Emacs
417 branches, to override the server setting (untested; not sure this
418 works), or by adding an entry to ~/.bazaar/locations.conf:
420   [bzr+ssh://USERNAME@bzr.savannah.gnu.org/emacs/*/]
421   post_commit_to = ""
423 You have to use locations.conf rather than bazaar.conf because the
424 latter has a lower priority than branch.conf.
426 * Using git-bzr
428 ** initially
430 You can use Git locally to talk to the Bazaar repo as a "remote" repo
431 via git-bzr (aka git-remote-bzr).  Initial clone:
433  git clone bzr::bzr+ssh://USER@bzr.sv.gnu.org/emacs/trunk e
435 This creates the working dir e/ (with subdir .git, etc).  Disk usage
436 is 13G (as of early 2014), so you will probably want to repack:
438  git repack -a -d -f --window=250 --depth=250 --window-memory=N
440 where N is chosen to avoid swapping.  E.g., given 512MB RAM, N="200m"
441 results in "du -sh .git" => 559M, about double the smallest reported
442 value (obtained with "deprecated" command "git gc --aggressive").
444 ** steady-state
446 Use "fetch", "pull" and other remote-to-local commands as usual.
448 For "push", the Emacs Bazaar repo is configured with
450  append_revisions_only = True
452 so some versions of git-remote-bzr may raise AppendRevisionsOnlyViolation
453 (in func do_export) instead of displaying a "non fast-forward" message
454 and skipping the branch.  See:
456  http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg00436.html
458 which includes a provisional patch to git-remote-bzr to do that.
460 ** remote name
462 Although Git itself is agnostic about what names you choose for
463 the remote repo, it seems git-bzr is more likely to get confused.
464 After the clone as described above, the remote name is "origin";
465 changing it is Not Recommended.  [Insert 9-hour high-entropy then
466 mysterious bug w/ JSON parsing errors anecdote here. --ttn]