comparison en/ch11-mq.xml @ 809:ef53d025f410

Mention qdelete and qimport -r.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 23 Apr 2009 22:24:02 -0700
parents 3b640272a966
children 1a0a78e197c3
comparison
equal deleted inserted replaced
808:557552d4699f 809:ef53d025f410
116 modifications those patches make.</para> 116 modifications those patches make.</para>
117 117
118 <para id="x_3b9">Quilt knows nothing about revision control tools, so it 118 <para id="x_3b9">Quilt knows nothing about revision control tools, so it
119 works equally well on top of an unpacked tarball or a 119 works equally well on top of an unpacked tarball or a
120 Subversion working copy.</para> 120 Subversion working copy.</para>
121 121 </sect2>
122 </sect2> 122
123 <sect2 id="sec:mq:quilt-mq"> 123 <sect2 id="sec:mq:quilt-mq">
124 <title>From patchwork quilt to Mercurial Queues</title> 124 <title>From patchwork quilt to Mercurial Queues</title>
125 125
126 <para id="x_3ba">In mid-2005, Chris Mason took the features of quilt and 126 <para id="x_3ba">In mid-2005, Chris Mason took the features of quilt and
127 wrote an extension that he called Mercurial Queues, which 127 wrote an extension that he called Mercurial Queues, which
179 binary-search through all changesets and applied patches to see 179 binary-search through all changesets and applied patches to see
180 where a bug got introduced or fixed. You can use the <command 180 where a bug got introduced or fixed. You can use the <command
181 role="hg-cmd">hg annotate</command> command to see which 181 role="hg-cmd">hg annotate</command> command to see which
182 changeset or patch modified a particular line of a source file. 182 changeset or patch modified a particular line of a source file.
183 And so on.</para> 183 And so on.</para>
184 184 </sect1>
185 </sect1> 185
186 <sect1 id="sec:mq:patch"> 186 <sect1 id="sec:mq:patch">
187 <title>Understanding patches</title> 187 <title>Understanding patches</title>
188 188
189 <para id="x_3c2">Because MQ doesn't hide its patch-oriented nature, it is 189 <para id="x_3c2">Because MQ doesn't hide its patch-oriented nature, it is
190 helpful to understand what patches are, and a little about the 190 helpful to understand what patches are, and a little about the
242 242
243 <para id="x_3c9">We will return to some of the more subtle aspects of patches 243 <para id="x_3c9">We will return to some of the more subtle aspects of patches
244 later (in <xref linkend="sec:mq:adv-patch"/>), but you 244 later (in <xref linkend="sec:mq:adv-patch"/>), but you
245 should have 245 should have
246 enough information now to use MQ.</para> 246 enough information now to use MQ.</para>
247 247 </sect1>
248 </sect1> 248
249 <sect1 id="sec:mq:start"> 249 <sect1 id="sec:mq:start">
250 <title>Getting started with Mercurial Queues</title> 250 <title>Getting started with Mercurial Queues</title>
251 251
252 <para id="x_3ca">Because MQ is implemented as an extension, you must 252 <para id="x_3ca">Because MQ is implemented as an extension, you must
253 explicitly enable before you can use it. (You don't need to 253 explicitly enable before you can use it. (You don't need to
263 commands available. To verify that the extension is working, 263 commands available. To verify that the extension is working,
264 you can use <command role="hg-cmd">hg help</command> to see if 264 you can use <command role="hg-cmd">hg help</command> to see if
265 the <command role="hg-ext-mq">qinit</command> command is now 265 the <command role="hg-ext-mq">qinit</command> command is now
266 available.</para> 266 available.</para>
267 267
268 &interaction.mq.qinit-help.help; 268 &interaction.mq.qinit-help.help;
269 269
270 <para id="x_3cc">You can use MQ with <emphasis>any</emphasis> Mercurial 270 <para id="x_3cc">You can use MQ with <emphasis>any</emphasis> Mercurial
271 repository, and its commands only operate within that 271 repository, and its commands only operate within that
272 repository. To get started, simply prepare the repository using 272 repository. To get started, simply prepare the repository using
273 the <command role="hg-ext-mq">qinit</command> command.</para> 273 the <command role="hg-ext-mq">qinit</command> command.</para>
274 274
275 &interaction.mq.tutorial.qinit; 275 &interaction.mq.tutorial.qinit;
276 276
277 <para id="x_3cd">This command creates an empty directory called <filename 277 <para id="x_3cd">This command creates an empty directory called <filename
278 role="special" class="directory">.hg/patches</filename>, where 278 role="special" class="directory">.hg/patches</filename>, where
279 MQ will keep its metadata. As with many Mercurial commands, the 279 MQ will keep its metadata. As with many Mercurial commands, the
280 <command role="hg-ext-mq">qinit</command> command prints nothing 280 <command role="hg-ext-mq">qinit</command> command prints nothing
290 <para id="x_3cf">MQ will use this as the name of an actual file in the 290 <para id="x_3cf">MQ will use this as the name of an actual file in the
291 <filename role="special" 291 <filename role="special"
292 class="directory">.hg/patches</filename> directory, as you 292 class="directory">.hg/patches</filename> directory, as you
293 can see below.</para> 293 can see below.</para>
294 294
295 &interaction.mq.tutorial.qnew; 295 &interaction.mq.tutorial.qnew;
296 296
297 <para id="x_3d0">Also newly present in the <filename role="special" 297 <para id="x_3d0">Also newly present in the <filename role="special"
298 class="directory">.hg/patches</filename> directory are two 298 class="directory">.hg/patches</filename> directory are two
299 other files, <filename role="special">series</filename> and 299 other files, <filename role="special">series</filename> and
300 <filename role="special">status</filename>. The <filename 300 <filename role="special">status</filename>. The <filename
318 <para id="x_3d2">Once you have created your new patch, you can edit files 318 <para id="x_3d2">Once you have created your new patch, you can edit files
319 in the working directory as you usually would. All of the 319 in the working directory as you usually would. All of the
320 normal Mercurial commands, such as <command role="hg-cmd">hg 320 normal Mercurial commands, such as <command role="hg-cmd">hg
321 diff</command> and <command role="hg-cmd">hg 321 diff</command> and <command role="hg-cmd">hg
322 annotate</command>, work exactly as they did before.</para> 322 annotate</command>, work exactly as they did before.</para>
323 323 </sect2>
324 </sect2> 324
325 <sect2> 325 <sect2>
326 <title>Refreshing a patch</title> 326 <title>Refreshing a patch</title>
327 327
328 <para id="x_3d3">When you reach a point where you want to save your work, 328 <para id="x_3d3">When you reach a point where you want to save your work,
329 use the <command role="hg-ext-mq">qrefresh</command> command 329 use the <command role="hg-ext-mq">qrefresh</command> command
330 to update the patch you are working on.</para> 330 to update the patch you are working on.</para>
331 331
332 &interaction.mq.tutorial.qrefresh; 332 &interaction.mq.tutorial.qrefresh;
333 333
334 <para id="x_3d4">This command folds the changes you have made in the 334 <para id="x_3d4">This command folds the changes you have made in the
335 working directory into your patch, and updates its 335 working directory into your patch, and updates its
336 corresponding changeset to contain those changes.</para> 336 corresponding changeset to contain those changes.</para>
337 337
340 <quote>checkpoint</quote> your work. Refresh your patch at an 340 <quote>checkpoint</quote> your work. Refresh your patch at an
341 opportune time; try an experiment; and if the experiment 341 opportune time; try an experiment; and if the experiment
342 doesn't work out, <command role="hg-cmd">hg revert</command> 342 doesn't work out, <command role="hg-cmd">hg revert</command>
343 your modifications back to the last time you refreshed.</para> 343 your modifications back to the last time you refreshed.</para>
344 344
345 &interaction.mq.tutorial.qrefresh2; 345 &interaction.mq.tutorial.qrefresh2;
346 346 </sect2>
347 </sect2> 347
348 <sect2> 348 <sect2>
349 <title>Stacking and tracking patches</title> 349 <title>Stacking and tracking patches</title>
350 350
351 <para id="x_3d6">Once you have finished working on a patch, or need to work 351 <para id="x_3d6">Once you have finished working on a patch, or need to work
352 on another, you can use the <command 352 on another, you can use the <command
353 role="hg-ext-mq">qnew</command> command again to create a 353 role="hg-ext-mq">qnew</command> command again to create a
354 new patch. Mercurial will apply this patch on top of your 354 new patch. Mercurial will apply this patch on top of your
355 existing patch.</para> 355 existing patch.</para>
356 356
357 &interaction.mq.tutorial.qnew2; 357 &interaction.mq.tutorial.qnew2;
358
358 <para id="x_3d7">Notice that the patch contains the changes in our prior 359 <para id="x_3d7">Notice that the patch contains the changes in our prior
359 patch as part of its context (you can see this more clearly in 360 patch as part of its context (you can see this more clearly in
360 the output of <command role="hg-cmd">hg 361 the output of <command role="hg-cmd">hg
361 annotate</command>).</para> 362 annotate</command>).</para>
362 363
365 role="hg-ext-mq">qrefresh</command>, we've been careful to 366 role="hg-ext-mq">qrefresh</command>, we've been careful to
366 only use regular Mercurial commands. However, MQ provides 367 only use regular Mercurial commands. However, MQ provides
367 many commands that are easier to use when you are thinking 368 many commands that are easier to use when you are thinking
368 about patches, as illustrated below.</para> 369 about patches, as illustrated below.</para>
369 370
370 &interaction.mq.tutorial.qseries; 371 &interaction.mq.tutorial.qseries;
371 372
372 <itemizedlist> 373 <itemizedlist>
373 <listitem><para id="x_3d9">The <command 374 <listitem><para id="x_3d9">The <command
374 role="hg-ext-mq">qseries</command> command lists every 375 role="hg-ext-mq">qseries</command> command lists every
375 patch that MQ knows about in this repository, from oldest 376 patch that MQ knows about in this repository, from oldest
380 role="hg-ext-mq">qapplied</command> command lists every 381 role="hg-ext-mq">qapplied</command> command lists every
381 patch that MQ has <emphasis>applied</emphasis> in this 382 patch that MQ has <emphasis>applied</emphasis> in this
382 repository, again from oldest to newest (most recently 383 repository, again from oldest to newest (most recently
383 applied).</para> 384 applied).</para>
384 </listitem></itemizedlist> 385 </listitem></itemizedlist>
385 386 </sect2>
386 </sect2> 387
387 <sect2> 388 <sect2>
388 <title>Manipulating the patch stack</title> 389 <title>Manipulating the patch stack</title>
389 390
390 <para id="x_3db">The previous discussion implied that there must be a 391 <para id="x_3db">The previous discussion implied that there must be a
391 difference between <quote>known</quote> and 392 difference between <quote>known</quote> and
418 creates a new changeset to correspond to the patch, and the 419 creates a new changeset to correspond to the patch, and the
419 patch's changes once again become present in the working 420 patch's changes once again become present in the working
420 directory. See below for examples of <command 421 directory. See below for examples of <command
421 role="hg-ext-mq">qpop</command> and <command 422 role="hg-ext-mq">qpop</command> and <command
422 role="hg-ext-mq">qpush</command> in action.</para> 423 role="hg-ext-mq">qpush</command> in action.</para>
423 &interaction.mq.tutorial.qpop; 424
425 &interaction.mq.tutorial.qpop;
424 426
425 <para id="x_3df">Notice that once we have popped a patch or two patches, 427 <para id="x_3df">Notice that once we have popped a patch or two patches,
426 the output of <command role="hg-ext-mq">qseries</command> 428 the output of <command role="hg-ext-mq">qseries</command>
427 remains the same, while that of <command 429 remains the same, while that of <command
428 role="hg-ext-mq">qapplied</command> has changed.</para> 430 role="hg-ext-mq">qapplied</command> has changed.</para>
429 431
430 432 </sect2>
431 </sect2> 433
432 <sect2> 434 <sect2>
433 <title>Pushing and popping many patches</title> 435 <title>Pushing and popping many patches</title>
434 436
435 <para id="x_3e0">While <command role="hg-ext-mq">qpush</command> and 437 <para id="x_3e0">While <command role="hg-ext-mq">qpush</command> and
436 <command role="hg-ext-mq">qpop</command> each operate on a 438 <command role="hg-ext-mq">qpop</command> each operate on a
442 role="hg-ext-mq-cmd-qpop-opt">-a</option> option to <command 444 role="hg-ext-mq-cmd-qpop-opt">-a</option> option to <command
443 role="hg-ext-mq">qpop</command> causes it to pop all applied 445 role="hg-ext-mq">qpop</command> causes it to pop all applied
444 patches. (For some more ways to push and pop many patches, 446 patches. (For some more ways to push and pop many patches,
445 see <xref linkend="sec:mq:perf"/> below.)</para> 447 see <xref linkend="sec:mq:perf"/> below.)</para>
446 448
447 &interaction.mq.tutorial.qpush-a; 449 &interaction.mq.tutorial.qpush-a;
448 450 </sect2>
449 </sect2> 451
450 <sect2> 452 <sect2>
451 <title>Safety checks, and overriding them</title> 453 <title>Safety checks, and overriding them</title>
452 454
453 <para id="x_3e1">Several MQ commands check the working directory before 455 <para id="x_3e1">Several MQ commands check the working directory before
454 they do anything, and fail if they find any modifications. 456 they do anything, and fail if they find any modifications.
458 role="hg-ext-mq">qnew</command> command will not create a 460 role="hg-ext-mq">qnew</command> command will not create a
459 new patch if there are outstanding changes, caused in this 461 new patch if there are outstanding changes, caused in this
460 case by the <command role="hg-cmd">hg add</command> of 462 case by the <command role="hg-cmd">hg add</command> of
461 <filename>file3</filename>.</para> 463 <filename>file3</filename>.</para>
462 464
463 &interaction.mq.tutorial.add; 465 &interaction.mq.tutorial.add;
464 466
465 <para id="x_3e2">Commands that check the working directory all take an 467 <para id="x_3e2">Commands that check the working directory all take an
466 <quote>I know what I'm doing</quote> option, which is always 468 <quote>I know what I'm doing</quote> option, which is always
467 named <option>-f</option>. The exact meaning of 469 named <option>-f</option>. The exact meaning of
468 <option>-f</option> depends on the command. For example, 470 <option>-f</option> depends on the command. For example,
472 creates, but <command role="hg-cmd">hg qpop <option 474 creates, but <command role="hg-cmd">hg qpop <option
473 role="hg-ext-mq-cmd-qpop-opt">hg -f</option></command> 475 role="hg-ext-mq-cmd-qpop-opt">hg -f</option></command>
474 will revert modifications to any files affected by the patch 476 will revert modifications to any files affected by the patch
475 that it is popping. Be sure to read the documentation for a 477 that it is popping. Be sure to read the documentation for a
476 command's <option>-f</option> option before you use it!</para> 478 command's <option>-f</option> option before you use it!</para>
477 479 </sect2>
478 </sect2> 480
479 <sect2> 481 <sect2>
480 <title>Working on several patches at once</title> 482 <title>Working on several patches at once</title>
481 483
482 <para id="x_3e3">The <command role="hg-ext-mq">qrefresh</command> command 484 <para id="x_3e3">The <command role="hg-ext-mq">qrefresh</command> command
483 always refreshes the <emphasis>topmost</emphasis> applied 485 always refreshes the <emphasis>topmost</emphasis> applied
497 patch to save your in-progress changes, and <command 499 patch to save your in-progress changes, and <command
498 role="hg-ext-mq">qpop</command> down to the core patch. Fix 500 role="hg-ext-mq">qpop</command> down to the core patch. Fix
499 the core bug, <command role="hg-ext-mq">qrefresh</command> the 501 the core bug, <command role="hg-ext-mq">qrefresh</command> the
500 core patch, and <command role="hg-ext-mq">qpush</command> back 502 core patch, and <command role="hg-ext-mq">qpush</command> back
501 to the UI patch to continue where you left off.</para> 503 to the UI patch to continue where you left off.</para>
502 504 </sect2>
503 </sect2> 505 </sect1>
504 </sect1> 506
505 <sect1 id="sec:mq:adv-patch"> 507 <sect1 id="sec:mq:adv-patch">
506 <title>More about patches</title> 508 <title>More about patches</title>
507 509
508 <para id="x_3e5">MQ uses the GNU <command>patch</command> command to apply 510 <para id="x_3e5">MQ uses the GNU <command>patch</command> command to apply
509 patches, so it's helpful to know a few more detailed aspects of 511 patches, so it's helpful to know a few more detailed aspects of
578 complexity may become unnecessary; see <ulink role="hg-bug" 580 complexity may become unnecessary; see <ulink role="hg-bug"
579 url="http://www.selenic.com/mercurial/bts/issue311">issue 581 url="http://www.selenic.com/mercurial/bts/issue311">issue
580 311</ulink> for details. 582 311</ulink> for details.
581 </para> 583 </para>
582 </sect2> 584 </sect2>
585
583 <sect2> 586 <sect2>
584 <title>Strategies for applying a patch</title> 587 <title>Strategies for applying a patch</title>
585 588
586 <para id="x_3ec">When <command>patch</command> applies a hunk, it tries a 589 <para id="x_3ec">When <command>patch</command> applies a hunk, it tries a
587 handful of successively less accurate strategies to try to 590 handful of successively less accurate strategies to try to
621 <filename>foo</filename> with six hunks, and one of them fails 624 <filename>foo</filename> with six hunks, and one of them fails
622 to apply, you will have: an unmodified 625 to apply, you will have: an unmodified
623 <filename>foo.orig</filename>, a <filename>foo.rej</filename> 626 <filename>foo.orig</filename>, a <filename>foo.rej</filename>
624 containing one hunk, and <filename>foo</filename>, containing 627 containing one hunk, and <filename>foo</filename>, containing
625 the changes made by the five successful hunks.</para> 628 the changes made by the five successful hunks.</para>
626 629 </sect2>
627 </sect2> 630
628 <sect2> 631 <sect2>
629 <title>Some quirks of patch representation</title> 632 <title>Some quirks of patch representation</title>
630 633
631 <para id="x_3f0">There are a few useful things to know about how 634 <para id="x_3f0">There are a few useful things to know about how
632 <command>patch</command> works with files.</para> 635 <command>patch</command> works with files.</para>
661 empty files, so you cannot use a patch to represent the 664 empty files, so you cannot use a patch to represent the
662 notion <quote>I added this empty file to the 665 notion <quote>I added this empty file to the
663 tree</quote>.</para> 666 tree</quote>.</para>
664 </listitem></itemizedlist> 667 </listitem></itemizedlist>
665 </sect2> 668 </sect2>
669
666 <sect2> 670 <sect2>
667 <title>Beware the fuzz</title> 671 <title>Beware the fuzz</title>
668 672
669 <para id="x_3f7">While applying a hunk at an offset, or with a fuzz factor, 673 <para id="x_3f7">While applying a hunk at an offset, or with a fuzz factor,
670 will often be completely successful, these inexact techniques 674 will often be completely successful, these inexact techniques
684 against a different revision of the underlying files. In some 688 against a different revision of the underlying files. In some
685 cases, such as when you're maintaining a patch that must sit 689 cases, such as when you're maintaining a patch that must sit
686 on top of multiple versions of a source tree, it's acceptable 690 on top of multiple versions of a source tree, it's acceptable
687 to have a patch apply with some fuzz, provided you've verified 691 to have a patch apply with some fuzz, provided you've verified
688 the results of the patching process in such cases.</para> 692 the results of the patching process in such cases.</para>
689 693 </sect2>
690 </sect2> 694
691 <sect2> 695 <sect2>
692 <title>Handling rejection</title> 696 <title>Handling rejection</title>
693 697
694 <para id="x_3f9">If <command role="hg-ext-mq">qpush</command> fails to 698 <para id="x_3f9">If <command role="hg-ext-mq">qpush</command> fails to
695 apply a patch, it will print an error message and exit. If it 699 apply a patch, it will print an error message and exit. If it
705 <para id="x_3fb">Unfortunately, there aren't any great techniques for 709 <para id="x_3fb">Unfortunately, there aren't any great techniques for
706 dealing with rejected hunks. Most often, you'll need to view 710 dealing with rejected hunks. Most often, you'll need to view
707 the <filename role="special">.rej</filename> file and edit the 711 the <filename role="special">.rej</filename> file and edit the
708 target file, applying the rejected hunks by hand.</para> 712 target file, applying the rejected hunks by hand.</para>
709 713
710 <para id="x_3fc">If you're feeling adventurous, Neil Brown, a Linux kernel 714 <para id="x_3fd">A Linux kernel hacker, Chris Mason (the author
711 hacker, wrote a tool called <command>wiggle</command> 715 of Mercurial Queues), wrote a tool called
712 <citation>web:wiggle</citation>, which is more vigorous than 716 <command>mpatch</command> (<ulink
713 <command>patch</command> in its attempts to make a patch 717 url="http://oss.oracle.com/~mason/mpatch/">http://oss.oracle.com/~mason/mpatch/</ulink>),
714 apply.</para>
715
716 <para id="x_3fd">Another Linux kernel hacker, Chris Mason (the author of
717 Mercurial Queues), wrote a similar tool called
718 <command>mpatch</command> <citation>web:mpatch</citation>,
719 which takes a simple approach to automating the application of 718 which takes a simple approach to automating the application of
720 hunks rejected by <command>patch</command>. The 719 hunks rejected by <command>patch</command>. The
721 <command>mpatch</command> command can help with four common 720 <command>mpatch</command> command can help with four common
722 reasons that a hunk may be rejected:</para> 721 reasons that a hunk may be rejected:</para>
723 722
734 </listitem> 733 </listitem>
735 <listitem><para id="x_401">A hunk removes lines with slightly different 734 <listitem><para id="x_401">A hunk removes lines with slightly different
736 content than those currently present in the file.</para> 735 content than those currently present in the file.</para>
737 </listitem></itemizedlist> 736 </listitem></itemizedlist>
738 737
739 <para id="x_402">If you use <command>wiggle</command> or 738 <para id="x_402">If you use <command>mpatch</command>, you
740 <command>mpatch</command>, you should be doubly careful to 739 should be doubly careful to check your results when you're
741 check your results when you're done. In fact, 740 done. In fact, <command>mpatch</command> enforces this method
742 <command>mpatch</command> enforces this method of 741 of double-checking the tool's output, by automatically
743 double-checking the tool's output, by automatically dropping 742 dropping you into a merge program when it has done its job, so
744 you into a merge program when it has done its job, so that you 743 that you can verify its work and finish off any remaining
745 can verify its work and finish off any remaining
746 merges.</para> 744 merges.</para>
747 745 </sect2>
748 </sect2> 746 </sect1>
749 </sect1> 747
748 <sect1>
749 <title>More on patch management</title>
750
751 <para>As you grow familiar with MQ, you will find yourself wanting
752 to perform other kinds of patch management operations.</para>
753
754 <sect2>
755 <title>Deleting unwanted patches</title>
756
757 <para>If you want to get rid of a patch, use the <command
758 role="hg-ext-mq">hg qdelete</command> command to delete the
759 patch file and remove its entry from the patch series. If you
760 try to delete a patch that is still applied, <command
761 role="hg-ext-mq">hg qdelete</command> will refuse.</para>
762
763 &interaction.ch11-qdelete.go;
764 </sect2>
765
766 <sect2>
767 <title>Converting to and from permanent revisions</title>
768
769 <para>Once you're done working on a patch and want to turn it
770 into a permanent changeset, use the <command
771 role="hg-ext-mq">hg qdelete -r</command> command. Pass a
772 revision to the <option>-r</option> option to identify the
773 patch that you want to turn into a regular changeset; this
774 patch must already be applied.</para>
775
776 &interaction.ch11-qdelete.convert;
777
778 <para>It is also possible to turn an existing changeset into a
779 patch, by passing the <option>-r</option> option to <command
780 role="hg-ext-mq">hg qimport</command>.</para>
781
782 &interaction.ch11-qdelete.import;
783
784 <para>Note that it only makes sense to convert a changeset into
785 a patch if you have not propagated that changeset into any
786 other repositories. The imported changeset's ID will change
787 every time you refresh the patch, which will make Mercurial
788 treat it as unrelated to the original changeset if you have
789 pushed it somewhere else.</para>
790 </sect2>
791 </sect1>
792
750 <sect1 id="sec:mq:perf"> 793 <sect1 id="sec:mq:perf">
751 <title>Getting the best performance out of MQ</title> 794 <title>Getting the best performance out of MQ</title>
752 795
753 <para id="x_403">MQ is very efficient at handling a large number of patches. 796 <para id="x_403">MQ is very efficient at handling a large number of patches.
754 I ran some performance experiments in mid-2006 for a talk that I 797 I ran some performance experiments in mid-2006 for a talk that I
755 gave at the 2006 EuroPython conference 798 gave at the 2006 EuroPython conference. I used as my data set the
756 <citation>web:europython</citation>. I used as my data set the
757 Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. 799 Linux 2.6.17-mm1 patch series, which consists of 1,738 patches.
758 I applied these on top of a Linux kernel repository containing 800 I applied these on top of a Linux kernel repository containing
759 all 27,472 revisions between Linux 2.6.12-rc2 and Linux 801 all 27,472 revisions between Linux 2.6.12-rc2 and Linux
760 2.6.17.</para> 802 2.6.17.</para>
761 803
797 839
798 <para id="x_408">You can identify a destination patch using either the name 840 <para id="x_408">You can identify a destination patch using either the name
799 of the patch, or by number. If you use numeric addressing, 841 of the patch, or by number. If you use numeric addressing,
800 patches are counted from zero; this means that the first patch 842 patches are counted from zero; this means that the first patch
801 is zero, the second is one, and so on.</para> 843 is zero, the second is one, and so on.</para>
802 844 </sect1>
803 </sect1> 845
804 <sect1 id="sec:mq:merge"> 846 <sect1 id="sec:mq:merge">
805 <title>Updating your patches when the underlying code 847 <title>Updating your patches when the underlying code
806 changes</title> 848 changes</title>
807 849
808 <para id="x_409">It's common to have a stack of patches on top of an 850 <para id="x_409">It's common to have a stack of patches on top of an
897 extra head using <command role="hg-cmd">hg qpop -a -n 939 extra head using <command role="hg-cmd">hg qpop -a -n
898 patches.N</command> or <command role="hg-cmd">hg 940 patches.N</command> or <command role="hg-cmd">hg
899 strip</command>. You can delete <filename role="special" 941 strip</command>. You can delete <filename role="special"
900 class="directory">.hg/patches.N</filename> once you are sure 942 class="directory">.hg/patches.N</filename> once you are sure
901 that you no longer need it as a backup.</para> 943 that you no longer need it as a backup.</para>
902 944 </sect1>
903 </sect1> 945
904 <sect1> 946 <sect1>
905 <title>Identifying patches</title> 947 <title>Identifying patches</title>
906 948
907 <para id="x_416">MQ commands that work with patches let you refer to a patch 949 <para id="x_416">MQ commands that work with patches let you refer to a patch
908 either by using its name or by a number. By name is obvious 950 either by using its name or by a number. By name is obvious
961 distinguish applied patches from underlying 1003 distinguish applied patches from underlying
962 <quote>normal</quote> revisions. The following example shows a 1004 <quote>normal</quote> revisions. The following example shows a
963 few normal Mercurial commands in use with applied 1005 few normal Mercurial commands in use with applied
964 patches.</para> 1006 patches.</para>
965 1007
966 &interaction.mq.id.output; 1008 &interaction.mq.id.output;
967 1009 </sect1>
968 </sect1> 1010
969 <sect1> 1011 <sect1>
970 <title>Useful things to know about</title> 1012 <title>Useful things to know about</title>
971 1013
972 <para id="x_420">There are a number of aspects of MQ usage that don't fit 1014 <para id="x_420">There are a number of aspects of MQ usage that don't fit
973 tidily into sections of their own, but that are good to know. 1015 tidily into sections of their own, but that are good to know.
989 maintain the <quote>patchiness</quote> of that changeset and 1031 maintain the <quote>patchiness</quote> of that changeset and
990 changesets below it on the patch stack. If you try to do 1032 changesets below it on the patch stack. If you try to do
991 this, it will appear to succeed, but MQ will become 1033 this, it will appear to succeed, but MQ will become
992 confused.</para> 1034 confused.</para>
993 </listitem></itemizedlist> 1035 </listitem></itemizedlist>
994 1036 </sect1>
995 </sect1> 1037
996 <sect1 id="sec:mq:repo"> 1038 <sect1 id="sec:mq:repo">
997 <title>Managing patches in a repository</title> 1039 <title>Managing patches in a repository</title>
998 1040
999 <para id="x_423">Because MQ's <filename role="special" 1041 <para id="x_423">Because MQ's <filename role="special"
1000 class="directory">.hg/patches</filename> directory resides 1042 class="directory">.hg/patches</filename> directory resides
1075 1117
1076 <programlisting>alias mq=`hg -R $(hg root)/.hg/patches'</programlisting> 1118 <programlisting>alias mq=`hg -R $(hg root)/.hg/patches'</programlisting>
1077 1119
1078 <para id="x_42d">You can then issue commands of the form <command>mq 1120 <para id="x_42d">You can then issue commands of the form <command>mq
1079 pull</command> from the main repository.</para> 1121 pull</command> from the main repository.</para>
1080 1122 </sect2>
1081 </sect2> 1123
1082 <sect2> 1124 <sect2>
1083 <title>A few things to watch out for</title> 1125 <title>A few things to watch out for</title>
1084 1126
1085 <para id="x_42e">MQ's support for working with a repository full of patches 1127 <para id="x_42e">MQ's support for working with a repository full of patches
1086 is limited in a few small respects.</para> 1128 is limited in a few small respects.</para>
1214 1256
1215 <para id="x_43c">Finally, you can apply your patches on top of the new 1257 <para id="x_43c">Finally, you can apply your patches on top of the new
1216 tree.</para> 1258 tree.</para>
1217 1259
1218 &interaction.mq.tarball.repush; 1260 &interaction.mq.tarball.repush;
1219 1261 </sect2>
1220 </sect2> 1262
1221 <sect2 id="sec:mq:combine"> 1263 <sect2 id="sec:mq:combine">
1222 <title>Combining entire patches</title> 1264 <title>Combining entire patches</title>
1223 1265
1224 <para id="x_43d">MQ provides a command, <command 1266 <para id="x_43d">MQ provides a command, <command
1225 role="hg-ext-mq">qfold</command> that lets you combine 1267 role="hg-ext-mq">qfold</command> that lets you combine
1235 <literal>bar</literal> and <literal>quux</literal> into it, 1277 <literal>bar</literal> and <literal>quux</literal> into it,
1236 you will end up with a patch that has the same effect as if 1278 you will end up with a patch that has the same effect as if
1237 you applied first <literal>foo</literal>, then 1279 you applied first <literal>foo</literal>, then
1238 <literal>bar</literal>, followed by 1280 <literal>bar</literal>, followed by
1239 <literal>quux</literal>.</para> 1281 <literal>quux</literal>.</para>
1240 1282 </sect2>
1241 </sect2> 1283
1242 <sect2> 1284 <sect2>
1243 <title>Merging part of one patch into another</title> 1285 <title>Merging part of one patch into another</title>
1244 1286
1245 <para id="x_43f">Merging <emphasis>part</emphasis> of one patch into 1287 <para id="x_43f">Merging <emphasis>part</emphasis> of one patch into
1246 another is more difficult than combining entire 1288 another is more difficult than combining entire