changeset 769:e9ef075327c1

Merge with http://bitbucket.org/dongsheng/hgbook/
author Bryan O'Sullivan <bos@serpentine.com>
date Mon, 06 Apr 2009 23:15:52 -0700
parents 2ff0a43f1152 (diff) a79fb712fe20 (current diff)
children eb11ec9eed8c
files en/ch02-tour-merge.xml en/ch03-concepts.xml en/examples/results/backout.init.out en/examples/results/backout.manual.backout.out en/examples/results/backout.manual.cat.out en/examples/results/backout.manual.clone.out en/examples/results/backout.manual.heads.out en/examples/results/backout.manual.log.out en/examples/results/backout.manual.merge.out en/examples/results/backout.manual.parents.out en/examples/results/backout.non-tip.backout.out en/examples/results/backout.non-tip.cat.out en/examples/results/backout.non-tip.clone.out en/examples/results/backout.simple.log.out en/examples/results/backout.simple.out en/examples/results/bisect.commits.out en/examples/results/bisect.help.out en/examples/results/bisect.init.out en/examples/results/bisect.search.bad-init.out en/examples/results/bisect.search.good-init.out en/examples/results/bisect.search.init.out en/examples/results/bisect.search.mytest.out en/examples/results/bisect.search.reset.out en/examples/results/bisect.search.rest.out en/examples/results/bisect.search.step1.out en/examples/results/bisect.search.step2.out en/examples/results/branch-named.branch.out en/examples/results/branch-named.branches.out en/examples/results/branch-named.commit.out en/examples/results/branch-named.create.out en/examples/results/branch-named.foo-commit.out en/examples/results/branch-named.merge.out en/examples/results/branch-named.parents.out en/examples/results/branch-named.rebranch.out en/examples/results/branch-named.status.out en/examples/results/branch-named.update-bar.out en/examples/results/branch-named.update-foo.out en/examples/results/branch-named.update-nothing.out en/examples/results/branch-named.update-switchy.out en/examples/results/branch-named.update.out en/examples/results/branch-repo.bugfix.out en/examples/results/branch-repo.clone.out en/examples/results/branch-repo.merge.out en/examples/results/branch-repo.new.out en/examples/results/branch-repo.pull.out en/examples/results/branch-repo.tag.out en/examples/results/branching.clone.out en/examples/results/branching.init.out en/examples/results/branching.main.out en/examples/results/branching.merge.out en/examples/results/branching.stable.out en/examples/results/branching.tag.out en/examples/results/branching.update.out en/examples/results/cmdref.diff-p.out en/examples/results/daily.copy.after.out en/examples/results/daily.copy.cat.out en/examples/results/daily.copy.clone.out en/examples/results/daily.copy.copy.out en/examples/results/daily.copy.dir-dest.out en/examples/results/daily.copy.dir-src-dest.out en/examples/results/daily.copy.dir-src.out en/examples/results/daily.copy.init.out en/examples/results/daily.copy.merge.out en/examples/results/daily.copy.other.out en/examples/results/daily.copy.simple.out en/examples/results/daily.copy.status-copy.out en/examples/results/daily.copy.status.out en/examples/results/daily.files.add-dir.out en/examples/results/daily.files.add.out en/examples/results/daily.files.addremove.out en/examples/results/daily.files.commit-addremove.out en/examples/results/daily.files.hidden.out en/examples/results/daily.files.missing.out en/examples/results/daily.files.recover-missing.out en/examples/results/daily.files.remove-after.out en/examples/results/daily.files.remove.out en/examples/results/daily.rename.rename.out en/examples/results/daily.rename.status-copy.out en/examples/results/daily.rename.status.out en/examples/results/daily.revert.add.out en/examples/results/daily.revert.copy.out en/examples/results/daily.revert.missing.out en/examples/results/daily.revert.modify.out en/examples/results/daily.revert.remove.out en/examples/results/daily.revert.rename-orig.out en/examples/results/daily.revert.rename.out en/examples/results/daily.revert.status.out en/examples/results/daily.revert.unmodify.out en/examples/results/extdiff.diff.out en/examples/results/extdiff.extdiff-ctx.out en/examples/results/extdiff.extdiff.out en/examples/results/filenames.dirs.out en/examples/results/filenames.files.out en/examples/results/filenames.filter.exclude.out en/examples/results/filenames.filter.include.out en/examples/results/filenames.glob.group.out en/examples/results/filenames.glob.question.out en/examples/results/filenames.glob.range.out en/examples/results/filenames.glob.star-starstar.out en/examples/results/filenames.glob.star.out en/examples/results/filenames.glob.starstar.out en/examples/results/filenames.wdir-relname.out en/examples/results/filenames.wdir-subdir.out en/examples/results/hook.msglen.go.out en/examples/results/hook.msglen.run.out en/examples/results/hook.simple.ext.out en/examples/results/hook.simple.init.out en/examples/results/hook.simple.pretxncommit.out en/examples/results/hook.ws.better.out en/examples/results/hook.ws.simple.out en/examples/results/issue29.go.out en/examples/results/mq.dodiff.diff.out en/examples/results/mq.guards.init.out en/examples/results/mq.guards.qguard.neg.out en/examples/results/mq.guards.qguard.out en/examples/results/mq.guards.qguard.pos.out en/examples/results/mq.guards.qselect.cat.out en/examples/results/mq.guards.qselect.error.out en/examples/results/mq.guards.qselect.foo.out en/examples/results/mq.guards.qselect.foobar.out en/examples/results/mq.guards.qselect.qpush.out en/examples/results/mq.guards.qselect.quux.out en/examples/results/mq.guards.series.out en/examples/results/mq.id.out.out en/examples/results/mq.id.output.out en/examples/results/mq.qinit-help.help.out en/examples/results/mq.tarball.download.out en/examples/results/mq.tarball.newsource.out en/examples/results/mq.tarball.qinit.out en/examples/results/mq.tarball.repush.out en/examples/results/mq.tools.lsdiff.out en/examples/results/mq.tools.tools.out en/examples/results/mq.tutorial.add.out en/examples/results/mq.tutorial.qinit.out en/examples/results/mq.tutorial.qnew.out en/examples/results/mq.tutorial.qnew2.out en/examples/results/mq.tutorial.qpop.out en/examples/results/mq.tutorial.qpush-a.out en/examples/results/mq.tutorial.qrefresh.out en/examples/results/mq.tutorial.qrefresh2.out en/examples/results/mq.tutorial.qseries.out en/examples/results/rename.divergent.clone.out en/examples/results/rename.divergent.merge.out en/examples/results/rename.divergent.rename.anne.out en/examples/results/rename.divergent.rename.bob.out en/examples/results/rollback.add.out en/examples/results/rollback.commit.out en/examples/results/rollback.rollback.out en/examples/results/rollback.status.out en/examples/results/rollback.tip.out en/examples/results/rollback.twice.out en/examples/results/tag.init.out en/examples/results/tag.log.out en/examples/results/tag.log.v1.0.out en/examples/results/tag.remove.out en/examples/results/tag.replace.out en/examples/results/tag.tag.out en/examples/results/tag.tags.out en/examples/results/tag.tip.out en/examples/results/template.simple.changelog.out en/examples/results/template.simple.combine.out en/examples/results/template.simple.compact.out en/examples/results/template.simple.datekeyword.out en/examples/results/template.simple.keywords.out en/examples/results/template.simple.manyfilters.out en/examples/results/template.simple.normal.out en/examples/results/template.simple.rev.out en/examples/results/template.simple.simplest.out en/examples/results/template.simple.simplesub.out en/examples/results/template.svnstyle.id.out en/examples/results/template.svnstyle.result.out en/examples/results/template.svnstyle.short.out en/examples/results/template.svnstyle.simplest.out en/examples/results/template.svnstyle.style.out en/examples/results/template.svnstyle.syntax.error.out en/examples/results/template.svnstyle.syntax.input.out en/examples/results/template.svnstyle.template.out en/examples/results/tour-merge-conflict.commit.out en/examples/results/tour-merge-conflict.cousin.out en/examples/results/tour-merge-conflict.merge.out en/examples/results/tour-merge-conflict.pull.out en/examples/results/tour-merge-conflict.son.out en/examples/results/tour-merge-conflict.wife.out en/examples/results/tour.clone-pull.out en/examples/results/tour.clone-push.out en/examples/results/tour.clone.out en/examples/results/tour.commit.out en/examples/results/tour.diff.out en/examples/results/tour.help.out en/examples/results/tour.incoming.out en/examples/results/tour.log-r.out en/examples/results/tour.log-v.out en/examples/results/tour.log-vp.out en/examples/results/tour.log.out en/examples/results/tour.log.range.out en/examples/results/tour.ls-a.out en/examples/results/tour.ls.out en/examples/results/tour.merge.cat.out en/examples/results/tour.merge.clone.out en/examples/results/tour.merge.commit.out en/examples/results/tour.merge.heads.out en/examples/results/tour.merge.merge.out en/examples/results/tour.merge.parents.out en/examples/results/tour.merge.pull.out en/examples/results/tour.merge.tip.out en/examples/results/tour.merge.update.out en/examples/results/tour.older.out en/examples/results/tour.outgoing.net.out en/examples/results/tour.outgoing.out en/examples/results/tour.parents.out en/examples/results/tour.pull.out en/examples/results/tour.push.net.out en/examples/results/tour.push.nothing.out en/examples/results/tour.push.out en/examples/results/tour.reclone.out en/examples/results/tour.sed.out en/examples/results/tour.status.out en/examples/results/tour.tip.out en/examples/results/tour.update.out en/examples/results/tour.version.out en/figs/kdiff3.png en/figs/note.png examples/hg-interdiff examples/hg-replay tools/latex-to-docbook xsl/all-ids.xsl xsl/base-html-stylesheet.xsl xsl/chunk-stylesheet.xsl xsl/dtd-profile.xsl
diffstat 5 files changed, 106 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/en/ch02-tour-merge.xml	Tue Apr 07 11:04:18 2009 +0800
+++ b/en/ch02-tour-merge.xml	Mon Apr 06 23:15:52 2009 -0700
@@ -112,24 +112,13 @@
 
       <para id="x_345">Mercurial is telling us that the <command role="hg-cmd">hg
 	  update</command> command won't do a merge; it won't update
