Design

Fourth iteration

Items with Revisions are stored in mercurial's internal directory .hg. Operations on Items are done in memory, utilizing new mercurial features: memchangectx and memfilectx, which allow easy manipulation of changesets without the need of working copy. Advantage is less I/O operations.

Revision data before commit is also stored in memory using StringIO. While this is good for small Items, bigger ones that don't fit into memory will fail.

Revision metadata is stored in mercurial internally, using dictionary bound to each changeset: extra. This gives cleaner code, and mercurial stores this in optimal way itself.

Item Metadata is not versioned and stored in separate directory.

This implementation does not identify Items internally by name. Instead Items have unique ID's which are currently MD5 hashes. Name-to-id translation is stored in name-mapping file. This mapping is text file to allow merging it on repository synchronization. Hashes are computed from Item's name, current timestamp and random integer.

Renames are done by relinking name with hash. Item does not move itself in hg. Thus 'hg rename' is not used, and renames won't be possible 'on console' without providing dedicated hg extensions.

Repository layout

    data/
    +-- rev/
        +-- .hg/
        +-- .name-mapping
        +-- 0f4eac723857aa118122c08f534fcf56 (after hg update)
        +-- 4c4712a4141d261ec0ca8f9037950685 (after hg update)
        +-- ...
    +-- meta/
        +-- 0f4eac723857aa118122c08f534fcf56.meta
        +-- 4c4712a4141d261ec0ca8f9037950685.meta
        +-- ...
    +-- cache/
        +-- 0f4eac723857aa118122c08f534fcf56.cache
        +-- 4c4712a4141d261ec0ca8f9037950685.cache
        +-- ...

Prerequisites

This backend uses development version of mercurial (077f1e637cd8 from http://selenic.com/repo/hg). Because there is a feature imposed by API, that current iteration can not overcome, mercurial must pe patched.

This feature is: multiple empty revisions in a row. Currently, Item revisions are stored as file revisions. And to store subsequent empty revisions, we have to force mercurial make filelog records with empty data.

Patch for that behaviour can be found in source tree, MoinMoin/storage/backends/research/repo_force_changes.diff

Limitations

Known broken

Current problems

This problems lead to antoher iteration planned after SOC.


CategoryGsocProject

MoinMoin: PawelPacana/MercurialBackend2008 (last edited 2012-06-01 07:57:08 by EugeneSyromyatnikov)