chiark / gitweb /
Makefile: printing rune
[topbloke-formulae.git] / old-strategy.tex
1
2 \section{Planning phase}
3
4 The results of the planning phase consist of: 
5 \begin{itemize*}
6 \item{ The relation $\hasdirdep$ and hence the partial order $\hasdep$. }
7 \item{ For each commit set $\pc$, a confirmed set of sources $\set S_{\pc}$. }
8 \item{ For each commit set $\pc$, the order in which to merge the sources
9         $E_{\pc,j} \in \set E_{\pc}$. }
10 \item{ For each $E_{\pc,j}$ an intended merge base $M_{\pc,j}$. }
11 \end{itemize*}
12
13 We use a recursive planning algorith, recursing over Topbloke commit
14 sets (ie, sets $\py$ or $\pn$).  We'll call the commit set we're
15 processing at each step $\pc$.
16 At each recursive step 
17 we make a plan to merge all $\set E_{\pc} = \{ E_{\pc,j \ldots} \}$
18 and all the direct contributors of $\pc$ (as determined below)
19 into $\tipzc$, to make $\tipfc$.
20
21 We start with $\pc = \pl$ where $\pl = \patchof{L}$.
22
23
24 \subsection{Direct contributors for $\pc = \pcn$}
25
26 The direct contributors of $\pcn$ are the commit sets corresponding to
27 the tip branches for the direct dependencies of the patch $\pc$.  We
28 need to calculate what the direct dependencies are going to be.
29
30 Choose an (arbitrary, but ideally somehow optimal in
31 a way not discussed here) ordering of $\set E_{\pc}$, $E_{\pc,j}$
32 ($j = 1 \ldots m$).
33 For brevity we will write $E_j$ for $E_{\pc,j}$.
34 Remove from that set (and ordering) any $E_j$ which
35 are $\le$ and $\neq$ some other $E_k$.
36
37 Initially let $\set D_0 = \depsreqof{\tipzc}$.
38 For each $E_j$ starting with $j=1$ choose a corresponding intended
39 merge base $M_j$ such that $M_j \le E_j \land M_j \le T_{\pc,j-1}$.
40 Calculate $\set D_j$ as the 3-way merge of the sets $\set D_{j-1}$ and
41 $\depsreqof{E_j}$ using as a base $\depsreqof{M_j}$.  This will
42 generate $D_m$ as the putative direct contributors of $\pcn$.
43
44 However, the invocation may give instructions that certain direct
45 dependencies are definitely to be included, or excluded.  As a result
46 the set of actual direct contributors is some arbitrary set of patches
47 (strictly, some arbitrary set of Topbloke tip commit sets).
48
49 \subsection{Direct contributors for $\pc = \pcy$}
50
51 The sole direct contributor of $\pcy$ is $\pcn$.
52
53 \subsection{Recursive step}
54
55 For each direct contributor $\p$, we add the edge $\pc \hasdirdep \p$
56 and augment the ordering $\hasdep$ accordingly.
57
58 If this would make a cycle in $\hasdep$, we abort . The operation must
59 then be retried by the user, if desired, but with different or
60 additional instructions for modifying the direct contributors of some
61 $\pqn$ involved in the cycle.
62
63 For each such $\p$, after updating $\hasdep$, we recursively make a plan
64 for $\pc' = \p$.
65
66
67
68 \section{Execution phase}
69
70 We process commit sets from the bottom up according to the relation
71 $\hasdep$.  For each commit set $\pc$ we construct $\tipfc$ from
72 $\tipzc$, as planned.  By construction, $\hasdep$ has $\patchof{L}$
73 as its maximum, so this operation will finish by updating
74 $\tipca{\patchof{L}}$ with $\tipfa{\patchof{L}}$.
75
76 After we are done with each commit set $\pc$, the
77 new tip $\tipfc$ has the following properties:
78 \[ \eqn{Tip Sources}{
79   \bigforall_{E_i \in \set E_{\pc}} \tipfc \ge E_i
80 }\]
81 \[ \eqn{Tip Dependencies}{
82   \bigforall_{\pc \hasdep \p} \tipfc \ge \tipfa \p
83 }\]
84 \[ \eqn{Perfect Contents}{
85   \tipfc \haspatch \p \equiv \pc \hasdep \py
86 }\]
87
88 For brevity we will sometimes write $\tipu$ for $\tipuc$, etc.  We will start
89 out with $\tipc = \tipz$, and at each step of the way construct some
90 $\tipu$ from $\tipc$.  The final $\tipu$ becomes $\tipf$.
91
92 \subsection{Preparation}
93
94 Firstly, we will check each $E_i$ for being $\ge \tipc$.  If
95 it is, are we fast forward to $E_i$
96 --- formally, $\tipu = \text{max}(\tipc, E_i)$ ---
97 and drop $E_i$ from the planned ordering.
98
99 Then we will merge the direct contributors and the sources' ends.
100 This generates more commits $\tipuc \in \pc$, but none in any other
101 commit set.  We maintain
102 $$
103  \bigforall_{\p \isdep \pc}
104  \pancsof{\tipcc}{\p} \subset
105    \pancsof{\tipfa \p}{\p}
106 $$
107 \proof{
108  For $\tipcc = \tipzc$, $T$ ...WRONG WE NEED $\tipfa \p$ TO BE IN $\set E$ SOMEHOW
109 }
110
111 \subsection{Merge Contributors for $\pcy$}
112
113 Merge $\pcn$ into $\tipc$.  That is, merge with
114 $L = \tipc, R = \tipfa{\pcn}, M = \baseof{\tipc}$.
115 to construct $\tipu$.
116
117 Merge conditions:
118
119 Ingredients satisfied by construction.
120 Tip Merge satisfied by construction.  Merge Acyclic follows
121 from Perfect Contents and $\hasdep$ being acyclic.
122
123 Removal Merge Ends: For $\p = \pc$, $M \nothaspatch \p$; OK.
124 For $\p \neq \pc$, by Tip Contents,
125 $M \haspatch \p \equiv L \haspatch \p$, so we need only
126 worry about $X = R, Y = L$; ie $L \haspatch \p$,
127 $M = \baseof{L} \haspatch \p$.
128 By Tip Contents for $L$, $D \le L \equiv D \le M$.  OK.~~$\qed$
129
130 WIP UP TO HERE
131
132 Addition Merge Ends: If $\py \isdep \pcn$, we have already
133 done the execution phase for $\pcn$ and $\py$.  By
134 Perfect Contents for $\pcn$, $\tipfa \pcn \haspatch \p$ i.e.
135 $R \haspatch \p$.  So we only need to worry about $Y = R = \tipfa \pcn$.
136 By Tip Dependencies $\tipfa \pcn \ge \tipfa \py$.
137 And by Tip Sources $\tipfa \py \ge $
138
139 want to prove $E \le \tipfc$ where $E \in \pendsof{\tipcc}{\py}$
140
141 $\pancsof{\tipcc}{\py} = $
142
143
144 computed $\tipfa \py$, and by Perfect Contents for $\py$
145
146
147 with $M=M_j, L=T_{\pc,j-1}, R=E_j$,
148 and calculate what the resulting desired direct dependencies file
149 (ie, the set of patches $\set D_j$)
150 would be.  Eventually we 
151
152 So, formally, we select somehow an order of sources $S_i$.  For each 
153
154
155 Make use of the following recursive algorithm, Plan 
156
157
158
159
160  recursively make a plan to merge all $E = \pends$
161
162 Specifically, in
163
164
165
166
167
168
169