-	the working directory when it thinks we might be wanting to do
+	the working directory when it thinks we might want to do
 	a merge, unless we force it to do so.  Instead, we use the
 	<command role="hg-cmd">hg merge</command> command to merge the
 	two heads.</para>
 
       &interaction.tour.merge.merge;
 
-      <figure id="fig:tour-merge:merge">
-	<title>Working directory and repository during merge, and
-	  following commit</title>
-	<mediaobject>
-	  <imageobject>
-	    <imagedata fileref="figs/tour-merge-merge.png"/>
-	  </imageobject>
-	  <textobject><phrase>XXX add text</phrase></textobject>
-	</mediaobject>
-      </figure>
-
       <para id="x_347">This updates the working directory so that it contains
 	changes from <emphasis>both</emphasis> heads, which is
 	reflected in both the output of <command role="hg-cmd">hg
@@ -164,13 +153,31 @@
 	parent changesets, and these become the parents of the new
 	changeset.</para>
 
+      <figure id="fig:tour-merge:merge">
+	<title>Working directory and repository during merge, and
+	  following commit</title>
+	<mediaobject>
+	  <imageobject>
+	    <imagedata fileref="figs/tour-merge-merge.png"/>
+	  </imageobject>
+	  <textobject><phrase>XXX add text</phrase></textobject>
+	</mediaobject>
+      </figure>
+
+      <para>We sometimes talk about a merge having
+	<emphasis>sides</emphasis>: the left side is the first parent
+	in the output of <command role="hg-cmd">hg parents</command>,
+	and the right side is the second.  If the working directory
+	was at e.g. revision 5 before we began a merge, that revision
+	will become the left side of the merge.</para>
     </sect2>
   </sect1>
