Mercurial > hgbook
comparison en/ch01-tour-basic.xml @ 824:c8d662d3cb40
Improve chapter 1 further, based on comments.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun, 03 May 2009 19:23:08 -0700 |
parents | 29f0f79cf614 |
children | d7d09cda83d2 |
comparison
equal
deleted
inserted
replaced
823:9e33729cafae | 824:c8d662d3cb40 |
---|---|
49 <literal>mercurial</literal>.</para> | 49 <literal>mercurial</literal>.</para> |
50 | 50 |
51 <itemizedlist> | 51 <itemizedlist> |
52 <listitem><para id="x_4">Ubuntu and Debian:</para> | 52 <listitem><para id="x_4">Ubuntu and Debian:</para> |
53 <programlisting>apt-get install mercurial</programlisting></listitem> | 53 <programlisting>apt-get install mercurial</programlisting></listitem> |
54 <listitem><para id="x_5">Fedora and OpenSUSE:</para> | 54 <listitem><para id="x_5">Fedora:</para> |
55 <programlisting>yum install mercurial</programlisting></listitem> | 55 <programlisting>yum install mercurial</programlisting></listitem> |
56 <listitem><para>OpenSUSE:</para> | |
57 <programlisting>zypper install mercurial</programlisting></listitem> | |
56 <listitem><para id="x_6">Gentoo:</para> | 58 <listitem><para id="x_6">Gentoo:</para> |
57 <programlisting>emerge mercurial</programlisting></listitem> | 59 <programlisting>emerge mercurial</programlisting></listitem> |
58 </itemizedlist> | 60 </itemizedlist> |
59 | 61 |
60 </sect2> | 62 </sect2> |
72 <sect1> | 74 <sect1> |
73 <title>Getting started</title> | 75 <title>Getting started</title> |
74 | 76 |
75 <para id="x_e">To begin, we'll use the <command role="hg-cmd">hg | 77 <para id="x_e">To begin, we'll use the <command role="hg-cmd">hg |
76 version</command> command to find out whether Mercurial is | 78 version</command> command to find out whether Mercurial is |
77 actually installed properly. The actual version information | 79 installed properly. The actual version information that it |
78 that it prints isn't so important; it's whether it prints | 80 prints isn't so important; we simply care whether the command |
79 anything at all that we care about.</para> | 81 runs and prints anything at all.</para> |
80 | 82 |
81 &interaction.tour.version; | 83 &interaction.tour.version; |
82 | 84 |
83 <sect2> | 85 <sect2> |
84 <title>Built-in help</title> | 86 <title>Built-in help</title> |
211 <listitem><para id="x_1e"><literal>changeset</literal>: This | 213 <listitem><para id="x_1e"><literal>changeset</literal>: This |
212 field has the format of a number, followed by a colon, | 214 field has the format of a number, followed by a colon, |
213 followed by a hexadecimal (or <emphasis>hex</emphasis>) | 215 followed by a hexadecimal (or <emphasis>hex</emphasis>) |
214 string. These are <emphasis>identifiers</emphasis> for the | 216 string. These are <emphasis>identifiers</emphasis> for the |
215 changeset. The hex string is a unique identifier: the same | 217 changeset. The hex string is a unique identifier: the same |
216 hex string will always refer to the same changeset. The | 218 hex string will always refer to the same changeset in every |
219 copy of this repository. The | |
217 number is shorter and easier to type than the hex string, | 220 number is shorter and easier to type than the hex string, |
218 but it isn't unique: the same number in two different clones | 221 but it isn't unique: the same number in two different clones |
219 of a repository may identify different changesets. Why | 222 of a repository may identify different changesets.</para> |
220 provide the number at all, then? For local | |
221 convenience.</para> | |
222 </listitem> | 223 </listitem> |
223 <listitem><para id="x_1f"><literal>user</literal>: The identity of the | 224 <listitem><para id="x_1f"><literal>user</literal>: The identity of the |
224 person who created the changeset. This is a free-form | 225 person who created the changeset. This is a free-form |
225 field, but it most often contains a person's name and email | 226 field, but it most often contains a person's name and email |
226 address.</para></listitem> | 227 address.</para></listitem> |
415 role="hg-cmd">hg log -v -p -r 2</command> can be written | 416 role="hg-cmd">hg log -v -p -r 2</command> can be written |
416 as <command role="hg-cmd">hg log -vpr2</command>.</para> | 417 as <command role="hg-cmd">hg log -vpr2</command>.</para> |
417 </listitem> | 418 </listitem> |
418 </itemizedlist> | 419 </itemizedlist> |
419 | 420 |
420 <para id="x_36">In the examples throughout this book, I use short options | 421 <para id="x_36">In the examples throughout this book, I usually |
421 instead of long. This just reflects my own preference, so don't | 422 use short options instead of long. This simply reflects my own |
422 read anything significant into it.</para> | 423 preference, so don't read anything significant into it.</para> |
423 | 424 |
424 <para id="x_37">Most commands that print output of some kind will print more | 425 <para id="x_37">Most commands that print output of some kind will print more |
425 output when passed a <option role="hg-opt-global">-v</option> | 426 output when passed a <option role="hg-opt-global">-v</option> |
426 (or <option role="hg-opt-global">--verbose</option>) option, and | 427 (or <option role="hg-opt-global">--verbose</option>) option, and |
427 less when passed <option role="hg-opt-global">-q</option> (or | 428 less when passed <option role="hg-opt-global">-q</option> (or |
588 below for details.</para> | 589 below for details.</para> |
589 <sect3 id="sec:tour-basic:username"> | 590 <sect3 id="sec:tour-basic:username"> |
590 <title>Creating a Mercurial configuration file</title> | 591 <title>Creating a Mercurial configuration file</title> |
591 | 592 |
592 <para id="x_4a">To set a user name, use your favorite editor | 593 <para id="x_4a">To set a user name, use your favorite editor |
593 to create a file called <filename | 594 to create a file called <filename |
594 role="special">.hgrc</filename> in your home directory. | 595 role="special">.hgrc</filename> in your home directory. |
595 Mercurial will use this file to look up your personalised | 596 Mercurial will use this file to look up your personalised |
596 configuration settings. The initial contents of your | 597 configuration settings. The initial contents of your |
597 <filename role="special">.hgrc</filename> should look like | 598 <filename role="special">.hgrc</filename> should look like |
598 this.</para> | 599 this.</para> |
599 | 600 |
600 <remark>Figure out what the appropriate directory is on | 601 <tip> |
601 Windows.</remark> | 602 <title><quote>Home directory</quote> on Windows</title> |
603 | |
604 <para>When we refer to your home directory, on an English | |
605 language installation of Windows this will usually be a | |
606 folder named after your user name in | |
607 <filename>C:\Documents and Settings</filename>. You can | |
608 find out the exact name of your home directory by opening | |
609 a command prompt window and running the following | |
610 command.</para> | |
611 | |
612 <screen><prompt>C:\></prompt> <userinput>echo %UserProfile%</userinput></screen> | |
613 </tip> | |
602 | 614 |
603 <programlisting># This is a Mercurial configuration file. | 615 <programlisting># This is a Mercurial configuration file. |
604 [ui] | 616 [ui] |
605 username = Firstname Lastname <email.address@domain.net></programlisting> | 617 username = Firstname Lastname <email.address@example.net></programlisting> |
606 | 618 |
607 <para id="x_4b">The <quote><literal>[ui]</literal></quote> line begins a | 619 <para id="x_4b">The <quote><literal>[ui]</literal></quote> line begins a |
608 <emphasis>section</emphasis> of the config file, so you can | 620 <emphasis>section</emphasis> of the config file, so you can |
609 read the <quote><literal>username = ...</literal></quote> | 621 read the <quote><literal>username = ...</literal></quote> |
610 line as meaning <quote>set the value of the | 622 line as meaning <quote>set the value of the |
618 | 630 |
619 <sect3> | 631 <sect3> |
620 <title>Choosing a user name</title> | 632 <title>Choosing a user name</title> |
621 | 633 |
622 <para id="x_4c">You can use any text you like as the value of | 634 <para id="x_4c">You can use any text you like as the value of |
623 the <literal>username</literal> config item, since this | 635 the <literal>username</literal> config item, since this |
624 information is for reading by other people, but will not be | 636 information is for reading by other people, but will not be |
625 interpreted by Mercurial. The convention that most | 637 interpreted by Mercurial. The convention that most people |
626 people follow is to use their name and email address, as | 638 follow is to use their name and email address, as in the |
627 in the example above.</para> | 639 example above.</para> |
628 <note> | 640 <note> |
629 <para id="x_4d">Mercurial's built-in web server obfuscates | 641 <para id="x_4d">Mercurial's built-in web server obfuscates |
630 email addresses, to make it more difficult for the email | 642 email addresses, to make it more difficult for the email |
631 harvesting tools that spammers use. This reduces the | 643 harvesting tools that spammers use. This reduces the |
632 likelihood that you'll start receiving more junk email | 644 likelihood that you'll start receiving more junk email if |
633 if you publish a Mercurial repository on the | 645 you publish a Mercurial repository on the |
634 web.</para></note> | 646 web.</para></note> |
635 | |
636 </sect3> | 647 </sect3> |
637 </sect2> | 648 </sect2> |
638 <sect2> | 649 <sect2> |
639 <title>Writing a commit message</title> | 650 <title>Writing a commit message</title> |
640 | 651 |
641 <para id="x_4e">When we commit a change, Mercurial drops us into | 652 <para id="x_4e">When we commit a change, Mercurial drops us into |
642 a text editor, to enter a message that will describe the | 653 a text editor, to enter a message that will describe the |
643 modifications we've made in this changeset. This is called | 654 modifications we've made in this changeset. This is called |
644 the <emphasis>commit message</emphasis>. It will be a | 655 the <emphasis>commit message</emphasis>. It will be a record |
645 record for readers of what we did and why, and it will be | 656 for readers of what we did and why, and it will be printed by |
646 printed by <command role="hg-cmd">hg log</command> after | 657 <command role="hg-cmd">hg log</command> after we've finished |
647 we've finished committing.</para> | 658 committing.</para> |
648 | 659 |
649 &interaction.tour.commit; | 660 &interaction.tour.commit; |
650 | 661 |
651 <para id="x_4f">The editor that the <command role="hg-cmd">hg | 662 <para id="x_4f">The editor that the <command role="hg-cmd">hg |
652 commit</command> command drops us into will contain an | 663 commit</command> command drops us into will contain an empty |
653 empty line or two, followed by a number of lines starting with | 664 line or two, followed by a number of lines starting with |
654 <quote><literal>HG:</literal></quote>.</para> | 665 <quote><literal>HG:</literal></quote>.</para> |
655 | 666 |
656 <programlisting> | 667 <programlisting> |
657 This is where I type my commit comment. | 668 This is where I type my commit comment. |
658 | 669 |
659 HG: Enter commit message. Lines beginning with 'HG:' are removed. | 670 HG: Enter commit message. Lines beginning with 'HG:' are removed. |
661 HG: user: Bryan O'Sullivan <bos@serpentine.com> | 672 HG: user: Bryan O'Sullivan <bos@serpentine.com> |
662 HG: branch 'default' | 673 HG: branch 'default' |
663 HG: changed hello.c</programlisting> | 674 HG: changed hello.c</programlisting> |
664 | 675 |
665 <para id="x_50">Mercurial ignores the lines that start with | 676 <para id="x_50">Mercurial ignores the lines that start with |
666 <quote><literal>HG:</literal></quote>; it uses them only to | 677 <quote><literal>HG:</literal></quote>; it uses them only to |
667 tell us which files it's recording changes to. Modifying or | 678 tell us which files it's recording changes to. Modifying or |
668 deleting these lines has no effect.</para> | 679 deleting these lines has no effect.</para> |
669 </sect2> | 680 </sect2> |
670 <sect2> | 681 <sect2> |
671 <title>Writing a good commit message</title> | 682 <title>Writing a good commit message</title> |
672 | 683 |
673 <para id="x_51">Since <command role="hg-cmd">hg log</command> | 684 <para id="x_51">Since <command role="hg-cmd">hg log</command> |
674 only prints the first line of a commit message by default, | 685 only prints the first line of a commit message by default, |
675 it's best to write a commit message whose first line stands | 686 it's best to write a commit message whose first line stands |
676 alone. Here's a real example of a commit message that | 687 alone. Here's a real example of a commit message that |
677 <emphasis>doesn't</emphasis> follow this guideline, and | 688 <emphasis>doesn't</emphasis> follow this guideline, and hence |
678 hence has a summary that is not | 689 has a summary that is not readable.</para> |
679 readable.</para> | |
680 | 690 |
681 <programlisting> | 691 <programlisting> |
682 changeset: 73:584af0e231be | 692 changeset: 73:584af0e231be |
683 user: Censored Person <censored.person@example.org> | 693 user: Censored Person <censored.person@example.org> |
684 date: Tue Sep 26 21:37:07 2006 -0700 | 694 date: Tue Sep 26 21:37:07 2006 -0700 |
685 summary: include buildmeister/commondefs. Add exports.</programlisting> | 695 summary: include buildmeister/commondefs. Add exports.</programlisting> |
686 | 696 |
687 <para id="x_52">As far as the remainder of the contents of the | 697 <para id="x_52">As far as the remainder of the contents of the |
688 commit message are concerned, there are no hard-and-fast | 698 commit message are concerned, there are no hard-and-fast |
689 rules. Mercurial itself doesn't interpret or care about the | 699 rules. Mercurial itself doesn't interpret or care about the |
690 contents of the commit message, though your project may have | 700 contents of the commit message, though your project may have |
691 policies that dictate a certain kind of | 701 policies that dictate a certain kind of formatting.</para> |
692 formatting.</para> | |
693 <para id="x_53">My personal preference is for short, but | 702 <para id="x_53">My personal preference is for short, but |
694 informative, commit messages that tell me something that I | 703 informative, commit messages that tell me something that I |
695 can't figure out with a quick glance at the output of | 704 can't figure out with a quick glance at the output of <command |
696 <command role="hg-cmd">hg log | 705 role="hg-cmd">hg log --patch</command>.</para> |
697 --patch</command>.</para> | 706 <para id="x_55">If we run the <command role="hg-cmd">hg |
698 </sect2> | 707 commit</command> command without any arguments, it records |
708 all of the changes we've made, as reported by <command | |
709 role="hg-cmd">hg status</command> and <command | |
710 role="hg-cmd">hg diff</command>.</para> | |
711 | |
712 <note> | |
713 <title>A surprise for Subversion users</title> | |
714 | |
715 <para>Like other Mercurial commands, if we don't supply | |
716 explicit names to commit to the <command role="hg-cmd">hg | |
717 commit</command>, it will operate across a repository's | |
718 entire working directory. Be wary of this if you're coming | |
719 from the Subversion or CVS world, since you might expect it | |
720 to operate only on the current directory that you happen to | |
721 be visiting and its subdirectories.</para> | |
722 </note> | |
723 </sect2> | |
724 | |
699 <sect2> | 725 <sect2> |
700 <title>Aborting a commit</title> | 726 <title>Aborting a commit</title> |
701 | 727 |
702 <para id="x_54">If you decide that you don't want to commit | 728 <para id="x_54">If you decide that you don't want to commit |
703 while in the middle of editing a commit message, simply exit | 729 while in the middle of editing a commit message, simply exit |
704 from your editor without saving the file that it's editing. | 730 from your editor without saving the file that it's editing. |
705 This will cause nothing to happen to either the repository | 731 This will cause nothing to happen to either the repository or |
706 or the working directory.</para> | 732 the working directory.</para> |
707 <para id="x_55">If we run the <command role="hg-cmd">hg | 733 </sect2> |
708 commit</command> command without any arguments, it records | 734 |
709 all of the changes we've made, as reported by <command | |
710 role="hg-cmd">hg status</command> and <command | |
711 role="hg-cmd">hg diff</command>.</para> | |
712 </sect2> | |
713 <sect2> | 735 <sect2> |
714 <title>Admiring our new handiwork</title> | 736 <title>Admiring our new handiwork</title> |
715 | 737 |
716 <para id="x_56">Once we've finished the commit, we can use the | 738 <para id="x_56">Once we've finished the commit, we can use the |
717 <command role="hg-cmd">hg tip</command> command to display | 739 <command role="hg-cmd">hg tip</command> command to display the |
718 the changeset we just created. This command produces output | 740 changeset we just created. This command produces output that |
719 that is identical to <command role="hg-cmd">hg | 741 is identical to <command role="hg-cmd">hg log</command>, but |
720 log</command>, but it only displays the newest revision in | 742 it only displays the newest revision in the repository.</para> |
721 the repository.</para> | |
722 | 743 |
723 &interaction.tour.tip; | 744 &interaction.tour.tip; |
724 | 745 |
725 <para id="x_57">We refer to the newest revision in the | 746 <para id="x_57">We refer to the newest revision in the |
726 repository as the <emphasis>tip revision</emphasis>, or simply | 747 repository as the <emphasis>tip revision</emphasis>, or simply |
739 | 760 |
740 <sect1> | 761 <sect1> |
741 <title>Sharing changes</title> | 762 <title>Sharing changes</title> |
742 | 763 |
743 <para id="x_58">We mentioned earlier that repositories in | 764 <para id="x_58">We mentioned earlier that repositories in |
744 Mercurial are self-contained. This means that the changeset | 765 Mercurial are self-contained. This means that the changeset we |
745 we just created exists only in our <filename | 766 just created exists only in our <filename |
746 class="directory">my-hello</filename> repository. Let's | 767 class="directory">my-hello</filename> repository. Let's look |
747 look at a few ways that we can propagate this change into | 768 at a few ways that we can propagate this change into other |
748 other repositories.</para> | 769 repositories.</para> |
749 | 770 |
750 <sect2 id="sec:tour:pull"> | 771 <sect2 id="sec:tour:pull"> |
751 <title>Pulling changes from another repository</title> | 772 <title>Pulling changes from another repository</title> |
773 | |
752 <para id="x_59">To get started, let's clone our original | 774 <para id="x_59">To get started, let's clone our original |
753 <filename class="directory">hello</filename> repository, | 775 <filename class="directory">hello</filename> repository, which |
754 which does not contain the change we just committed. We'll | 776 does not contain the change we just committed. We'll call our |
755 call our temporary repository <filename | 777 temporary repository <filename |
756 class="directory">hello-pull</filename>.</para> | 778 class="directory">hello-pull</filename>.</para> |
757 | 779 |
758 &interaction.tour.clone-pull; | 780 &interaction.tour.clone-pull; |
759 | 781 |
760 <para id="x_5a">We'll use the <command role="hg-cmd">hg | 782 <para id="x_5a">We'll use the <command role="hg-cmd">hg |
761 pull</command> command to bring changes from <filename | 783 pull</command> command to bring changes from <filename |
762 class="directory">my-hello</filename> into <filename | 784 class="directory">my-hello</filename> into <filename |
763 class="directory">hello-pull</filename>. However, blindly | 785 class="directory">hello-pull</filename>. However, blindly |
764 pulling unknown changes into a repository is a somewhat | 786 pulling unknown changes into a repository is a somewhat scary |
765 scary prospect. Mercurial provides the <command | 787 prospect. Mercurial provides the <command role="hg-cmd">hg |
766 role="hg-cmd">hg incoming</command> command to tell us | 788 incoming</command> command to tell us what changes the |
767 what changes the <command role="hg-cmd">hg pull</command> | 789 <command role="hg-cmd">hg pull</command> command |
768 command <emphasis>would</emphasis> pull into the repository, | 790 <emphasis>would</emphasis> pull into the repository, without |
769 without actually pulling the changes in.</para> | 791 actually pulling the changes in.</para> |
770 | 792 |
771 &interaction.tour.incoming; | 793 &interaction.tour.incoming; |
772 | 794 |
773 <para id="x_5b">Suppose you're pulling changes from a repository | |
774 on the network somewhere. While you are looking at the <command | |
775 role="hg-cmd">hg incoming</command> output, and before you | |
776 pull those changes, someone might have committed something in | |
777 the remote repository. This means that it's possible to pull | |
778 more changes than you saw when using <command | |
779 role="hg-cmd">hg incoming</command>.</para> | |
780 | |
781 <para id="x_5c">Bringing changes into a repository is a simple | 795 <para id="x_5c">Bringing changes into a repository is a simple |
782 matter of running the <command role="hg-cmd">hg | 796 matter of running the <command role="hg-cmd">hg pull</command> |
783 pull</command> command, and telling it which repository to | 797 command, and optionally telling it which repository to pull from.</para> |
784 pull from.</para> | |
785 | 798 |
786 &interaction.tour.pull; | 799 &interaction.tour.pull; |
787 | 800 |
788 <para id="x_5d">As you can see | 801 <para id="x_5d">As you can see from the before-and-after output |
789 from the before-and-after output of <command | 802 of <command role="hg-cmd">hg tip</command>, we have |
790 role="hg-cmd">hg tip</command>, we have successfully | 803 successfully pulled changes into our repository. However, |
791 pulled changes into our repository. There remains one step | 804 Mercurial separates pulling changes in from updating the |
792 before we can see these changes in the working | 805 working directory. There remains one step before we will see |
793 directory.</para> | 806 the changes that we just pulled appear in the working |
794 </sect2> | 807 directory.</para> |
808 | |
809 <tip> | |
810 <title>Pulling specific changes</title> | |
811 | |
812 <para id="x_5b">It is possible that due to the delay between | |
813 running <command role="hg-cmd">hg incoming</command> and | |
814 <command role="hg-cmd">hg pull</command>, you may not see | |
815 all changesets that will be brought from the other | |
816 repository. Suppose you're pulling changes from a repository | |
817 on the network somewhere. While you are looking at the | |
818 <command role="hg-cmd">hg incoming</command> output, and | |
819 before you pull those changes, someone might have committed | |
820 something in the remote repository. This means that it's | |
821 possible to pull more changes than you saw when using | |
822 <command role="hg-cmd">hg incoming</command>.</para> | |
823 | |
824 <para>If you only want to pull precisely the changes that were | |
825 listed by <command role="hg-cmd">hg incoming</command>, or | |
826 you have some other reason to pull a subset of changes, | |
827 simply identify the change that you want to pull by its | |
828 changeset ID, e.g. <command>hg pull | |
829 -r7e95bb</command>.</para> | |
830 </tip> | |
831 </sect2> | |
832 | |
795 <sect2> | 833 <sect2> |
796 <title>Updating the working directory</title> | 834 <title>Updating the working directory</title> |
797 | 835 |
798 <para id="x_5e">We have so far glossed over the relationship | 836 <para id="x_5e">We have so far glossed over the relationship |
799 between a repository and its working directory. The <command | 837 between a repository and its working directory. The <command |
805 the working directory. Instead, we use the <command | 843 the working directory. Instead, we use the <command |
806 role="hg-cmd">hg update</command> command to do this.</para> | 844 role="hg-cmd">hg update</command> command to do this.</para> |
807 | 845 |
808 &interaction.tour.update; | 846 &interaction.tour.update; |
809 | 847 |
810 <para id="x_5f">It might seem a bit strange that <command role="hg-cmd">hg | 848 <para id="x_5f">It might seem a bit strange that <command |
811 pull</command> doesn't update the working directory | 849 role="hg-cmd">hg pull</command> doesn't update the working |
812 automatically. There's actually a good reason for this: you | 850 directory automatically. There's actually a good reason for |
813 can use <command role="hg-cmd">hg update</command> to update | 851 this: you can use <command role="hg-cmd">hg update</command> |
814 the working directory to the state it was in at <emphasis>any | 852 to update the working directory to the state it was in at |
815 revision</emphasis> in the history of the repository. If | 853 <emphasis>any revision</emphasis> in the history of the |
816 you had the working directory updated to an old revision&emdash;to | 854 repository. If you had the working directory updated to an |
817 hunt down the origin of a bug, say&emdash;and ran a <command | 855 old revision&emdash;to hunt down the origin of a bug, |
818 role="hg-cmd">hg pull</command> which automatically updated | 856 say&emdash;and ran a <command role="hg-cmd">hg pull</command> |
819 the working directory to a new revision, you might not be | 857 which automatically updated the working directory to a new |
820 terribly happy.</para> | 858 revision, you might not be terribly happy.</para> |
821 <para id="x_60">However, since pull-then-update is such a common thing to | 859 |
822 do, Mercurial lets you combine the two by passing the <option | 860 <para id="x_60">Since pull-then-update is such a common sequence |
823 role="hg-opt-pull">-u</option> option to <command | 861 of operations, Mercurial lets you combine the two by passing |
862 the <option role="hg-opt-pull">-u</option> option to <command | |
824 role="hg-cmd">hg pull</command>.</para> | 863 role="hg-cmd">hg pull</command>.</para> |
825 | 864 |
826 <para id="x_61">If you look back at the output of <command | 865 <para id="x_61">If you look back at the output of <command |
827 role="hg-cmd">hg pull</command> in <xref | 866 role="hg-cmd">hg pull</command> in <xref |
828 linkend="sec:tour:pull"/> when we ran it without <option | 867 linkend="sec:tour:pull"/> when we ran it without <option |
830 a helpful reminder that we'd have to take an explicit step to | 869 a helpful reminder that we'd have to take an explicit step to |
831 update the working directory:</para> | 870 update the working directory:</para> |
832 | 871 |
833 <!-- &interaction.xxx.fixme; --> | 872 <!-- &interaction.xxx.fixme; --> |
834 | 873 |
835 <para id="x_62">To find out what revision the working directory is at, use | 874 <para id="x_62">To find out what revision the working directory |
836 the <command role="hg-cmd">hg parents</command> | 875 is at, use the <command role="hg-cmd">hg parents</command> |
837 command.</para> | 876 command.</para> |
838 | 877 |
839 &interaction.tour.parents; | 878 &interaction.tour.parents; |
840 | 879 |
841 <para id="x_63">If you look back at <xref | 880 <para id="x_63">If you look back at <xref |
842 linkend="fig:tour-basic:history"/>, | 881 linkend="fig:tour-basic:history"/>, you'll see arrows |
843 you'll see arrows connecting each changeset. The node that | 882 connecting each changeset. The node that the arrow leads |
844 the arrow leads <emphasis>from</emphasis> in each case is a | 883 <emphasis>from</emphasis> in each case is a parent, and the |
845 parent, and the node that the arrow leads | 884 node that the arrow leads <emphasis>to</emphasis> is its |
846 <emphasis>to</emphasis> is its child. The working directory | 885 child. The working directory has a parent in just the same |
847 has a parent in just the same way; this is the changeset that | 886 way; this is the changeset that the working directory |
848 the working directory currently contains.</para> | 887 currently contains.</para> |
849 | 888 |
850 <para id="x_64">To update the working directory to a particular revision, | 889 <para id="x_64">To update the working directory to a particular |
851 | 890 revision, give a revision number or changeset ID to the |
852 give a revision number or changeset ID to the <command | 891 <command role="hg-cmd">hg update</command> command.</para> |
853 role="hg-cmd">hg update</command> command.</para> | |
854 | 892 |
855 &interaction.tour.older; | 893 &interaction.tour.older; |
856 | 894 |
857 <para id="x_65">If you omit an explicit revision, <command | 895 <para id="x_65">If you omit an explicit revision, <command |
858 role="hg-cmd">hg update</command> will update to the tip | 896 role="hg-cmd">hg update</command> will update to the tip |
863 | 901 |
864 <sect2> | 902 <sect2> |
865 <title>Pushing changes to another repository</title> | 903 <title>Pushing changes to another repository</title> |
866 | 904 |
867 <para id="x_66">Mercurial lets us push changes to another | 905 <para id="x_66">Mercurial lets us push changes to another |
868 repository, from the repository we're currently visiting. | 906 repository, from the repository we're currently visiting. As |
869 As with the example of <command role="hg-cmd">hg | 907 with the example of <command role="hg-cmd">hg pull</command> |
870 pull</command> above, we'll create a temporary repository | 908 above, we'll create a temporary repository to push our changes |
871 to push our changes into.</para> | 909 into.</para> |
872 | 910 |
873 &interaction.tour.clone-push; | 911 &interaction.tour.clone-push; |
874 | 912 |
875 <para id="x_67">The <command role="hg-cmd">hg outgoing</command> command | 913 <para id="x_67">The <command role="hg-cmd">hg outgoing</command> |
876 tells us what changes would be pushed into another | 914 command tells us what changes would be pushed into another |
877 repository.</para> | 915 repository.</para> |
878 | 916 |
879 &interaction.tour.outgoing; | 917 &interaction.tour.outgoing; |
880 | 918 |
881 <para id="x_68">And the | 919 <para id="x_68">And the <command role="hg-cmd">hg push</command> |
882 <command role="hg-cmd">hg push</command> command does the | 920 command does the actual push.</para> |
883 actual push.</para> | |
884 | 921 |
885 &interaction.tour.push; | 922 &interaction.tour.push; |
886 | 923 |
887 <para id="x_69">As with <command role="hg-cmd">hg | 924 <para id="x_69">As with <command role="hg-cmd">hg |
888 pull</command>, the <command role="hg-cmd">hg push</command> | 925 pull</command>, the <command role="hg-cmd">hg push</command> |
900 and the receiving repository already has those changes? | 937 and the receiving repository already has those changes? |
901 Nothing too exciting.</para> | 938 Nothing too exciting.</para> |
902 | 939 |
903 &interaction.tour.push.nothing; | 940 &interaction.tour.push.nothing; |
904 </sect2> | 941 </sect2> |
942 | |
943 <sect2> | |
944 <title>Default locations</title> | |
945 | |
946 <para>When we clone a repository, Mercurial records the location | |
947 of the repository we cloned in the | |
948 <filename>.hg/hgrc</filename> file of the new repository. If | |
949 we don't supply a location to <command>hg pull</command> from | |
950 or <command>hg push</command> to, those commands will use this | |
951 location as a default. The <command>hg incoming</command> | |
952 and <command>hg outgoing</command> commands do so too.</para> | |
953 | |
954 <para>If you open a repository's <filename>.hg/hgrc</filename> | |
955 file in a text editor, you will see contents like the | |
956 following.</para> | |
957 | |
958 <programlisting>[paths] | |
959 default = http://www.selenic.com/repo/hg</programlisting> | |
960 | |
961 <para>It is possible&emdash;and often useful&emdash;to have the | |
962 default location for <command>hg push</command> and | |
963 <command>hg outgoing</command> be different from those for | |
964 <command>hg pull</command> and <command>hg incoming</command>. | |
965 We can do this by adding a <literal>default-push</literal> | |
966 entry to the <literal>[paths]</literal> section of the | |
967 <filename>.hg/hgrc</filename> file, as follows.</para> | |
968 | |
969 <programlisting>[paths] | |
970 default = http://www.selenic.com/repo/hg | |
971 default-push = http://hg.example.com/hg</programlisting> | |
972 </sect2> | |
973 | |
905 <sect2> | 974 <sect2> |
906 <title>Sharing changes over a network</title> | 975 <title>Sharing changes over a network</title> |
907 | 976 |
908 <para id="x_6b">The commands we have covered in the previous few | 977 <para id="x_6b">The commands we have covered in the previous few |
909 sections are not limited to working with local repositories. | 978 sections are not limited to working with local repositories. |
911 connection; simply pass in a URL instead of a local | 980 connection; simply pass in a URL instead of a local |
912 path.</para> | 981 path.</para> |
913 | 982 |
914 &interaction.tour.outgoing.net; | 983 &interaction.tour.outgoing.net; |
915 | 984 |
916 <para id="x_6c">In this example, we | 985 <para id="x_6c">In this example, we can see what changes we |
917 can see what changes we could push to the remote repository, | 986 could push to the remote repository, but the repository is |
918 but the repository is understandably not set up to let | 987 understandably not set up to let anonymous users push to |
919 anonymous users push to it.</para> | 988 it.</para> |
920 | 989 |
921 &interaction.tour.push.net; | 990 &interaction.tour.push.net; |
922 </sect2> | 991 </sect2> |
923 </sect1> | 992 </sect1> |
924 </chapter> | 993 </chapter> |