Next: Darcs commands Up: Darcs 2.2.0 (release) Darcs Previous: Best practices Contents
Subsections

- Introduction
- Darcs 1 format
- Hashed format
- Darcs 2 format

# Repository formats

# Introduction

Darcs 2 introduces a couple of new repository formats and this chapter is intended to serve as brief introduction to them and as an overview of inter-operation between them.

# Darcs 1 format

Darcs 1 format is the only format supported by 1.0.x versions of darcs. Darcs 2 is capable of entirely interacting with darcs 1 format and still defaults to darcs 1 format, but to take full advantage of new capabilities of darcs 2 it be will necessary to upgrade to the newer formats.

`old-fashioned-inventory` is now deprecated and should be avoided if at all possible.

# Hashed format

Hashed repository format is an intermediate format that interoperates well with darcs 1 repositories. Darcs 2 can push/pull between darcs 1 format and hashed format repositories and can easily convert from one to the other. Among its benefits, one of the most user obvious changes is that the hashed format provides a more robust pristine format, that is less susceptible to corruption from IDEs and automated tools. It also enables the use of a global patch cache (see the Best Practices section for more).

Hashed format is recommend for all repositories used with darcs 2 that need to interoperate with darcs 1 branches or darcs 1 developers.

To convert an existing darcs 1 repository to hashed format simply `get` a new copy with the hashed flag:

    $ darcs get --hashed old-repo new-repo

`hashed` Offers several features while still being compatible with old-fashioned repositories. The specific features are:

- The hashed format allows for greater atomicity of operations. This makes for greater safety and simultaneously greater efficiency. These benefits, however, have not been fully realized in this release. For instance, with a hashed repository, there is no need for darcs push to require a repository lock, so you could record patches while waiting for a push to finish (for instance, if it's waiting on the test suite).

- The `_darcs/pristine` directory no longer holds the pristine cache. This disallows certain hackish short-cuts, but also dramatically reduces the danger of third-party programs (e.g. DreamWeaver) recursing into the pristine cache and corrupting darcs repositories.

- Darcs get can optionally operate in a much faster ``lazy'' fashion, meaning that patches are downloaded only when they are needed. This gives us much of the benefits of -partial repositories, without most of their disadvantages. This approach, however, does have several new dangers. First, some operations may unexpectedly require the download of large numbers of patches, which could be slow (but you could always interrupt with `^C`). Secondly, if the source repository disappears, or you lose network connectivity, some operations may fail.

- Darcs now supports caching of patches and file contents to reduce bandwidth and save disk space. It greatly speeds up a number of operations, and is essentially transparent.

# Darcs 2 format

Darcs 2 format is the successor to darcs 1 format. It makes use of the various improvements of the hashed repository format, with additional benefits including an increased efficiency and robustness when dealing with conflicting patches.

Darcs 2 format is recommended for projects that do not need to interoperate with darcs 1 repositories or developers with versions of darcs less than 2.0.0 installed.

Initialize a new repository in darcs 2 format:

    $ darcs init --darcs-2

Projects in darcs 1 format ready to move all development to darcs 2 can convert an existing repository to darcs 2 format. This should be done only once per family tree of related repositories, as converting each branch separately may result in inter-repository corruption that can lead to subtle and hard to diagnose problems when attempting to exchange patches between seperately converted repositories. The recommendation is to convert the branch of a project with the largest superset of patches in the project and then recreate the branches from this superset repository via `darcs get`, particularly with the usage of its selection flags such as `--context`, `--tag` and `--to-match`, and `darcs obliterate`, which can be used to interactively remove patches that are not intended in the recreated branch.

The command for conversion:

    $ darcs convert d1repo d2repo

`darcs-2` Is the default. It enables all available features, and requiring that all repos for a project use the same format. In addition to the features of the `hashed` format described above, the `darcs-2` format also enables the following:

- It should no longer be possible to confuse darcs or freeze it indefinitely by merging conflicting changes.

- Identical primitive changes no longer conflict. This is a long-requested feature, and has far-reaching implications.

Next: Darcs commands Up: Darcs 2.2.0 (release) Darcs Previous: Best practices Contents