+
   <sect1>
     <title>Merging conflicting changes</title>
 
     <para id="x_34b">Most merges are simple affairs, but sometimes you'll find
-      yourself merging changes where each modifies the same portions
+      yourself merging changes where each side modifies the same portions
       of the same files.  Unless both modifications are identical,
       this results in a <emphasis>conflict</emphasis>, where you have
       to decide how to reconcile the different changes into something
@@ -192,14 +199,13 @@
       decide what the file should look like.</para>
 
     <para id="x_34e">Mercurial doesn't have a built-in facility for handling
-      conflicts. Instead, it runs an external program called
-      <command>hgmerge</command>.  This is a shell script that is
-      bundled with Mercurial; you can change it to behave however you
-      please.  What it does by default is try to find one of several
+      conflicts. Instead, it runs an external program, usually one
+      that displays some kind of graphical conflict resolution
+      interface.  By default, Mercurial tries to find one of several
       different merging tools that are likely to be installed on your
       system.  It first tries a few fully automatic merging tools; if
       these don't succeed (because the resolution process requires
-      human guidance) or aren't present, the script tries a few
+      human guidance) or aren't present, it tries a few
       different graphical merging tools.</para>
 
     <para id="x_34f">It's also possible to get Mercurial to run another program
@@ -299,18 +305,12 @@
 
       &interaction.tour-merge-conflict.pull;
 
