4 Merge commits $L$ and $R$ using merge base $M$:
6 C \hasparents \{ L, R \}
8 \patchof{C} = \patchof{L}
10 \commitmergeof{C}{L}{M}{R}
12 We will occasionally use $X,Y$ s.t. $\{X,Y\} = \{L,R\}$.
14 This can also be used for dependency re-insertion, by setting $L \in
15 \pn$, $R \in \pry$, $M = \baseof{R}$, provided that the Conditions are
16 satisfied; in particular, provided that $L \ge \baseof{R}$.
18 \subsection{Conditions}
19 \[ \eqn{ Ingredients }{
25 R \in \py : & \baseof{R} \ge \baseof{L}
26 \land [\baseof{L} = M \lor \baseof{L} = \baseof{M}] \\
27 R \in \pn : & M = \baseof{L} \\
28 \text{otherwise} : & \false
31 \[ \eqn{ Base Merge }{
41 \[ \eqn{ Merge Acyclic }{
46 \[ \eqn{ Removal Merge Ends }{
47 X \not\haspatch \p \land
51 \pendsof{Y}{\py} = \pendsof{M}{\py}
53 \[ \eqn{ Addition Merge Ends }{
54 X \not\haspatch \p \land
55 M \nothaspatch \p \land
58 \bigforall_{E \in \pendsof{X}{\py}} E \le Y
61 \[ \eqn{ Suitable Tips }{
62 \bigforall_{\p \neq \patchof{L}, \; C \haspatch \p}
64 \pendsof{J}{\py} = \{ T \}
66 \forall_{E \in \pendsof{K}{\py}} T \ge E
67 , \text{where} \{J,K\} = \{L,R\}
69 \[ \eqn{ Foreign Merges }{
70 \isforeign{L} \implies \isforeign{R}
73 \subsection{Non-Topbloke merges}
75 We require both $\isforeign{L}$ and $\isforeign{R}$
76 (Foreign Merges, above).
77 I.e. not only is it forbidden to merge into a Topbloke-controlled
78 branch without Topbloke's assistance, it is also forbidden to
79 merge any Topbloke-controlled branch into any plain git branch.
81 Given those conditions, Tip Merge and Merge Acyclic do not apply.
82 By Foreign Ancestry of $L$, $\isforeign{M}$ as well.
83 So by Foreign Ancestry for any $A \in \{L,M,R\}$,
84 $\forall_{\p, D \in \py} D \not\le A$
85 so $\pendsof{A}{\py} = \{ \}$ and the RHS of both Merge Ends
86 conditions are satisifed.
88 So a plain git merge of non-Topbloke branches meets the conditions and
89 is therefore consistent with our model.
91 \subsection{No Replay}
93 By definition of \commitmergename,
94 $D \isin C \implies D \isin L \lor D \isin R \lor D = C$.
96 Ingredients Prevent Replay applies. $\qed$
98 \subsection{Unique Base}
100 Need to consider only $C \in \py$, ie $L \in \py$,
101 and calculate $\pendsof{C}{\pn}$. So we will consider some
102 putative ancestor $A \in \pn$ and see whether $A \le C$.
104 By Exact Ancestors for C, $A \le C \equiv A \le L \lor A \le R \lor A = C$.
105 But $C \in \py$ and $A \in \pn$ so $A \neq C$.
106 Thus $A \le C \equiv A \le L \lor A \le R$.
108 By Unique Base of L and Transitive Ancestors,
109 $A \le L \equiv A \le \baseof{L}$.
111 \subsubsection{For $R \in \py$:}
113 By Unique Base of $R$ and Transitive Ancestors,
114 $A \le R \equiv A \le \baseof{R}$.
116 But by Tip Merge condition on $\baseof{R}$,
117 $A \le \baseof{L} \implies A \le \baseof{R}$, so
118 $A \le \baseof{R} \lor A \le \baseof{L} \equiv A \le \baseof{R}$.
119 Thus $A \le C \equiv A \le \baseof{R}$.
120 That is, $\baseof{C} = \baseof{R}$.
122 \subsubsection{For $R \in \pn$:}
124 By Tip Merge condition and since $M \le R$,
125 $A \le \baseof{L} \implies A \le R$, so
126 $A \le R \lor A \le \baseof{L} \equiv A \le R$.
127 Thus $A \le C \equiv A \le R$.
128 That is, $\baseof{C} = R$.
132 \subsection{Coherence and Patch Inclusion}
136 L \nothaspatch \p \land R \nothaspatch \p : & C \nothaspatch \p \\
137 L \haspatch \p \land R \haspatch \p : & C \haspatch \p \\
138 \text{otherwise} \land M \haspatch \p : & C \nothaspatch \p \\
139 \text{otherwise} \land M \nothaspatch \p : & C \haspatch \p
143 ~ Consider $D \in \py$.
145 \subsubsection{For $L \nothaspatch \p, R \nothaspatch \p$:}
146 $D \not\isin L \land D \not\isin R$. $C \not\in \py$ (otherwise $L
147 \in \py$ ie $L \haspatch \p$ by Tip Own Contents for $L$).
149 Applying \commitmergename gives $D \not\isin C$ i.e. $C \nothaspatch \p$.
152 \subsubsection{For $L \haspatch \p, R \haspatch \p$:}
153 $D \isin L \equiv D \le L$ and $D \isin R \equiv D \le R$.
154 (Likewise $D \isin X \equiv D \le X$ and $D \isin Y \equiv D \le Y$.)
156 Consider $D = C$: $D \isin C$, $D \le C$, OK for $C \zhaspatch \p$.
158 For $D \neq C$: $D \le C \equiv D \le L \lor D \le R
159 \equiv D \isin L \lor D \isin R$.
160 (Likewise $D \le C \equiv D \le X \lor D \le Y$.)
162 Consider $D \neq C, D \isin X \land D \isin Y$:
163 By \commitmergename, $D \isin C$. Also $D \le X$
164 so $D \le C$. OK for $C \zhaspatch \p$.
166 Consider $D \neq C, D \not\isin X \land D \not\isin Y$:
167 By \commitmergename, $D \not\isin C$.
168 And $D \not\le X \land D \not\le Y$ so $D \not\le C$.
169 OK for $C \zhaspatch \p$.
171 Remaining case, wlog, is $D \not\isin X \land D \isin Y$.
172 $D \not\le X$ so $D \not\le M$ so $D \not\isin M$.
173 Thus by \commitmergename, $D \isin C$. And $D \le Y$ so $D \le C$.
174 OK for $C \zhaspatch \p$.
176 So, in all cases, $C \zhaspatch \p$.
177 And by $L \haspatch \p$, $\exists_{F \in \py} F \le L$
178 and this $F \le C$ so indeed $C \haspatch \p$.
180 \subsubsection{For (wlog) $X \not\haspatch \p, Y \haspatch \p$:}
182 One of the Merge Ends conditions applies.
183 Recall that we are considering $D \in \py$.
184 $D \isin Y \equiv D \le Y$. $D \not\isin X$.
185 We will show for each of
187 if $M \haspatch \p$, $D \not\isin C$,
188 whereas if $M \nothaspatch \p$, $D \isin C \equiv D \le C$.
189 And by $Y \haspatch \p$, $\exists_{F \in \py} F \le Y$ and this
190 $F \le C$ so this suffices.
192 Consider $D = C$: Thus $C \in \py, L \in \py$.
193 By Tip Own Contents, $L \haspatch \p$ so $L \neq X$,
194 therefore we must have $L=Y$, $R=X$.
195 Conversely $R \not\in \py$
196 so by Tip Merge $M = \baseof{L}$. Thus $M \in \pn$ so
197 by Base Acyclic $M \nothaspatch \p$. By \commitmergename, $D \isin C$,
200 Consider $D \neq C, M \nothaspatch \p, D \isin Y$:
201 $D \le Y$ so $D \le C$.
202 $D \not\isin M$ so by \commitmergename, $D \isin C$. OK.
204 Consider $D \neq C, M \nothaspatch \p, D \not\isin Y$:
205 $D \not\le Y$. If $D \le X$ then
206 $D \in \pancsof{X}{\py}$, so by Addition Merge Ends and
207 Transitive Ancestors $D \le Y$ --- a contradiction, so $D \not\le X$.
208 Thus $D \not\le C$. By \commitmergename, $D \not\isin C$. OK.
210 Consider $D \neq C, M \haspatch \p, D \isin Y$:
211 $D \le Y$ so $D \in \pancsof{Y}{\py}$ so by Removal Merge Ends
212 and Transitive Ancestors $D \in \pancsof{M}{\py}$ so $D \le M$.
213 Thus $D \isin M$. By \commitmergename, $D \not\isin C$. OK.
215 Consider $D \neq C, M \haspatch \p, D \not\isin Y$:
216 By \commitmergename, $D \not\isin C$. OK.
220 \subsection{Base Acyclic}
222 This applies when $C \in \pn$.
223 $C \in \pn$ when $L \in \pn$ so by Merge Acyclic, $R \nothaspatch \p$.
225 Consider some $D \in \py$.
227 By Base Acyclic of $L$, $D \not\isin L$. By the above, $D \not\isin
228 R$. And $D \neq C$. So $D \not\isin C$.
232 \subsection{Tip Contents}
234 We need worry only about $C \in \py$.
235 And $\patchof{C} = \patchof{L}$
236 so $L \in \py$ so $L \haspatch \p$. We will use the Unique Base
237 of $C$, and its Coherence and Patch Inclusion, as just proved.
239 Firstly we show $C \haspatch \p$: If $R \in \py$, then $R \haspatch
240 \p$ and by Coherence/Inclusion $C \haspatch \p$ . If $R \not\in \py$
241 then by Tip Merge $M = \baseof{L}$ so by Base Acyclic and definition
242 of $\nothaspatch$, $M \nothaspatch \p$. So by Coherence/Inclusion $C
243 \haspatch \p$ (whether $R \haspatch \p$ or $\nothaspatch$).
245 We will consider an arbitrary commit $D$
246 and prove the Exclusive Tip Contents form.
248 \subsubsection{For $D \in \py$:}
249 $C \haspatch \p$ so by definition of $\haspatch$, $D \isin C \equiv D
252 \subsubsection{For $D \not\in \py, R \not\in \py$:}
254 $D \neq C$. By Tip Contents of $L$,
255 $D \isin L \equiv D \isin \baseof{L}$, so by Tip Merge condition,
256 $D \isin L \equiv D \isin M$. So by \commitmergename, $D \isin
257 C \equiv D \isin R$. And $R = \baseof{C}$ by Unique Base of $C$.
258 Thus $D \isin C \equiv D \isin \baseof{C}$. OK.
260 \subsubsection{For $D \not\in \py, R \in \py$:}
265 $D \isin L \equiv D \isin \baseof{L}$ and
266 $D \isin R \equiv D \isin \baseof{R}$.
268 Apply Tip Merge condition.
269 If $\baseof{L} = M$, trivially $D \isin M \equiv D \isin \baseof{L}.$
270 Whereas if $\baseof{L} = \baseof{M}$, by definition of $\base$,
271 $\patchof{M} = \patchof{L} = \py$, so by Tip Contents of $M$,
272 $D \isin M \equiv D \isin \baseof{M} \equiv D \isin \baseof{L}$.
274 So $D \isin M \equiv D \isin L$ so by \commitmergename,
275 $D \isin C \equiv D \isin R$. But from Unique Base,
276 $\baseof{C} = \baseof{R}$.
277 Therefore $D \isin C \equiv D \isin \baseof{C}$. OK.
281 \subsection{Unique Tips}
283 For $L \in \py$, trivially $\pendsof{C}{\py} = C$ so $T = C$ is
286 For $L \not\in \py$, $\pancsof{C}{\py} = \pancsof{L}{\py} \cup
287 \pancsof{R}{\py}$. So $T$ from Suitable Tips is a suitable $T$ for
292 \subsection{Foreign Inclusion}
294 Consider some $D \in \foreign$.
295 By Foreign Inclusion of $L, M, R$:
296 $D \isin L \equiv D \le L$;
297 $D \isin M \equiv D \le M$;
298 $D \isin R \equiv D \le R$.
300 \subsubsection{For $D = C$:}
302 $D \isin C$ and $D \le C$. OK.
304 \subsubsection{For $D \neq C, D \isin M$:}
306 Thus $D \le M$ so $D \le L$ and $D \le R$ so $D \isin L$ and $D \isin
307 R$. So by \commitmergename, $D \isin C$. And $D \le C$. OK.
309 \subsubsection{For $D \neq C, D \not\isin M, D \isin X$:}
311 By \commitmergename, $D \isin C$.
312 And $D \isin X$ means $D \le X$ so $D \le C$.
315 \subsubsection{For $D \neq C, D \not\isin M, D \not\isin L, D \not\isin R$:}
317 By \commitmergename, $D \not\isin C$.
318 And $D \not\le L, D \not\le R$ so $D \not\le C$.
323 \subsection{Foreign Ancestry}
325 Only relevant if $\isforeign{L}$, in which case
326 $\isforeign{C}$ and by Foreign Merges $\isforeign{R}$,
327 so Totally Foreign Ancestry applies. $\qed$
329 \subsection{Bases' Children}
331 If $L \in \py, R \in \py$: not applicable for either $D=L$ or $D=R$.
333 If $L \in \py, R \in \pn$: not applicable for $L$, OK for $R$.
335 Other possibilities for $L \in \py$ are excluded by Tip Merge.
337 If $L \in \pn, R \in \pn$: satisfied for both $L$ and $R$.
339 If $L \in \pn, R \in \foreign$: satisfied for $L$, not applicable for
342 If $L \in \pn, R \in \pqy$: satisfied for $L$, not applicable for
345 Other possibilities for $L \in \pn$ are excluded by Base Merge.
347 If $L \in \foreign$: not applicable for $L$; nor for $R$, by Foreign Merges.