Define the Revision Tracking Graph (RTG), which is an oriented graph (without circles) where each node x has a set C(x) associated with it. C(x) contains all edges on all paths from a node 0 ( C(0) = {} ). Each edge can be in a set at most once!
You can also describe this data structure by the rules for its growth:
- Start with node 0 with associated empty set
C(0) = {}
= creating new object - For any node x create a new node y where (x,y) is oriented edge from x to y and
C(y) = C(x) union { (x,y) }
= versioning and branching - For any nodes f and t, create node r, where (f,r) and (t,r) are oriented edges and
C(r) = C(f) union C(t) union { (f,r), (t,r) }
= merging
Note: You can see there is no mathematical difference between creating new version and a branch. It is a semantical difference depending on whether there is already an edge leading from the node or not.
Base node is defined as a node b, such as C(b) = C(f) intersect C(t)
, where f and t are nodes representing two versions to be merged.
Simple Merge equation Result=To + (From-Base)
= means that if we subtract every edge in C(b) from C(f) and add all edges in C(t) we get a resulting C(r) minus (f,r) and (t,r) edges exactly. No edge would appear twice and all edges in C(f) and C(t) would be represented. = 3-way merge
Complex merge equation Result = To + Sum(i=1..n) for (Fi-Bi), where Fn = From
. Each edge can be in exactly one of the sets To, (Fi-Bi). For n=1 this turns into a simple merge equation. In case there exist no base in simple case, we might find sequence of F,B nodes to fit the complex equation. (1+2n)-way merge
I have actually several questions pertaining to this data structure. I am posing the first 3 for "frame of mind", as I already know the answers. And I believe question 4 directly leads to answering question 5, which I really try to get answered.
- Prove there can be no circles in the graph
- Prove that for certain graphs there are such nodes F,T for which base cannot be found as specified in simple equation.
- Create algorithm to find B in simple case where n = 1.
- Prove that for each RTG and each pair of nodes F and T, there is a set of n pairs of nodes Fi,Bi, where i=1..n to fit the complex merge equation.
- Create algorithm to find minimum n and Fi,Bi for i=1..n where n > 1.