-      <para id="x_35d">In this example, I won't use Mercurial's normal
-	<command>hgmerge</command> program to do the merge, because it
-	would drop my nice automated example-running tool into a
-	graphical user interface.  Instead, I'll set
+      <para id="x_35d">In this example, I'll set
 	<envar>HGMERGE</envar> to tell Mercurial to use the
 	non-interactive <command>merge</command> command.  This is
-	bundled with many Unix-like systems. If you're following this
+	bundled with many Unix-like systems. (If you're following this
 	example on your computer, don't bother setting
-	<envar>HGMERGE</envar>.</para>
-
-      <para id="x_35e"><emphasis role="bold">XXX FIX THIS
-	  EXAMPLE.</emphasis></para>
+	<envar>HGMERGE</envar>.)</para>
 
       &interaction.tour-merge-conflict.merge;
 
@@ -341,7 +341,7 @@
     <para id="x_362">The process of merging changes as outlined above is
       straightforward, but requires running three commands in
       sequence.</para>
-    <programlisting>hg pull
+    <programlisting>hg pull -u
 hg merge
 hg commit -m 'Merged remote changes'</programlisting>
     <para id="x_363">In the case of the final commit, you also need to enter a
@@ -360,30 +360,33 @@
       work <quote>behind the scenes,</quote> for example adding
       capabilities to the server.</para>
 
-    <para id="x_366">The <literal role="hg-ext">fetch</literal> extension adds a
-      new command called, not surprisingly, <command role="hg-cmd">hg
-	fetch</command>.  This extension acts as a combination of
-      <command role="hg-cmd">hg pull</command>, <command
-	role="hg-cmd">hg update</command> and <command
-	role="hg-cmd">hg merge</command>.  It begins by pulling
+    <para id="x_366">The <literal role="hg-ext">fetch</literal>
+      extension adds a new command called, not surprisingly, <command
+	role="hg-cmd">hg fetch</command>.  This extension acts as a
+      combination of <command role="hg-cmd">hg pull -u</command>,
+      <command role="hg-cmd">hg merge</command> and <command
+	role="hg-cmd">hg commit</command>.  It begins by pulling
       changes from another repository into the current repository.  If
       it finds that the changes added a new head to the repository, it
-      begins a merge, then commits the result of the merge with an
-      automatically-generated commit message.  If no new heads were
-      added, it updates the working directory to the new tip
-      changeset.</para>
+      begins a merge, then (if the merge succeeded) commits the result
+      of the merge with an automatically-generated commit message.  If
+      no new heads were added, it updates the working directory to the
+      new tip changeset.</para>
 
