In KBibTeX, there is a [[ https://cgit.kde.org/kbibtex.git/tree/src/getgit.cmake | `getgit.cmake` ]] file to collect information from Git regarding the source's history assuming that the source code came from a Git repository. `ECMSourceVersionControl.cmake` can be expanded making `getgit.cmake`'s functionality available to all KDE projects.
Code from KBibTeX's `getgit.cmake` was refactored to fit `ECMSourceVersionControl.cmake` and similar code has been added to support Subversion and other version control systems.
The following information is extracted from version control systems:
* `ECM_SOURCE_VERSION_CONTROL_BRANCH` will contain the name of the branch, such as for example `master` for Git or `^/trunk` for Subversion
* `ECM_SOURCE_VERSION_CONTROL_REVISION` is the current revision, such as the SHA1 hash in Git or `r` followed by a number in Subversion
* `ECM_SOURCE_VERSION_CONTROL_COMMIT_COUNT` is the direct number of commits from the origin of the history until the current revision, excluding any other branches.
Different version control systems are supported to different degrees:
* Git is fully supported thanks to the mature code from `getgit.cmake`
* Subversion is well supported except for the question wheter to use `last-changed-revision` or just `revision` and how to correctly compute the commit count (some `svn log ... | grep -c ...` won't be available)
* Mercurial support only covers `ECM_SOURCE_VERSION_CONTROL_BRANCH` but not `ECM_SOURCE_VERSION_CONTROL_COMMIT_COUNT` or `ECM_SOURCE_VERSION_CONTROL_REVISION`
* Bazaar is virtually incomplete. However, this seems to be a dead project anyway.
Due to its incomplete support, this revision requires input from people more familiar with Subversion, Mercurial, and Bazaar.