299
299
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302
Caching and writeing of data
303
============================
305
Repositories try to provide a consistent view of the data within them
306
within a 'lock context'.
311
Locks come in two flavours - read locks and write locks. Read locks allow
312
data to be read from the repository. Write locks allow data to be read and
313
signal that you intend to write data at some point. The actual writing of
314
data must take place within a Write Group.
316
Write locks provide a cache of repository data during the period of the
317
write lock, and allow write_groups to be acquired. For some repositories
318
the presence of a write lock is exclusive to a single client, for others
319
which are lock free or use server side locks (e.g. svn), the write lock
320
simply provides the cache context.
325
Write groups are the only allowed means for inserting data into a
326
repository. These are created by ``start_write_group``, and concluded by
327
either ``commit_write_group`` or ``abort_write_group``. A write lock must
328
be held on the repository for the entire duration. At most one write
329
group can be active on a repository at a time.
331
Write groups signal to the repository the window during which data is
332
actively being inserted. Several write groups could be committed during a
335
There is no guarantee that data inserted during a write group will be
336
invisible in the repository if the write group is not committed.
337
Specifically repositories without atomic insertion facilities will be
338
writing data as it is inserted within the write group, and may not be able
339
to revert that data - e.g. in the event of a dropped SFTP connection in a
340
knit repository, inserted file data will be visible in the repository. Some
341
repositories have an atomic insertion facility, and for those
342
all-or-nothing will apply.
344
The precise meaning of a write group is format specific. For instance a
345
knit based repository treats the write group methods as dummy calls,
346
simply meeting the api that clients will use. A pack based repository will
347
open a new pack container at the start of a write group, and rename it
348
into place at commit time.