\section{Strategy}
When we are trying to do a merge of some kind, in general,
we want to merge some commits $S_0 \ldots S_n$.
We'll write $S_0 = L$. We require that $L$ is the current git ref
for $\patchof{L}$.
%Let $\set E_{\pc} = \bigcup_i \pendsof{S_i}{\pc}$.
\subsection{Notation}
\begin{basedescript}{
\desclabelwidth{5em}
\desclabelstyle{\nextlinelabel}
}
\item[ $\depsreqof{K}$ ]
The set of direct dependencies (in the form $\py$)
requested in the commit $K$ ($K \in \pn$) for the patch $\p$.
\item[ $\pc \succ_1 \{ \p, \pq \ldots \}$ ]
The Topbloke commit set $\pc$ has as direct contributors
(see below) exactly $\p, \pq, \ldots$. This is an acyclic relation.
\item[ $\p \succ \pq$ ]
The commit set $\p$ has as direct or indirect contributor the commit
set $\pq$.
This is an acyclic relation, and is the completion of $\succ_1$ into a
partial order.
\end{basedescript}
\subsection{Planning phase}
We use a recursive planning algorith, recursing over Topbloke commit
sets (ie, sets $\py$ or $\pn$). We'll call the commit set we're
processing at each step $\pc$. We start with $\pc = \pl$
where $\pl = \patchof{L}$.
At each recursive step
we intend to merge all $\set E_{\pc} = \{ E_{\pc,j \ldots} \}$
and all the direct contributors of $\pc$ (as determined below)
into the existing git ref for $\pc$, to make $T_{\pc}$.
The direct contributors of $\pcn$ are the Topbloke commit sets
corresponding to the tip branches for the direct dependencies of
$\pc$.
The sole direct contributor of $\pcy$ is $\pcn$.
\subsubsection{Planning step for $\pc = \pcn$.}
FIXME DEFINE $\set E$
Choose an (arbitrary, but ideally somehow optimal in
a way not discussed here) ordering of $\set E_{\pc}$, $E_j$ (for
$j = 1 \ldots m$). Remove from that set (and ordering) any $E_j$ which
are $\le$ and $\neq$ some other $E_k$.
Initially let $T_{\pc,0}$ be the git ref for $\pcn$. And let
$\set D_0 = \depsreqof{T_{\pc,0}}$.
For each $E_j$ starting with $j=1$ choose a corresponding intended
merge base $M_j$ such that $M_j \le E_j \land M_j \le T_{\pc,j-1}$.
Calculate $\set D_j$ as the 3-way merge of the sets $\set D_{j-1}$ and
$\depsreqof{E_j}$ using as a base $\depsreqof{M_j}$. This will
generate $D_m$ as the putative direct contributors for $\pcn$.
However, the invocation may specify that certain direct dependencies
are definitely to be included, or excluded. As a result the set
of actual direct contributors is some arbitrary set of patches.
Imagine that we will merge the direct
with $M=M_j, L=T_{\pc,j-1}, R=E_j$,
and calculate what the resulting desired direct dependencies file
(ie, the set of patches $\set D_j$)
would be. Eventually we
So, formally, we select somehow an order of sources $S_i$. For each
Make use of the following recursive algorithm, Plan
recursively make a plan to merge all $E = \pends$
Specifically, in