Entity back pointers to the branch Jonathan S. Shapiro (shap@eros-os.org)
Mon, 12 Jun 2000 14:08:41 -0400

Something struck me while implementing the predecessor list logic in commit that makes the answer fairly obvious: entities should definitely name the branch and version under which they were first committed.

My original reluctance had to do with the fact that you could have many branch versions including the same entity, because the entity gets carried forward until it is modified again. In a straight-line branch this causes no confusion; the back pointer merely names the version on the current branch in which the entity was introduced.

The reason I wanted to avoid the back pointer was that confusion might arise after a merge. Given a merge resulting from two lines of development A and B, you'ld suddenly have objects whose last modification was in B and objects whose last modification was in A. In time, this would make the merge algorithm behavior fairly hard to understand, because the closes common ancestor would turn out to be something on some long-forgotten branch.

What I failed to consider is that if the object has been modified on either branch, the merge needs to generate a new entity, because the predecessor list needs to be updated.

So a question for Josh (and John, and anybody else who feels inclined to chip in):

Assume that lines of development A and B derive from a common ancestor, and that we are now merging them back together. For a given entity X, it seems to me that the following possibilities exist (I'm ignoring the cases where one or the other is missing).

  1. X was not modified in either A or B. We can carry the pre-fork version forward without introducing a new entity.
  2. X was modified in A or X was modified in B, but not both. We can carry the modified version forward without introducing a new entity.
  3. X was modified in both A and B. We must merge and introduce a new enity.

My question is: in the cases where a new entity did not strictly need to be introduced, might it nonetheless be useful to create one for the sake of shortening the length of the predecessor arcs? For example, if A.X was modified, but B.X was not, might we nonetheless want to create a new entity [A merge B].X whose predecessors are A[last].X and B[last].X?

shap