-    <para id="x_367">Enabling the <literal role="hg-ext">fetch</literal>
-      extension is easy.  Edit your <filename
-	role="special">.hgrc</filename>, and either go to the <literal
+    <para id="x_367">Enabling the <literal
+	role="hg-ext">fetch</literal> extension is easy.  Edit the
+      <filename role="special">.hgrc</filename> file in your home
+      directory, and either go to the <literal
 	role="rc-extensions">extensions</literal> section or create an
       <literal role="rc-extensions">extensions</literal> section. Then
-      add a line that simply reads <quote><literal>fetch
-	</literal></quote>.</para>
+      add a line that simply reads
+      <quote><literal>fetch=</literal></quote>.</para>
+
     <programlisting>[extensions]
 fetch =</programlisting>
-    <para id="x_368">(Normally, on the right-hand side of the
-      <quote><literal>=</literal></quote> would appear the location of
+
+    <para id="x_368">(Normally, the right-hand side of the
+      <quote><literal>=</literal></quote> would indicate where to find
       the extension, but since the <literal
 	role="hg-ext">fetch</literal> extension is in the standard
       distribution, Mercurial knows where to search for it.)</para>
--- a/en/ch03-concepts.xml	Tue Apr 07 11:04:18 2009 +0800
+++ b/en/ch03-concepts.xml	Mon Apr 06 23:15:52 2009 -0700
@@ -4,14 +4,16 @@
   <?dbhtml filename="behind-the-scenes.html"?>
   <title>Behind the scenes</title>
 
-  <para id="x_2e8">Unlike many revision control systems, the concepts upon which
-    Mercurial is built are simple enough that it's easy to understand
-    how the software really works.  Knowing this certainly isn't
-    necessary, but I find it useful to have a <quote>mental
-      model</quote> of what's going on.</para>
+  <para id="x_2e8">Unlike many revision control systems, the concepts
+    upon which Mercurial is built are simple enough that it's easy to
+    understand how the software really works.  Knowing these details
+    certainly isn't necessary, so it is certainly safe to skip this
+    chapter.  However, I think you will get more out of the software
+    with a <quote>mental model</quote> of what's going on.</para>
 
-  <para id="x_2e9">This understanding gives me confidence that Mercurial has been
-    carefully designed to be both <emphasis>safe</emphasis> and
+  <para id="x_2e9">Being able to understand what's going on behind the
+    scenes gives me confidence that Mercurial has been carefully
+    designed to be both <emphasis>safe</emphasis> and
     <emphasis>efficient</emphasis>.  And just as importantly, if it's
     easy for me to retain a good idea of what the software is doing
     when I perform a revision control task, I'm less likely to be
@@ -436,19 +438,19 @@
 	  a new head, because your working directory isn't synced to
 	  whatever the current tip is.</para>
 
-	<para id="x_316">  I put the word <quote>error</quote> in quotes because
-	  all that you need to do to rectify this situation is
-	  <command role="hg-cmd">hg merge</command>, then <command
-	    role="hg-cmd">hg commit</command>.  In other words, this
-	  almost never has negative consequences; it just surprises
-	  people.  I'll discuss other ways to avoid this behaviour,
-	  and why Mercurial behaves in this initially surprising way,
-	  later on.</para>
+	<para id="x_316">  I put the word <quote>error</quote> in
+	  quotes because all that you need to do to rectify this
+	  situation is <command role="hg-cmd">hg merge</command>, then
+	  <command role="hg-cmd">hg commit</command>.  In other words,
+	  this almost never has negative consequences; it's just
+	  something of a surprise for newcomers.  I'll discuss other
+	  ways to avoid this behaviour, and why Mercurial behaves in
+	  this initially surprising way, later on.</para>
       </note>
 
     </sect2>
     <sect2>
-      <title>Merging heads</title>
+      <title>Merging changes</title>
 
       <para id="x_317">When you run the <command role="hg-cmd">hg
 	  merge</command> command, Mercurial leaves the first parent
@@ -518,7 +520,25 @@
 	merge immediately becomes overwhelming.</para>
 
     </sect2>
+
+    <sect2>
+      <title>Merging and renames</title>
+
+      <para>A surprising number of revision control systems pay little
+	or no attention to a file's <emphasis>name</emphasis> over
+	time.  For instance, it used to be common that if a file got
+	renamed on one side of a merge, the changes from the other
+	side would be silently dropped.</para>
+
+      <para>Mercurial records metadata when you tell it to perform a
+	rename or copy. It uses this metadata during a merge to do the
+	right thing in the case of a merge.  For instance, if I rename
+	a file, and you edit it without renaming it, when we merge our
+	work the file will be renamed and have your edits
+	applied.</para>
+    </sect2>
   </sect1>
+
   <sect1>
     <title>Other interesting design features</title>
 
@@ -575,8 +595,8 @@
 	  compression package).  This combination of algorithm and
 	  compression of the entire stream (instead of a revision at a
 	  time) substantially reduces the number of bytes to be
