Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When you update to <code>D</code> and graft <code>F::J</code>, Mercurial runs a number of merges. It will start with this merge:</p> <pre><code>M = three_way_merge(local=D, other=F, base=E) </code></pre> <p>If we write <code>+d</code> for the delta between the states <code>C</code> and <code>D</code>, then we start with:</p> <pre><code> +d +e +f ---- C ---- D ---- E ---- F ---- </code></pre> <p>Turn the graph 90 degrees clockwise and the above three-way merge looks like this:</p> <pre><code> -e .---- D / E \ '---- F +f </code></pre> <p>That is, we pretend that we started with <code>E</code> and applied the opposite of <code>-e</code> to get to <code>D</code>. I think of as the reverse patch of <code>+e</code>. Starting in <code>E</code> we also went to state <code>F</code> with the normal delta <code>+f</code>. There's nothing strange here — we have all the states (<code>D</code>, <code>E</code>, and <code>F</code>) in the repository already. So seen like this, it's clear that we can merge <code>D</code> and <code>F</code>.</p> <p>Merging is a matter of "completing the diamond". So we find a new state <code>M</code> that is a mix of <code>D</code> and <code>F</code> and where the difference from <code>D</code> to <code>M</code> is similar to <code>+f</code> and the difference from <code>F</code> to <code>M</code> is similar to <code>-e</code>. It looks like this:</p> <pre><code> -e +f' .---- D ----. / \ E M \ / '---- F ----' +f -e' </code></pre> <p>The <code>+f</code> delta became <code>+f'</code> and the <code>-e</code> delta became <code>-e'</code>. This is just a normal three-way merge, but the effect is interesting: we've applied <code>F</code> onto <code>D</code> instead of <code>E</code>!</p> <p>After the merge, the second parent of <code>M</code> to <code>F</code> is dropped:</p> <pre><code> -e +f' .---- D ----. / \ E M \ '---- F +f </code></pre> <p>To reiterate: We have copied the "effect" of <code>F</code> onto <code>D</code>, that is, we have found a delta (<code>+f'</code>) that applied to <code>D</code> give the same effect as when <code>+f</code> was applied to <code>E</code>. We can straighten the graph a bit to get:</p> <pre><code> +f' --- D ---- M \ '---- E ---- F +e +f </code></pre> <p>The result is that <code>F</code> is grafted onto <code>D</code> using the full three-way machinery.</p> <ul> <li><p><strong>Q1:</strong> What just happened here? So....... how does that work? Why is it better?</p> <p><strong>A1:</strong> Using merges is better than patches since the merge machinery takes things like renames into account.</p></li> <li><p><strong>Q2:</strong> Is this merge just a normal 3-way merge using D, J' and M1?</p> <p><strong>A2:</strong> Yes, grafting does not alter the topology of the graph.</p></li> <li><p><strong>Q3:</strong> Has mercurial stored/used extra information about the graft operation to help it with the merge?</p> <p><strong>A3:</strong> No.</p></li> <li><p><strong>Q4:</strong> What are the potential problems with a flow like this?</p> <p><strong>A4:</strong> From a merge perspective it should work okay. It will duplicate some history which might be confusing for people.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload