Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Keeping Turtle and Dolfin in sync

In a turtle-origin project, every change you save in a Dolfin file is written back into the original Turtle automatically. You never have to export by hand.

Video 6.1 · Turtle projects, chapter “Automatic sync” (0:53–1:13). Watch on PeerTube

When it runs

  • Three seconds after you save a .dlf file. Further saves within those three seconds are merged into one run.
  • When you delete or rename a .dlf file.

It runs once at a time per project and never for edits to package.dlf or to the Turtle itself.

In a project with several Turtle sources, a saved file is synced only to the source(s) that generated it, each against its own reference point. A .dlf file that no source generated (one you created yourself) is not synced to any Turtle. In a project with a single source, every .dlf file syncs to it, as before.

Shared files

A Dolfin file generated by two or more sources is shared. Sync never writes a change to a shared file back to a Turtle: Agrafe cannot tell which source the change belongs to. The other files of the same source still sync, and the chip shows blocked: shared dolfin file, naming the file:

auto-sync skipped shared.dlf: generated by several Turtle sources, so the change cannot go back to one of them. Edit the Turtle sources by hand, then Re-translate

Renaming or deleting a shared file stops the sync of each of its sources completely, until you run Re-translate for that source.

To clear the state, make the same change in the Turtle sources by hand, then Re-translate each source (you can leave every file unticked: the shared file is then accepted as it is).

What is changed in the Turtle

Sync compares what Dolfin produced at the last sync with what it produces now, subject by subject, and touches only the subjects that differ.

  • A changed declaration has its statement rewritten in place, using the Turtle’s own prefixes (missing prefixes are added after the last directive).
  • A new declaration is appended after its concept’s last statement, or at the end of the file.
  • A deleted declaration has its statements removed.
  • Everything else is left byte for byte: untouched statements, comments and blank lines between statements, and Turtle that Dolfin does not model (“foreign” statements, for example your own annotations) even on a subject that is rewritten.

Limits

  • Comments inside a rewritten statement are lost. Comments between statements are kept.
  • A rewritten statement uses the serializer’s layout, not yours, and blank nodes come back with generated labels (_:ts…).
  • A restriction or list whose blank nodes no longer match is replaced as a whole (it is listed as Degraded in the report).
  • Changes to package.dlf (version, author, description) are not copied to the Turtle.
  • Renaming a .dlf file changes its namespace and therefore the IRI of everything in it. Sync treats it as removing the old subjects and adding the new ones.

The status chip

The project toolbar shows a chip for turtle-origin projects. Click it for details.

With several sources, the chip shows the source of the active tab: the .ttl itself, or the source that generated the active Dolfin file (the first one for a shared file), otherwise the first source. Its name is prefixed to the label, for example onto.ttl: Turtle in sync · 12:03. Undo last sync acts on that source.

ChipMeaning
Turtle in sync · 12:03Last sync succeeded at that (local) time.
syncing…A change is waiting or running.
blocked: turtle has syntax error (line N)The Turtle does not parse. Nothing is written. Fix the error and the next sync goes through.
blocked: dolfin has errorsThe Dolfin files do not compile. Nothing is written.
blocked: shared dolfin fileA file shared with another source changed. See Shared files.
error: …Something else, with the reason (for example read-only when your licence has lapsed, or concurrent edit).

While blocked, no edit is lost: sync keeps its reference point and applies the whole difference once it can run.

Details

The popover shows the last report:

  • Updated, Added, Removed: the subjects sync touched;
  • Degraded: blank-node structures replaced as a whole;
  • Missing: subjects sync wanted to remove or change but could not find, because you already edited them in the Turtle (skipped);
  • the number of non-Dolfin statements kept.

Undo last sync

Undo last sync restores the Turtle as it was before the last sync, and survives a restart. It is refused if you edited the Turtle by hand since, or if it was already used.

Undo changes only the Turtle: the Dolfin edits that were synced stay. Turtle and Dolfin then differ until you change those declarations again or use Re-translate. Later edits sync normally.

If the Turtle is open while sync writes

If someone has the Turtle open, sync edits it as normal text operations, so other people’s cursors and selections are not disturbed. If the text changed under it, sync retries once and then reports error: concurrent edit.

Choosing the source in requests

The sync status, Undo last sync and Re-translate server functions take an optional file_id: the .ttl file id of the source to act on. Without it they act on the project’s only source. In a project with several sources, leaving it out is an error (this project has N Turtle sources: say which one).