====== Changes and Versions ======

Changes are the persistent undo stack.
Versions are snapshots of the repository.
Archive is pages that are on non-active

Changes are per-page
Versions are repository width

For Changes and versions one dialog. Top a list with versions, below a list with changes for the current selected version. Versions is a linear list, changes a foldable tree by timestamp. Not sure how to handle view verus edit on these. Guess versions apart from current are always read-only. Changes may be regarded as an undo - but I also just may want to browse them.

---------------

* Log diffs at "commit_change()"
* Use the "Revert from HD" menu item to pop dialog with revisions
	* hard save before reverting => folded history
* Use "purge history" menu item to explicitly throw away records
	* dialog to confirm
	* check box for this page / all pages
* TODO for future release
	* Automatic purging
	* Hook revisions into the undo stack
		* hard save (?) + swap buffer to cache
		* if start editing from revision, throw away undo stack, diff against last save
			* => folded undo stack
		* if redo swap buffer in
	* Cache undo stack for X recent pages in PageView
		* Give parse tree a time stamp to check if page has changed
		* Set default to 1 cache item, this allows to go one level deep while editing
			* option to increase this cache
		* Also cache buffer, since parsing the tree again can invalidate the undo stack
		* maybe put buffer and stack in the page object and cache page objects ?
			* seems good approach, add "HEAD" method to repo to check if page has changed
	* Throw away undo stack on reload of the parse tree (e.g. explicit ^R)


===== Changes =====
The file based repository keeps copies of all pages in a sub-directory called "_changes".
Same dir is used to store files with a log of backward diffs.

* On save page also save a diff
* create an undo stack out of these diffs
* integrate this with the [[HyperTextBuffer]] undo stack
	* go into diff stack when at bottom of undo stack
	* swap buffer, and load diffed versions from file
	* on redo swap back at top of diff stack
* also a simple dialog with timestamps of changes to do rollback
* talk of "changes" -- "versions" are tagged places in this stack
	* versions can be kept by CVS / SVN / ...
	* changes are more fine-grained log between versions
* consider changes a semi-permanent cache
	* changes may be flushed after a version is made
	* or just to safe space - add menuitem tools->flush
	* changes can be purged, e.g. flush all changes older than two weeks

===== Versioning =====
* GUI
	* popup terminal when running external version control commands
	* "save version" (commit)
	* "check version" (update)
	* "versions.." should give a dialog with all version of a page. Versions can be shown read-only.
		* the version dialog will have a "Restore" button
		* when viewing a version read-only you can always use "save copy" to make a read-write copy of it
* API
	* Implement a Dir object that creates File objects and use this in Repsotiry/Files.pm
	* RC plugins can overload this object and use File objects with various hooks
	* No auto-detecting, repositories need to have been explicitly configed to use these backends
		* We do need a list of available backends for the dialog where this option can be edited
* proof of concept plugin for arch
* simple version control as plugin
	* use "''_archive/namespace/../page.utime.txt''"
* make the api generic enough that e.g. an encryption plugin is also possible with the same interface

===== Archive =====
* mechanism to hide namespaces from the side-pane
* plugin that adds an "archive" option next to delete which moves pages into this namespace.
	* update all links
	* if page exists append version number
	* for new pages insert link in template if page exists in archive