-	  transferred, yielding better network performance over almost
-	  all kinds of network.</para>
+	  transferred, yielding better network performance over most
+	  kinds of network.</para>
 
 	<para id="x_329">(If the connection is over <command>ssh</command>,
 	  Mercurial <emphasis>doesn't</emphasis> recompress the
--- a/en/examples/tour	Tue Apr 07 11:04:18 2009 +0800
+++ b/en/examples/tour	Mon Apr 06 23:15:52 2009 -0700
@@ -146,12 +146,17 @@
 
 hg push http://hg.serpentine.com/tutorial/hello
 
+#$ name:
+cp hello.c ../new-hello.c
+sed -i '/printf/i\\tprintf("once more, hello.\\n");' ../new-hello.c
+
 #$ name: merge.clone
 
 cd ..
 hg clone hello my-new-hello
 cd my-new-hello
-sed -i '/printf/i\\tprintf("once more, hello.\\n");' hello.c
+# The file new-hello.c is lightly edited.
+cp ../new-hello.c hello.c
 hg commit -m 'A new hello for a new day.'
 
 #$ name: merge.dummy2
--- a/en/examples/tour-merge-conflict	Tue Apr 07 11:04:18 2009 +0800
+++ b/en/examples/tour-merge-conflict	Mon Apr 06 23:15:52 2009 -0700
@@ -56,7 +56,6 @@
 #$ ignore: [<>]{7} /tmp/.*
 
 export HGMERGE=merge
-echo 'XXX this is broken and must be fixed'
 hg merge
 cat letter.txt
 
--- a/en/figs/filelog.svg	Tue Apr 07 11:04:18 2009 +0800
+++ b/en/figs/filelog.svg	Mon Apr 06 23:15:52 2009 -0700
@@ -2,7 +2,7 @@
 <!-- Created with Inkscape (http://www.inkscape.org/) -->
 <svg
    xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:cc="http://creativecommons.org/ns#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns="http://www.w3.org/2000/svg"
@@ -13,12 +13,19 @@
    height="1052.3622047"
    id="svg2"
    sodipodi:version="0.32"
-   inkscape:version="0.45.1"
+   inkscape:version="0.46"
    sodipodi:docname="filelog.svg"
    sodipodi:docbase="/home/arun/hgbook/en"
    inkscape:output_extension="org.inkscape.output.svg.inkscape">
   <defs
      id="defs4">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective57" />
     <marker
        inkscape:stockid="Arrow1Mend"
        orient="auto"
@@ -189,11 +196,12 @@
      inkscape:cx="455.8122"
      inkscape:cy="520"
      inkscape:document-units="px"
-     inkscape:current-layer="layer1"
+     inkscape:current-layer="g2940"
      inkscape:window-width="1680"
      inkscape:window-height="970"
-     inkscape:window-x="0"
-     inkscape:window-y="54" />
+     inkscape:window-x="3"
+     inkscape:window-y="46"
+     showgrid="false" />
   <metadata
      id="metadata7">
     <rdf:RDF>
@@ -245,7 +253,7 @@
              id="tspan2920"
              x="323.72824"
              y="416.7626"
-             style="font-family:Courier">.hg/store/data/README.i</tspan></text>
+             style="font-family:Courier">.hg/store/data/_r_e_a_d_m_e.i</tspan></text>
       </g>
       <g
          transform="translate(3.79093e-5,-80.1853)"