Export TimeTravel History¶
It may be useful to get the history of all edits to a given file shown in TimeTravel. One example might be a project in which students collaborate, where individual contributions to a team effort need to be documented.
There are three ways to export TimeTravel information.
Use the project API.
The following code snippet gives an example:
import sys sys.path.append("/cocalc/src/smc_pyutil/smc_pyutil/") import api v = api.get_syncdoc_history('a.ipynb', patches=False)
Replace ‘a.ipynb’ by the name of a file in the same project that you’re running this from.
When you run the code, v will have the complete TimeTravel history as a Python dictionary.
If patches=True you also get the actual patches, not just their lengths.
Each entry in the JSON file corresponds to one change, or patch, to the file. The field patch_length is the number of characters of the actual patch, which is not currently in the export.
If the project API is used to export TimeTravel, contents of the patches as well as the patch length can be retrieved by setting
patches=True in the api call.
In some cases, changes are attributed to the project, rather than to an individual user. For example, if you type the following into a compute cell in a Jupyter notebook:
then what you contributed to the patch stream is the string “2+2”. When you request to evaluate the project then inserts the output “4” into the patch stream.
The project will also output information about cpu usage, memory usage, etc., periodically into the notebook, which is again attributed to the project.
If you directly change a file on disk, the project will notice and load the changed file, and that change is also attributed to the project.