![]() |
Versioning tools | ![]() |
When writing documents in collaboration with other authors, it frequently arises that one wants to go through changes made by the other authors, and either accept, discard or further correct them. For this purpose, a special menu Version appears in the main menu bar, which makes this process automatic. By default, this menu is shown for documents under version control; using Tools\(\rightarrow\)Versioning tool\(\rightarrow\)Always, it is shown for all documents. Below, we will describe in more detail how this tool works.
In addition, there exist many stand-alone programs for maintaining several versions of a same file, such as Subversion, Git, Darcs, GNU Arch, just to mention a few of them. TeXmacs currently provides a basic support for Subversion and an extensive support for Git, but interfaces for the other systems could easily be added.
Assume that we have two versions old.tm and new.tm of the same document. In order to see the changes, first load the newer version new.tm, then click on Version\(\rightarrow\)Compare\(\rightarrow\)With older version and select the older version old.tm. The buffer will still be named new.tm, and the changes between both versions will be indicated by special markup. If there are any changes, then the cursor will be positioned at the first difference. In a similar way, you may compare the current buffer with a newer version on disk using Version\(\rightarrow\)Compare\(\rightarrow\)With newer version.
It is possible to go through all the differences between the old and new versions either from the items in the submenu Version\(\rightarrow\)Differences, or using the keyboard shortcuts ⌃↑ and ⌃↓. One may also use the more general structured navigation shortcuts ⌥↖, ⌥↘, ⌥⇞ and ⌥⇟.
Differences between the two versions can be displayed in three ways: by showing only the old version, only the new version, or both versions simultaneously. In all cases, the old version is displayed in dark red and the new version in dark green.
The visualization style can be specified individually for each individual change, via Version\(\rightarrow\)Differences\(\rightarrow\)Show or the keyboard shortcuts ⌃← (old version), ⌃→ (new version) and ⌃| (both versions). One may also cycle through the different style using the structured variant key ⌥⇥. If you selected some text, then the above actions will apply to the whole selection. In particular, by selecting the entire file, you can visualize the older or the newer version, or both versions.
It often occurs that we want to go through the changes between two versions and progressively retain either one or the other version for each individual difference. Assuming that the cursor is inside a given difference, this can be done from entries in the submenu Version\(\rightarrow\)Differences\(\rightarrow\)Retain. Alternatively, one may use the shortcuts ⌃1, ⌃2 and ⌃↩ to retain the old, new and currently displayed version, respectively. If both versions are displayed, then ⌃↩ retains the new version. After retaining one of the versions, we automatically jump to the next difference, which can then be processed.
If you selected some text, then any of the above action will retain the appropriate version for each of the differences in the selection. This applies in particular to the case when you select the entire document. A convenient alternative way to process all differences is to use ⌃↑ and ⌃↓ to go through the differences, use ⌃← and ⌃→ to select the preferred version. As soon as all differences have been processed, you select the entire document and click on Version\(\rightarrow\)Differences\(\rightarrow\)Retain\(\rightarrow\)Current version.
The entries in the submenu Version\(\rightarrow\)Differences\(\rightarrow\)Grain allow you to control the grain with which differences between versions are computed. By default, we use the finest grain Detailed. It is also possible to compute differences on a paragraph-based level, using Block. In that case, the entire paragraphs in which a change occurs will be highlighted. The roughest grain Rough will highlight the entire text, if a change occurs somewhere inside.
The grain is used when comparing two documents using Version\(\rightarrow\)Compare, but it is also possible to change the grain for a selected portion of text: simply select the text and choose the new grain in the submenu Version\(\rightarrow\)Differences\(\rightarrow\)Grain. This can in particular be applied on the entire buffer. Similarly, if you change the grain inside a difference, then the difference will be recomputed using the new grain.
Notice that you may also “change” the grain to the current grain. This has the effect of reactualizing the differences of a selected portion or of the current difference at the cursor position. This may be useful, if you made some changes to one of the versions. For instance, assume that the old version contained a theorem and that we changed it into a lemma in the new version and also modified part of its inside text. When visualizing the changes, the whole theorem will be highlighted, since there is no appropriate markup to indicate that we just changed from a theorem to a lemma. Nevertheless, if we want to compare the inside texts, we may turn the old theorem into a lemma and then reactualize.
If the file you are editing belongs to a directory that is under version control (only Subversion and Git are currently supported, although other systems might follow), then the first part of the Version menu will contain some clickable entries.
First of all, if the current buffer is under version control, then you may take a look at its history using Version\(\rightarrow\)History of this document. The history contains a list of hyperlinks to older revisions, together with short information about who changed what and when. Older revisions cannot be saved, but you may compare them to the current user version (on disk or being edited) using Version\(\rightarrow\)Compare with\(\rightarrow\)Current user version.
For Subversion, the Version menu also contains the following entries; the corresponding tools for Git are described below. After making some changes to a file under version control, the version inside the editor or on disk no longer corresponds to the version in the repository. Using Version\(\rightarrow\)Commit, the current user's version can be committed to the repository. When doing so, you will be prompted for a small explanatory message about the changes that you have made. A file that is not yet under version control can be added to the version control system using Version\(\rightarrow\)Register. Registering a file does not commit it to the repository: you still have to use Version\(\rightarrow\)Commit in order to do so.
If, while you were editing, changes to the file were made in the repository, then you may merge the result with your current version using Version\(\rightarrow\)Update. No conflict resolution has been implemented yet for Subversion.
For documents inside a Git working tree, the Version menu gives access to a complete interface to Git: committing changes or saving snapshots, comparing the document with any earlier version, restoring versions, seeing who changed what, synchronizing with coauthors, branches and tags, and the structured resolution of conflicts. These tools are described in the chapter working with Git.