
\section{\label{sec:named_patch_motivation}Named Patch Motivation}

When you record a ``patch'' in camp, you create a \emph{mega patch}
composed of many catches (which, at the point at which you record it,
are all just patches). You need to give a name to this mega patch, but
to avoid confusion with the names given to patches and catches we'll say
that mega patches have a \emph{title}.

A non-obvious result is that, if we don't give names to patches, then
dependencies of mega patches \emph{cannot} behave as one would expect
when duplicate changes are involved. Furthermore, one can construct
situations where the simple, natural merge algorithm fails.

The detail of what is inside a conflictor is irrelevant, as this is a
universal property, so for this section we will simply write
$\simpleconflictor{\seq{p}}{q}$ for a conflictor representing $q$ that
has effect $\seq{p}$.

To start off with, we record a mega patch $p$ in one repo, and $q$ in
another repo. $p$ and $q$ contain the same single patch. We also record
a mega patch $r$ that depends on $p$, {\ie} $p$ and $r$ do not commute.
So we have three repos: $p$, $q$, $pr$.

Next merge $p$ and $q$, resulting in $p \simpleconflictor{p^}{q}$,
and then merge this with $pr$, resulting in
$p \simpleconflictor{p^}{q} \simpleconflictor{}{r}$.

Now, this must commute to $pr\simpleconflictor{r^p^}{q}$,
and we can then unpull the $q$ conflictor to get $pr$.

But going back to
$p \simpleconflictor{p^}{q} \simpleconflictor{}{r}$,
this must also commute to
$q \simpleconflictor{q^}{p} \simpleconflictor{}{r}$.
But if the patches in $p$ and $q$ are not named, and are identical to
each other,
then $\simpleconflictor{p^}{q}$ and $\simpleconflictor{q^}{p}$
look identical to the $r$ conflictor! So this must
commute to
$qr\simpleconflictor{r^q^}{p}$
and again we can unpull to get $qr$. But in the land of named patches,
$r$ is supposed to depend on $p$!

This is disturbing enough, but now suppose that we create these $pr$ and
$qr$ repos and then try to merge them. We first want to get all the
mega patches that are common to both repos out of the way. We look at the
titles of the mega patches in each repo and conclude that $r$ is common
to both. We thus want to commute the repos so that they are $r' p'$ and
$r' q'$ respectively. But $r$ depends on $p$/$q$, so this commute fails!

XXX Change the /

XXX Say key point is merge equates by name, commute by content


