I implement versioning for my own domain model (tracking of differences in objects during update operations). Domain model has a tree structure. E.g. (-> is reference)
A
|-> B
|-> C -> A
| -> C
Requirements for versioning are following:
- Get the set of changed fields between two versions of domain object;
- Domain model has a tree structure;
- Fields can be organized in lists. In following example system should show that Y element was removed (but not that Z was removed and Y changed its state on Z) and X was changed:
[ v1 ] [ v2 ]
A A
|-> [X, Y, Z] |-> [X, Z]
|-> C |-> M
- There are no more requirements like locking/merging/branching.
I investigate the way to get change set between two states of the same object. I work with Java and interested in exist approaches/solutions. E.g. I’m looking for description of algorithm that subversion use to create next revision.
I will glad to get any theoretical or practical advice from your side.
Thanks
Well, I would say, you speak of 2 different things here.
Subversion has a revision number for the complete tree, meaning every change is a cheap copy of the previous version. So, there’s no changeset in the term you have in your object hierarchy. It’s more the sum off all changes – and they are calculated per file by your usual diff mechanism.
If you need versioning for your persisted objects, I would add a version attribute in each and then a method per class calculating the differences. But maybe you’ll need to tell us how you plan to use that information?