title: Consequences of using graft in Mercurial
body: <p>There've been several questions recently about skipping changes when maintaining release branches in Mercurial. For example:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/9532823/mercurial-branch-specific-changes-keep-coming-back-after-dummy-merge">Mercurial: Branch specific changes keep coming back after dummy merge</a></li>
  <li><a href="https://stackoverflow.com/questions/9500399/why-are-mercurial-backouts-in-one-branch-affecting-other-branches">Why are Mercurial backouts in one branch affecting other branches?</a></li>
  </ul>
  
  <p>Since it was introduced in 2.0, I've wondered about using <code>graft</code> to avoid this problem. Given a revision tree like this:</p>
  
  <pre><code>A---B---C---D---E---F---G---H---I---J
  </code></pre>
  
  <p>Suppose we need to create a release branch that skips the Evil change <code>E</code>.</p>
  
  <pre><code>hg update -r D
  hg graft "F::J"
  </code></pre>
  
  <p>giving us:</p>
  
  <pre><code>A---B---C---D---E---F---G---H---I---J
               \
                --F'--G'--H'--I'--J'
  </code></pre>
  
  <ul>
  <li>Q1: What just happened here? I can understand that <code>transplant</code> would have generated patches out of <code>F::J</code>, and then applied them onto <code>D</code>, but <code>graft</code> is said to use the 3-way merge rather than patches. So....... how does that work? Why is it better?</li>
  </ul>
  
  <p>Lets say I now fix <code>E</code>, and merge that into my release branch.</p>
  
  <pre><code>                  --E2-----------------
                   /                     \
  A---B---C---D---E---F---G---H---I---J---M1
               \                            \
                --F'--G'--H'--I'--J'---------M2--
  </code></pre>
  
  <p>M1 is a straight merge; nothing special there.
  M2 is merging branches which have "the same" (or at least equivalent) changes on.</p>
  
  <ul>
  <li>Q2: Is this merge just a normal 3-way merge using <code>D</code>, <code>J'</code> and <code>M1</code>?</li>
  <li>Q3: Has mercurial stored/used extra information about the graft operation to help it with the merge?</li>
  </ul>
  
  <p>And finally...</p>
  
  <ul>
  <li>Q4: What are the potential problems with a flow like this?</li>
  </ul>