When working on a shared project in a team, it may happen that the same files are edited by several users simultaneously. To save such changes from being overwritten, MetaEditor features the function for merging data.
If you try to save a file that has already been changed by someone to the storage, MetaEditor prompts you to get the latest changes first. When the changes are received, an attempt is made to merge the data: changes from the storage are applied to the local data copy and an attempt is made to save the current local changes.
Merging is applied only to text files with the source code (mq4, mq5, mqh, cpp and h) in ANSI format. Bmp and wav files are always completely replaced by newer versions.
Source code files are compared line by line. When conflicts arise (for example, the same line is changed in the local file and in the corresponding file in the repository), the merging algorithm aims to maximize the preservation of local changes.
Let's consider a typical case of merging two files. As mentioned above, during merging, source code files are compared line by line. If a file in the storage contains the lines that are not present in the local file, these lines are added. Consider the following example of merging two files:
After you click Update from Storage, the local files remain unchanged, since local changes are of higher priority. If the storage file had contained the new line "x=0;", it would have been added, while "return(true);" line would have remained unchanged:
The main principle of merging is the higher priority of local data. The algorithm seeks to maximize the preservation of local changes.
There are many types of conflicts during merging. In this section, just one of the most common situations was considered. The merging algorithm is complex and provides a comprehensive approach in the analysis files. More information about the merger can be found in a book on Subversion.