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