1 When we are trying to do an update of some kind, in general,
3 we want to merge some source commits $S \in \set S_{\pc}$.
4 We require $\patchof{S} = \pc$,
5 and $\tipcc \in \set S_{\pc}$.
11 \desclabelstyle{\nextlinelabel}
13 \item[ $\depsreqof{K}$ ]
14 The set of direct dependencies (in the form $\py$)
15 requested in the commit $K$ ($K \in \pn$) for the patch $\p$.
17 \item[ $\pc \hasdirdep \p$ ]
18 The Topbloke commit set $\pc$ has as a direct contributor the
19 commit set $\p$. This is an acyclic relation.
21 \item[ $\p \hasdep \pq$ ]
22 The commit set $\p$ has as direct or indirect contributor the commit
24 Acyclic; the completion of $\hasdirdep$ into a
27 %\item[ $\set E_{\pc}$ ]
28 %$ \bigcup_i \pendsof{S_{\pc,i}}{\pc} $.
29 %All the ends of $\pc$ in the sources.
31 \item[ $ \tipzc, \tipcc, \tipuc, \tipfc $ ]
32 The git ref for the Topbloke commit set $\pc$: respectively,
33 the original, current, updated, and final values.
37 \section{Planning phase}
39 The results of the planning phase consist of:
41 \item{ The relation $\hasdirdep$ and hence the partial order $\hasdep$. }
42 \item{ For each commit set $\pc$, a confirmed set of sources $\set S_{\pc}$. }
43 \item{ For each commit set $\pc$, the order in which to merge the sources
44 $E_{\pc,j} \in \set E_{\pc}$. }
45 \item{ For each $E_{\pc,j}$ an intended merge base $M_{\pc,j}$. }
48 We use a recursive planning algorith, recursing over Topbloke commit
49 sets (ie, sets $\py$ or $\pn$). We'll call the commit set we're
50 processing at each step $\pc$.
51 At each recursive step
52 we make a plan to merge all $\set E_{\pc} = \{ E_{\pc,j \ldots} \}$
53 and all the direct contributors of $\pc$ (as determined below)
54 into $\tipzc$, to make $\tipfc$.
56 We start with $\pc = \pl$ where $\pl = \patchof{L}$.
59 \subsection{Direct contributors for $\pc = \pcn$}
61 The direct contributors of $\pcn$ are the commit sets corresponding to
62 the tip branches for the direct dependencies of the patch $\pc$. We
63 need to calculate what the direct dependencies are going to be.
65 Choose an (arbitrary, but ideally somehow optimal in
66 a way not discussed here) ordering of $\set E_{\pc}$, $E_{\pc,j}$
68 For brevity we will write $E_j$ for $E_{\pc,j}$.
69 Remove from that set (and ordering) any $E_j$ which
70 are $\le$ and $\neq$ some other $E_k$.
72 Initially let $\set D_0 = \depsreqof{\tipzc}$.
73 For each $E_j$ starting with $j=1$ choose a corresponding intended
74 merge base $M_j$ such that $M_j \le E_j \land M_j \le T_{\pc,j-1}$.
75 Calculate $\set D_j$ as the 3-way merge of the sets $\set D_{j-1}$ and
76 $\depsreqof{E_j}$ using as a base $\depsreqof{M_j}$. This will
77 generate $D_m$ as the putative direct contributors of $\pcn$.
79 However, the invocation may give instructions that certain direct
80 dependencies are definitely to be included, or excluded. As a result
81 the set of actual direct contributors is some arbitrary set of patches
82 (strictly, some arbitrary set of Topbloke tip commit sets).
84 \subsection{Direct contributors for $\pc = \pcy$}
86 The sole direct contributor of $\pcy$ is $\pcn$.
88 \subsection{Recursive step}
90 For each direct contributor $\p$, we add the edge $\pc \hasdirdep \p$
91 and augment the ordering $\hasdep$ accordingly.
93 If this would make a cycle in $\hasdep$, we abort . The operation must
94 then be retried by the user, if desired, but with different or
95 additional instructions for modifying the direct contributors of some
96 $\pqn$ involved in the cycle.
98 For each such $\p$, after updating $\hasdep$, we recursively make a plan
103 \section{Execution phase}
105 We process commit sets from the bottom up according to the relation
106 $\hasdep$. For each commit set $\pc$ we construct $\tipfc$ from
107 $\tipzc$, as planned. By construction, $\hasdep$ has $\patchof{L}$
108 as its maximum, so this operation will finish by updating
109 $\tipca{\patchof{L}}$ with $\tipfa{\patchof{L}}$.
111 After we are done with each commit set $\pc$, the
112 new tip $\tipfc$ has the following properties:
113 \[ \eqn{Tip Sources}{
114 \bigforall_{E_i \in \set E_{\pc}} \tipfc \ge E_i
116 \[ \eqn{Tip Dependencies}{
117 \bigforall_{\pc \hasdep \p} \tipfc \ge \tipfa \p
119 \[ \eqn{Perfect Contents}{
120 \tipfc \haspatch \p \equiv \pc \hasdep \py
123 For brevity we will sometimes write $\tipu$ for $\tipuc$, etc. We will start
124 out with $\tipc = \tipz$, and at each step of the way construct some
125 $\tipu$ from $\tipc$. The final $\tipu$ becomes $\tipf$.
127 \subsection{Preparation}
129 Firstly, we will check each $E_i$ for being $\ge \tipc$. If
130 it is, are we fast forward to $E_i$
131 --- formally, $\tipu = \text{max}(\tipc, E_i)$ ---
132 and drop $E_i$ from the planned ordering.
134 Then we will merge the direct contributors and the sources' ends.
135 This generates more commits $\tipuc \in \pc$, but none in any other
136 commit set. We maintain
138 \bigforall_{\p \isdep \pc}
139 \pancsof{\tipcc}{\p} \subset
140 \pancsof{\tipfa \p}{\p}
143 For $\tipcc = \tipzc$, $T$ ...WRONG WE NEED $\tipfa \p$ TO BE IN $\set E$ SOMEHOW
146 \subsection{Merge Contributors for $\pcy$}
148 Merge $\pcn$ into $\tipc$. That is, merge with
149 $L = \tipc, R = \tipfa{\pcn}, M = \baseof{\tipc}$.
150 to construct $\tipu$.
154 Ingredients satisfied by construction.
155 Tip Merge satisfied by construction. Merge Acyclic follows
156 from Perfect Contents and $\hasdep$ being acyclic.
158 Removal Merge Ends: For $\p = \pc$, $M \nothaspatch \p$; OK.
159 For $\p \neq \pc$, by Tip Contents,
160 $M \haspatch \p \equiv L \haspatch \p$, so we need only
161 worry about $X = R, Y = L$; ie $L \haspatch \p$,
162 $M = \baseof{L} \haspatch \p$.
163 By Tip Contents for $L$, $D \le L \equiv D \le M$. OK.~~$\qed$
167 Addition Merge Ends: If $\py \isdep \pcn$, we have already
168 done the execution phase for $\pcn$ and $\py$. By
169 Perfect Contents for $\pcn$, $\tipfa \pcn \haspatch \p$ i.e.
170 $R \haspatch \p$. So we only need to worry about $Y = R = \tipfa \pcn$.
171 By Tip Dependencies $\tipfa \pcn \ge \tipfa \py$.
172 And by Tip Sources $\tipfa \py \ge $
174 want to prove $E \le \tipfc$ where $E \in \pendsof{\tipcc}{\py}$
176 $\pancsof{\tipcc}{\py} = $
179 computed $\tipfa \py$, and by Perfect Contents for $\py$
182 with $M=M_j, L=T_{\pc,j-1}, R=E_j$,
183 and calculate what the resulting desired direct dependencies file
184 (ie, the set of patches $\set D_j$)
185 would be. Eventually we
187 So, formally, we select somehow an order of sources $S_i$. For each
190 Make use of the following recursive algorithm, Plan
195 recursively make a plan to merge all $E = \pends$