Department of Electrical and Computer Engineering


Fine-grained Version Control in Molhado

Figure 1. Structure Versioning

From the primitive data model, trees and directed graphs are built. A tree is defined with two main attributes: 1) the ``children'' attribute maps each node to a sequence holding its children, and 2) the ``parent'' attribute maps each node to its parent. Figure 1 illustrates our tree-based structure versioning algorithm via an example. In this example, a ``content'' attribute is also defined that holds a string value for some of the nodes. Assume that there are three versions: v1, v2. The shape of a tree at each of the twoversions is shown. Version \emph{v2} has two differences from the version \emph{v1}: node 4 was deleted and the content of node 5 was changed. The values of versioned slots in the attribute table are changed to reflect modifications to the tree at these versions. For example, at the version v2, the ``content'' slot (i.e. the slot defined by the attribute ``content'') of node 5 contains a new value (the string ``new''), and the ``children'' slot of node 2 contains a reference to a new sequence object (seq3). Seq3 has only one slot, which contains a reference to node 5 since node 4 has been deleted. If there is a request for the values of slots associated with node 4 at v2, a run-time error will be reported. The fine-grained versioning algorithm for a directed graph is similar except that the attribute table does not have the ``parent'' attribute.

This structure versioning infrastructure is powerful and flexible since a directed graph can be used to represent various forms of structures. It is also very efficient since common structures are shared among versions and all information including structures and contents are versioned via one mechanism. Importantly, the algorithm is general for any subtree or subgraph, therefore, fine-grained version control is achieved for any abstraction represented by a node,
such as any syntactical unit in a program.

Figure 2. Fine-grained Version Control

Unlike many fine-grained SCM systems where granularity of versionable information unit is predefined and hard-coded, Molhado can version any logical unit (in general, any object that is represented as a node in our versioning infrastructure) if it is built according to our framework. For example, with Java classes and XML documents, the evolution of any syntactical unit (a class, a method, a statement, an expression, even a field) in a Java program or any element in an XML document can be captured. Figure 2 shows the history for a method.

Figure 3 shows the history of a paragraph in an XML documentation.


Since a link is also represented as a node, its evolution can be captured in Molhado too. Figure 4 shows the history of the link ``agrees''. Note that the link was not created until the version v9.1.1.1. Therefore, the earlier versions on the top window are ``disabled''. The evolution of SVG graphical objects can be displayed in the similar manner.

Figure 4. Versioning for a link