comparison en/ch04-daily.xml @ 775:29f0f79cf614

Update paragraph IDs
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 16 Apr 2009 23:46:45 -0700
parents 3b640272a966
children 1a0a78e197c3
comparison
equal deleted inserted replaced
774:e6c99cbd0abd 775:29f0f79cf614
355 cp</command> alias if you prefer). We must supply two or 355 cp</command> alias if you prefer). We must supply two or
356 more arguments, of which the last is treated as the 356 more arguments, of which the last is treated as the
357 <emphasis>destination</emphasis>, and all others are 357 <emphasis>destination</emphasis>, and all others are
358 <emphasis>sources</emphasis>.</para> 358 <emphasis>sources</emphasis>.</para>
359 359
360 <para>If you pass <command role="hg-cmd">hg copy</command> a 360 <para id="x_685">If you pass <command role="hg-cmd">hg copy</command> a
361 single file as the source, and the destination does not exist, 361 single file as the source, and the destination does not exist,
362 it creates a new file with that name.</para> 362 it creates a new file with that name.</para>
363 363
364 &interaction.daily.copy.simple; 364 &interaction.daily.copy.simple;
365 365
428 respects, the behavior of the <command role="hg-cmd">hg 428 respects, the behavior of the <command role="hg-cmd">hg
429 rename</command> command, and the options it accepts, are 429 rename</command> command, and the options it accepts, are
430 similar to the <command role="hg-cmd">hg copy</command> 430 similar to the <command role="hg-cmd">hg copy</command>
431 command.</para> 431 command.</para>
432 432
433 <para>If you're familiar with the Unix command line, you'll be 433 <para id="x_686">If you're familiar with the Unix command line, you'll be
434 glad to know that <command role="hg-cmd">hg rename</command> 434 glad to know that <command role="hg-cmd">hg rename</command>
435 command can be invoked as <command role="hg-cmd">hg 435 command can be invoked as <command role="hg-cmd">hg
436 mv</command>.</para> 436 mv</command>.</para>
437 437
438 <sect2> 438 <sect2>
548 </sect1> 548 </sect1>
549 549
550 <sect1> 550 <sect1>
551 <title>Dealing with tricky merges</title> 551 <title>Dealing with tricky merges</title>
552 552
553 <para>In a complicated or large project, it's not unusual for a 553 <para id="x_687">In a complicated or large project, it's not unusual for a
554 merge of two changesets to result in some headaches. Suppose 554 merge of two changesets to result in some headaches. Suppose
555 there's a big source file that's been extensively edited by each 555 there's a big source file that's been extensively edited by each
556 side of a merge: this is almost inevitably going to result in 556 side of a merge: this is almost inevitably going to result in
557 conflicts, some of which can take a few tries to sort 557 conflicts, some of which can take a few tries to sort
558 out.</para> 558 out.</para>
559 559
560 <para>Let's develop a simple case of this and see how to deal with 560 <para id="x_688">Let's develop a simple case of this and see how to deal with
561 it. We'll start off with a repository containing one file, and 561 it. We'll start off with a repository containing one file, and
562 clone it twice.</para> 562 clone it twice.</para>
563 563
564 &interaction.ch04-resolve.init; 564 &interaction.ch04-resolve.init;
565 565
566 <para>In one clone, we'll modify the file in one way.</para> 566 <para id="x_689">In one clone, we'll modify the file in one way.</para>
567 567
568 &interaction.ch04-resolve.left; 568 &interaction.ch04-resolve.left;
569 569
570 <para>In another, we'll modify the file differently.</para> 570 <para id="x_68a">In another, we'll modify the file differently.</para>
571 571
572 &interaction.ch04-resolve.right; 572 &interaction.ch04-resolve.right;
573 573
574 <para>Next, we'll pull each set of changes into our original 574 <para id="x_68b">Next, we'll pull each set of changes into our original
575 repo.</para> 575 repo.</para>
576 576
577 &interaction.ch04-resolve.pull; 577 &interaction.ch04-resolve.pull;
578 578
579 <para>We expect our repository to now contain two heads.</para> 579 <para id="x_68c">We expect our repository to now contain two heads.</para>
580 580
581 &interaction.ch04-resolve.heads; 581 &interaction.ch04-resolve.heads;
582 582
583 <para>Normally, if we run <command role="hg-cmd">hg 583 <para id="x_68d">Normally, if we run <command role="hg-cmd">hg
584 merge</command> at this point, it will drop us into a GUI that 584 merge</command> at this point, it will drop us into a GUI that
585 will let us manually resolve the conflicting edits to 585 will let us manually resolve the conflicting edits to
586 <filename>myfile.txt</filename>. However, to simplify things 586 <filename>myfile.txt</filename>. However, to simplify things
587 for presentation here, we'd like the merge to fail immediately 587 for presentation here, we'd like the merge to fail immediately
588 instead. Here's one way we can do so.</para> 588 instead. Here's one way we can do so.</para>
589 589
590 &interaction.ch04-resolve.export; 590 &interaction.ch04-resolve.export;
591 591
592 <para>We've told Mercurial's merge machinery to run the command 592 <para id="x_68e">We've told Mercurial's merge machinery to run the command
593 <command>false</command> (which, as we desire, fails 593 <command>false</command> (which, as we desire, fails
594 immediately) if it detects a merge that it can't sort out 594 immediately) if it detects a merge that it can't sort out
595 automatically.</para> 595 automatically.</para>
596 596
597 <para>If we now fire up <command role="hg-cmd">hg 597 <para id="x_68f">If we now fire up <command role="hg-cmd">hg
598 merge</command>, it should grind to a halt and report a 598 merge</command>, it should grind to a halt and report a
599 failure.</para> 599 failure.</para>
600 600
601 &interaction.ch04-resolve.merge; 601 &interaction.ch04-resolve.merge;
602 602
603 <para>Even if we don't notice that the merge failed, Mercurial 603 <para id="x_690">Even if we don't notice that the merge failed, Mercurial
604 will prevent us from accidentally committing the result of a 604 will prevent us from accidentally committing the result of a
605 failed merge.</para> 605 failed merge.</para>
606 606
607 &interaction.ch04-resolve.cifail; 607 &interaction.ch04-resolve.cifail;
608 608
609 <para>When <command role="hg-cmd">hg commit</command> fails in 609 <para id="x_691">When <command role="hg-cmd">hg commit</command> fails in
610 this case, it suggests that we use the unfamiliar <command 610 this case, it suggests that we use the unfamiliar <command
611 role="hg-cmd">hg resolve</command> command. As usual, 611 role="hg-cmd">hg resolve</command> command. As usual,
612 <command role="hg-cmd">hg help resolve</command> will print a 612 <command role="hg-cmd">hg help resolve</command> will print a
613 helpful synopsis.</para> 613 helpful synopsis.</para>
614 614
615 <sect2> 615 <sect2>
616 <title>File resolution states</title> 616 <title>File resolution states</title>
617 617
618 <para>When a merge occurs, most files will usually remain 618 <para id="x_692">When a merge occurs, most files will usually remain
619 unmodified. For each file where Mercurial has to do 619 unmodified. For each file where Mercurial has to do
620 something, it tracks the state of the file.</para> 620 something, it tracks the state of the file.</para>
621 621
622 <itemizedlist> 622 <itemizedlist>
623 <listitem> 623 <listitem>
624 <para>A <emphasis>resolved</emphasis> file has been 624 <para id="x_693">A <emphasis>resolved</emphasis> file has been
625 successfully merged, either automatically by Mercurial or 625 successfully merged, either automatically by Mercurial or
626 manually with human intervention.</para> 626 manually with human intervention.</para>
627 </listitem> 627 </listitem>
628 <listitem> 628 <listitem>
629 <para>An <emphasis>unresolved</emphasis> file was not merged 629 <para id="x_694">An <emphasis>unresolved</emphasis> file was not merged
630 successfully, and needs more attention.</para> 630 successfully, and needs more attention.</para>
631 </listitem> 631 </listitem>
632 </itemizedlist> 632 </itemizedlist>
633 633
634 <para>If Mercurial sees <emphasis>any</emphasis> file in the 634 <para id="x_695">If Mercurial sees <emphasis>any</emphasis> file in the
635 unresolved state after a merge, it considers the merge to have 635 unresolved state after a merge, it considers the merge to have
636 failed. Fortunately, we do not need to restart the entire 636 failed. Fortunately, we do not need to restart the entire
637 merge from scratch.</para> 637 merge from scratch.</para>
638 638
639 <para>The <option role="hg-opt-resolve">--list</option> or 639 <para id="x_696">The <option role="hg-opt-resolve">--list</option> or
640 <option role="hg-opt-resolve">-l</option> option to <command 640 <option role="hg-opt-resolve">-l</option> option to <command
641 role="hg-cmd">hg resolve</command> prints out the state of 641 role="hg-cmd">hg resolve</command> prints out the state of
642 each merged file.</para> 642 each merged file.</para>
643 643
644 &interaction.ch04-resolve.list; 644 &interaction.ch04-resolve.list;
645 645
646 <para>In the output from <command role="hg-cmd">hg 646 <para id="x_697">In the output from <command role="hg-cmd">hg
647 resolve</command>, a resolved file is marked with 647 resolve</command>, a resolved file is marked with
648 <literal>R</literal>, while an unresolved file is marked with 648 <literal>R</literal>, while an unresolved file is marked with
649 <literal>U</literal>. If any files are listed with 649 <literal>U</literal>. If any files are listed with
650 <literal>U</literal>, we know that an attempt to commit the 650 <literal>U</literal>, we know that an attempt to commit the
651 results of the merge will fail.</para> 651 results of the merge will fail.</para>
652 </sect2> 652 </sect2>
653 653
654 <sect2> 654 <sect2>
655 <title>Resolving a file merge</title> 655 <title>Resolving a file merge</title>
656 656
657 <para>We have several options to move a file from the unresolved 657 <para id="x_698">We have several options to move a file from the unresolved
658 into the resolved state. By far the most common is to rerun 658 into the resolved state. By far the most common is to rerun
659 <command role="hg-cmd">hg resolve</command>. If we pass the 659 <command role="hg-cmd">hg resolve</command>. If we pass the
660 names of individual files or directories, it will retry the 660 names of individual files or directories, it will retry the
661 merges of any unresolved files present in those locations. We 661 merges of any unresolved files present in those locations. We
662 can also pass the <option role="hg-opt-resolve">--all</option> 662 can also pass the <option role="hg-opt-resolve">--all</option>
663 or <option role="hg-opt-resolve">-a</option> option, which 663 or <option role="hg-opt-resolve">-a</option> option, which
664 will retry the merges of <emphasis>all</emphasis> unresolved 664 will retry the merges of <emphasis>all</emphasis> unresolved
665 files.</para> 665 files.</para>
666 666
667 <para>Mercurial also lets us modify the resolution state of a 667 <para id="x_699">Mercurial also lets us modify the resolution state of a
668 file directly. We can manually mark a file as resolved using 668 file directly. We can manually mark a file as resolved using
669 the <option role="hg-opt-resolve">--mark</option> option, or 669 the <option role="hg-opt-resolve">--mark</option> option, or
670 as unresolved using the <option 670 as unresolved using the <option
671 role="hg-opt-resolve">--unmark</option> option. This allows 671 role="hg-opt-resolve">--unmark</option> option. This allows
672 us to clean up a particularly messy merge by hand, and to keep 672 us to clean up a particularly messy merge by hand, and to keep