You can look at the revision system in DokuWiki. It is in Php, but it can give you idea for the organization of the files and the expected features (comparison between old revisions, or compression when revisions are stored).
When you edit a page, DokuWiki creates a revision with the old document. The old versions can be viewed by clicking the Old Revisions button. On the page shown, revisions can be compared with the diff tool.
Revisions are stored within the attic dir, within the configured savedir.
The compression configuration option specifies if the pages will be saved as compressed files or not.
The default system path is <dokuwiki>/data/attic/<namespace>/<attic file>
.
To remove any of the contents of the attic you can manually remove the corresponding files and sub-directories from the system.