Today we want to talk about a new feature that appeared in
Biggo a couple of days ago. The idea to implement the storage of versions of the site templates being changed has been around for a long time, but over time it became clear that this function would be useful for many clients who periodically change the source code of the templates. The fact is that by chance, or through ignorance, sometimes there are misunderstandings after the intervention of site owners in the source code. Of course, most often it turns out to return everything in one way or another, but if there was a version history, it would be so simple that no one would even have asked for it in those. support By the way, from the very beginning we had the function of restoring the template from the selected design, but firstly the original version of the template is not always desired, secondly it is impossible for the newly created templates, because there is only one copy. (There is a backup, but this is a separate topic).
So we decided to do everything according to the mind. It did not take long to choose a version control system, since there were selection criteria:
- decentralized (we don’t have any desire to launch a CVS server for each site)
- fast
At least several options came up here, but since there was a successful experience with Mercurial
(and it is also written in python, like everything else we have), then we chose it.
So, each time a file is saved, a new version is commited to the common repository for the site, that is, the changeset includes changing one file. As a result, how can we use this data:
')
1. Table of changes (what, who, when and where changed). This is also important because our dealers can perform additional tasks. services by accessing the site, including templates. In which case, besides the general CMS log, now there is also accurate data on changes in each template.
2. Comparison of versions. Visualization of differences in an easy-to-read format. Here, by the way, the role of Mercurial ends with the fact that it gives the contents of the files of the specified revisions, and the comparison is already a third-party library. Agree, in this form it is easier to study the differences than to read the unified diff format, from which inexperienced users are far enough.

Here you can see what has been removed, what has been added (red and green are highlighted)
3. Restore the required file revision
It should also be noted that the story is maintained regardless of how the file was changed: via textarea in the browser, or loaded changed in the editor.