next_inactive up previous


Darcs 0.9.12
David's advanced revision control system

David Roundy


Contents

Introduction

Darcs is a revision control system, along the lines of CVS or arch. That means that it keeps track of various revisions and branches of your project, allows for changes to propogate from one branch to another. Darcs is intended to be an ``advanced'' revision control system. Darcs has two particularly distinctive features which differ from other revision control systems: 1) each copy of the source is a fully functional branch, and 2) underlying darcs is a consistent and powerful theory of patches.

Every source tree a branch

The primary simplifying notion of darcs is that every copy of your source code is a full repository. This is dramatically different from CVS, in which the normal usage is for there to be one central repository from which source code will be checked out. It is closer to the notion of arch, since the `normal' use of arch is for each developer to create his own repository. However, darcs makes it even easier, since simply checking out the code is all it takes to create a new repository. This has several advantages, since you can harness the full power of darcs in any scratch copy of your code, without committing your possibly destabilizing changes to a central repository.

Theory of patches

The development of a simplified theory of patches is what originally motivated me to create darcs. This patch formalism means that darcs patches have a set of properties, which make possible manipulations that couldn't be done in other revision control systems. First, every patch is invertible. Secondly, sequential patches (i.e. patches that are created in sequence, one after the other) can be reordered, although this reordering can fail, which means the second patch is dependent on the first. Thirdly, patches which are in parallel (i.e. both patches were created by modifying identical trees) can be merged, and the result of a set of merges is independent of the order in which the merges are performed. This last property is critical to darcs' philosophy, as it means that a particular version of a source tree is fully defined by the list of patches that are in it. i.e. there is no issue regarding the order in which merges are performed. For a more thorough discussion of darcs' theory of patches, see Appendix A.

A simple advanced tool

Besides being ``advanced'' as discussed above, darcs is actually also quite simple. Versioning tools can be seen as three layers. At the foundation is the ability to manipulate changes. On top of that must be placed some kind of database system to keep track of the changes. Finally, at the very top is some some sort of distribution system for getting changes from one place to another.

Really, only the first of these three layers is of particular interest to me, so the other two are done as simply as possible. At the database layer, darcs just has an ordered list of patches along with the patches themselves, each stored as an individual file. Darcs' distribution system is strongly inspired by that of arch. Like arch, darcs uses a dumb server, typically apache or just a local or network file system. Unlike arch, darcs currently has no write ability to a remote file system. This means that darcs currently only supports for ``pulling'' of patches from a remote repository to a local one, but not ``pushing'' of patches. While this does simplify matters by eliminating issues of user permissions, it isn't really adequate, as it doesn't address the needs of users who lack a server with a permanent net connection to host their repositories. I do have plans for supporting a push mechanism (which, by the way will be accelerated if I hear there is a demand for such a thing, as I personally have no use for it).

Keeping track of changes rather than versions

In the last paragraph, I explained revision control systems in terms of three layers. One can also look at them as having two distinct uses. One is to provide a history of previous versions. The other is to keep track of changes that are made to the repository, and to allow these changes to be merged and moved from one repository to another. These two uses are distinct, and almost orthogonal, in the sense that a tool can support one of the two uses optimally while providing no support for the other. Darcs is not intended to maintain a history of versions, although it is possible to kludge together such a revision history, either by making each new patch depend on all previous patches, or by tagging regularly. In a sense, this is what the tag feature is for, but the intention is that tagging will be used only to mark particularly notable versions (e.g. released versions, or perhaps versions that pass a time consuming test suite).

As I understand them (and I certainly may be wrong), previous revision control systems originated with their purpose being to keep track of a history of versions, with the ability to merge changes being added as it was seen that this would be desirable. But the fundamental object remained the versions themselves.

In such a system, a patch (I am using patch here to mean an encapsulated set of changes) is uniquely determined by two trees. Merging changes that are in two trees consists of finding a common parent tree, computing the diffs of each tree with their parent, and then cleverly combining those two diffs and applying the combined diff to the parent tree, possibly at some point in the process allowing human intervention, to allow for fixing up problems in the merge such as conflicts.

Finding this parent tree poses problems. This is where DAGs (Directed Acyclic Graphs) come in. A DAG is a convenient way to assure that two trees (tree here meaning a source tree) have just one closest parent. This means that need keep track of the relationships of the trees, a most imposing task, as the number of trees becomes large! It also may put an artificial constraint on the users, by not allowing them to create cyclic loops of relationships between their versions. Since I don't particularly understand these DAGs (or, for that matter, other revision control systems), I'll leave it here and just trust those who have gone before me that they are difficult.

In the world of darcs, the source tree is not the fundamental object, but rather the patch is the fundamental object. Rather than a patch being defined in terms of the difference between two trees, a tree is defined as the result of applying a given set of patches to an empty tree. Moreover, these patches may be reordered (unless there are dependencies between the patches involved) without changing the tree. Thus there is no need to find a common parent when performing a merge. Or, if you like, their common parent is defined by the set of common patches, and may not correspond to any version in the version history (if we kept track of a history).

One useful consequence of darcs' patch-oriented philosophy is that since a patch need not be uniquely defined by a pair of trees (old and new), we can have several ways of representing the same change, which differ only in how they commute and what the result of merging them is. Of course, creating such a patch will require some sort of user input. This is a Good Thing, since the user creating the patch should be the one forced to think about what they really want to change, rather than the user merging the patch. An example of this is the token replace patch (See Section A.5). This feature make it possible to create a patch, for example, which changes every instance of the variable ``stupidly_named_var'' with ``better_var_name'', while leaving ``other_stupidly_named_var'' untouched. When this patch is merged with any other patch involving the ``stupidly_named_var'', that instance will also be modified to ``better_var_name''. This is in contrast to a more conventional merging method which would not only fail to change new instances of the variable, but would also involves conflicts when merging with any patch that modifies lines containing the variable. By more using additional information about the programmer's intent, darcs is thus able to make the process of changing a variable name the trivial task that it really is, which is really just a trivial search and replace, modulo tokenizing the code appropriately.

The patch formalism discussed in Appendix A is what makes darcs' approach possible. In order for a tree to consist of a set of patches, there must be a deterministic merge of any set patches, regardless of the order in which they must be merged. This requires that one be able to reorder patches. While I don't know that the patches are required to be invertible as well, my implementation certainly requires inveribility. In particular, invertibility is required to make use of Theorem 2, which is used extensively in the manipulation of merges.

To summarize, I believe that darcs has a solid theoretical foundation leagues beyond what anyone else has developed. On the down side, darcs is currently slow, possibly still buggy--certainly still buggy in its entirety, but I mean to say that its core may still be buggy. Moreover it is lacking an abundance of features. However, I believe that the theory behind darcs will be the foundation of the next generation of revision control system.

Building darcs

This chapter should walk you through the steps necesary to build darcs for yourself. There are in general two ways to build darcs. One is for building released versions from tarballs, and the other is to build the latest and greatest darcs, from the darcs repo itself.

Please let me know if you have any problems building darcs, or don't have problems described in this chapter and think there's something obsolete here, so I can keep this page up-to-date.

Prerequisites

To build darcs you will need to have ghc, the Glorious Glasgow Haskell Compiler. You should have at the very minimum version 5.04.2, but I myself only test it with 5.04.3. There are plans to phase out support for ghc5, so moving up to 6.0 is a good idea.

It is a good idea (but not required) to have a recent version of libcurl installed. If not, you will at least need to have either wget or curl installed if you want to be able to grab repos remotely over normal network protocols (ftp or http). You also might want to have scp available if you want to grab your repos over ssh...

To push patches, you will also need to have a working /usr/bin/sendmail, which is provided by most mail programs, and is generally available on linux and BSD systems. It's also there on MacOS X. However, if you don't have this, it won't stop you from building darcs.

To build the documentation (which isn't really necesary, it's included in html form with the tarballs), you will need to have latex installed, and latex2html if you want to build it in html form.

Building on MacOS X

To build on MacOS X, you will need the Apple Developer Tools and the ghc 6.0 package installed. There seems to be a problem with ghc and Apple's gcc 3.3, so you may need to run
% sudo gcc_select 3.1
to avoid crashes. I have also had to run autoconf once when the configure script failed.

Building on Microsoft Windows

I don't have Windows and don't know how to build darcs on it. It has been done, but I may have broken it recently... If you try building darcs on windows, whether you succeed or fail, please post on the darcs-users mailing list so we'll know how it went.

Building from tarball

If you get darcs from a tarball, the procedure (after unpacking the tarball itself) is as follows:
% ./configure
% make
% make install

There are options to configure that you may want to check out with

% ./configure --help

Building darcs from the repository

To build the latest darcs from its repository, you will first need a working copy of darcs. You can get darcs using:
% darcs get -v http://abridgegame.org/repos/darcs
and once you have the darcs repository you can bring it up to date with a
% darcs pull

The repository doesn't hold automatically generated files, which include the configure script and the HTML documentation. The documentation you can do without, but the configure script you have to generate using

% autoconf
Of course, this means you'll need to have autoconf installed.

After this the build process is the same as in the tarball case:

% ./configure
% make
% make install

Submitting patches to darcs

I know, this doesn't really belong in this chapter, but if you're using the repository version of darcs it's really easy to submit patches to me using darcs. In fact, even if you don't know any haskell, you could submit fixes or additions to this document (by editing building_darcs.tex) based on your experience building darcs...

To do so, just record your changes (which you made in the darcs repository)

% darcs record --no-test
making sure to give the patch a nice descriptive name. The --no-test options keeps darcs from trying to run the unit tests, which can be rather time-consuming. Then you can send the patch to me via email by
% darcs push
The darcs repository stores the email address to which patches should be pushed by default.

Getting started

This chapter will lead you through an example use of darcs, which hopefully will allow you to get started using darcs with your project.

Creating your repository

Creating your repository in the first place just involves telling darcs to create the special directory (called _darcs) in your project tree, which will hold the revision information. This is done my simply calling from the root directory of your project:

% cd my_project/
% darcs inittree
This creates the _darcs directory and populates it with whatever files and directories are needed to describe an empty project. You now need to tell darcs what files and directories in your project should be under revision control. You do this using the command darcs add:
% darcs add *.c Makefile.am configure.in
When you have added all your files (or at least, think you have), you will want to record your changes. ``Recording'' always includes adding a note as to why the change was made, or what it does. In this case, we'll just note that this is the initial version.
% darcs record --all
What is the patch name? Initial revision.
Note that since we didn't specify a patch name on the command line we were prompted for one. If the environment variable `EMAIL' isn't set, you will also be prompted for your email address. Each patch that is recorded is given a unique identifier consisting of the patch name, its creator's email address, and the date when it was created.

Making changes

Now that we have created our repository, make a change to one or more of your files. After making the modification run:

% darcs whatsnew
This should show you the modifications that you just made, in the darcs patch format. If you prefer to see your changes in a different format, read Section 4.4, which describs the whats-new command in detail.

Let's say you have now made a change to your project. The next thing to do is to record a patch. Recording a patch consists of grouping together a set of related changes, and giving them a name. It also tags the patch with the date it was recorded and your email address.

To record a patch simply type:

% darcs record
darcs will then prompt you with all the changes that you have made that have not yet been recorded, asking you which ones you want to include in the new patch. Finally, darcs will ask you for a name for the patch.

You can now rerun whatsnew, and see that indeed the changes you have recorded are no longer marked as new.

Making your repository visible to others

How do you let the world know about these wonderful changes? Obviously, they must be able to see your repository. Currently the easiest way to do this is typically by http using any web server. The recommended way to do this (using apache in a UNIX environment) is to create a directory called /var/www/repos, and then put a symlink to your repo there.

As long as you're running a web browser and making your repo available to the world, you may as well make it easy for people to see what changes you've made. You can do this by running make installserver, which installs the program darcs_cgi at /usr/lib/cgi-bin/darcs. You also will need to create a cache directory named /var/cache/darcs_cgi, and make sure the owner of that directory is the same user that your web browser runs as its cgi scripts as. For me, this is www-data. Now your friends and enemies should be able to easily browse your repos by pointing their web browsers at http://your.server.org/cgi-bin/darcs. You can read more about this interface in Chapter 5.

Getting changes made to another repository

Ok, so I can now browse your repository using their web browsers...so what? How do I get your changes into my repository, where they can do some good? It couldn't be easier. I just cd into my repository, and there type:
% darcs pull http://your.server.org/repos/yourproject
Darcs will check to see if you have recorded any changes that aren't in my current repository. If so, it'll prompt me for each one, to see which ones I want to add to my repository. Note that you may see a different series of prompts depending your answers, since sometimes one patch depends on another, so if you answer yes to the first one, you won't be prompted for the second if the first depends on it.

Of course, maybe I don't even have a copy of your repository. In that case I'd want to do a

% darcs get --verbose http://your.server.org/repos/yourproject
which gets the whole repo.

Creating a pushable repository

The darcs patcher (for a few more details see Chapter 6) is a program that allows you to set up a repository to which you can remotely ``push'' patches. Although this isn't necesary to use darcs, it can be useful if you want to give more than one person write access to a repository, or if you do much of your work using a computer on which it is not convenient to run a web server. The patcher receives patches via cryptographically signed email. For each repository you create on a machine a user is created which determines the email address for that repository. Alas, the patcher is considerably harder to set up than darcs itself, which is why this section of the manual is here.

Installing necesary programs

To install the patcher program, you can either install the ``darcs-server'' package (via debian or whatever), or run ``make installserver''. This hopefully will put the programs in the right places.

To use a pushable repository, you also must install the following programs: sudo, gnupg, a mailer configured to receive mail (e.g. exim, sendmail or postfix), and a web server (usually apache). If you want to be able to browse your repository via the web you must also configure your web server to run cgi scripts and make sure the darcs cgi script was properly installed.

Setting up a repository

To create a repository, as root run the `darcs-createrepo'. You will be prompted for the email address of the repository and the location of an existing copy of the repository. If your desired email is ``myproject@my.url'', this will create a user named ``myproject'' with a home directory of /var/lib/darcs/repos/myproject. FIXME: I have no idea if the darcs-createrepo program will even run on any system other than debian. Success reports would be appreciated (or of course bug reports if it fails).

The ``myproject'' user will be configured to run the darcs patcher on any emails it receives. However, the patcher will bounce any emails which aren't signed by a key in the /var/lib/darcs/repos/myproject/allowed_keys gpg keyring (which is empty). To give yourself access to this repository you will need to create a gpg key. If you don't know about public key cryptography, take a look at the gnupg manual.

Granting access to a repository

You create your gpg key by running (as your normal user):

% gpg --gen-key
You will be prompted for your name and email address, among other options. To add your public key to the allowed keys keyring. Of course, you can skip this step if you already have a gpg key you wish to use.

You now need to export the public key so we can tell the patcher about it. You can do this will the following comman (again as your normal user):

% gpg --export "email@address" > /tmp/exported_key
And now we can add your key to the allowed_keys:
(as root)> gpg --keyring /var/lib/darcs/repos/myproject/allowed_keys \
               --no-default-keyring --import /tmp/exported_key
You can repeat this process any number of times to authorize multiple users to push to the repository.

You should now be able to push a patch to the repository by running as your normal user, in a working copy of the repository:

% darcs push --sign http://your.computer/repos/myproject
You may want to add ``push sign'' to the file _darcs/prefs/defaults so that you won't need to type --sign every time you want to push...

Darcs commands

The general format of a darcs command is

% darcs COMMAND OPTIONS ARGUMENTS ...
Here COMMAND is a command such as add or record, which of course may have one or more arguments. Options have the form --option or -o, while arguments vary from command to command. There are many options which are common to a number of different commands, which will be summarized here.

Every COMMAND accepts --help as an argument, which tells it to provide a bit of help. Among other things, this help always provides an accurate listing of the options available with that command, and is therefore frequently useful as a supplement to the somewhat spartan help given in this manual.

% darcs COMMAND --help

Most commands also accept the --verbose option, which tells darcs to provide additional output. The amount of verbosity varies from command to command.

Darcs optimizes its operations by keeping track of the modification times of your files. This dramatically speeds up commands such as whatsnew and record which would otherwise require reading every file in the repo and comparing it with a reference version. However, there are times when this can cause problems, such as when running a series of darcs commands from a script, in which case often a file will be modified twice in the same second, which can lead to the second modification going unnoticed. The solution to such predicaments is the --ignore-times option, which instructs darcs not to trust the file modification times, but instead to check each file's contents explicitely.

Several commands need to be able to identify you. Conventionally, you provide an email address for this purpose. The easiest way to do this is to define an environment variable EMAIL or DARCS_EMAIL (with the latter overriding the former). You can also override this using the --author flag to any command. Alternatively, you could set your email address on a per-repository basis using the ``defaults'' mechanism for ``ALL'' commands, as described in Appendix B.

Calling darcs with just ``-help'' as an argument gives a brief summary of what commands are available. Calling darcs with the flag ``-version'' tells you the version of darcs you are using. Similarly calling darcs with only ``-commands'' gives a simple list of available commands. This latter arrangement is primarily intended for the use of command-line autocompletion facilities, as are available in bash.

darcs inittree

-v --verbose give verbose output

Initialize a new source tree as a darcs repository.

Generally you will only call inittree once for each project you work on, and calling it is just about the first thing you do. Just make sure you are in the main directory of the project, and inittree will set up all the directories and files darcs needs in order to start keeping track of revisions for your project.

inittree actually follows a very simple procedure. It simply creates the directories _darcs, _darcs/current and _darcs/patches, and then creates an empty file, _darcs/inventory. However, it is strongly recommended that you use darcs inittree to do this, as this procedure may change in a future version of darcs.

darcs add

-v --verbose give verbose output
  --boring don't skip boring files
  --case-ok don't refuse to add files differing only in case
-r --recursive add contents of subdirectories

Add needs to be called whenever you add a new file or directory to your project. Of course, it also needs to be called when you first create the project, to let darcs know which files should be kept track of.

Darcs will refuse to add a file or directory that differs from an existing one only in case. This is because the HFS+ file system used on under MacOS treats such files as being one and the same.

darcs remove

-v --verbose give verbose output

Remove should be called when you want to remove a file from your project, but don't actually want to delete the file. Otherwise just delete the file or directory, and darcs will notice that it has been removed.


darcs whatsnew

-v --verbose give verbose output
  --ignore-times don't trust the file modification times

Display unrecorded changes in the working directory.

What's-new gives you a view of what changes you've made in your working directory that haven't yet been recorded. The changes are displayed in darcs patch format. Darcs whatsnew will return a non-zero value if there are no changes, which can be useful if you just want to see in a script if anything has been modified. FIXME: If I feel motivated, I may create options for different (possibly more user-friendly) views, such as a unidiff view.

darcs check

-v --verbose give verbose output
  --no-test don't run the test script

Check the repository for consistency.

Check verifies that the patches stored in the repository, when successively applied to an empty tree, properly recreate the stored current tree.

If you like, you can configure your repository to be able to run a test suite of some sort. There are two ways you can do this. One is to use ``setpref'' to set the ``test'' value to be a command to run. e.g.

% darcs setpref test "sh configure && make && make test"

Alternatively, you can add to your repo a file called darcs_test. Darcs will recognize this, and make it executable and run it as a test script. Typically you would make darcs_test a simple script that compiles your project and possibly runs a test suite. You should make sure that your darcs_test returns an error code indicating either success or failure so darcs will know whether or not the code worked.

If you just want to check the consistency of your repository without running the test, you can call darcs check with the --no-test option.

darcs record

-m --patch-name PATCHNAME name of patch
-A --author EMAIL specify author id
-v --verbose give verbose output
  --no-test don't run the test script
-a --all answer yes to all patches
  --ask-deps ask about dependencies
  --ignore-times don't trust the file modification times

Record is used to name a set of changes and record the patch to the repository. Each patch is given a name, which typically would consist of a brief description of the changes. This name is later used to describe the patch. The name must fit on one line (i.e. cannot have any embedded newlines). If you have more to say, stick it in the log. (FIXME: Currently recording a patch deletes any pending changes that aren't included in the recorded patch. This is clearly a bug, but is a bit tedious to fix.) The patch is also flagged with the author of the change, taken by default from the DARCS_EMAIL environment variable, and if that doesn't exist, from the EMAIL environment variable. The date on which the patch was recorded is also included. Currently there is no provision for keeping track of when a patch enters a given repository. Finally, each changeset should have a full log (which may be empty). This log is for detailed notes which are too lengthy to fit in the name. If you answer that you do want to create a comment file, darcs will open an editor so that you can enter the comment in. The choice of editor proceeds as follows. If one of the $DARCSEDITOR, $VISUAL or $EDITOR environment variables is defined, its value is used (with precedence proceeding in the order listed). If not, ``vi'', ``emacs'', ``emacs -nw'' and ``nano'' are tried in that order.

Each patch may depend on any number of previous patches. If you choose to make your patch depend on a previous patch, that patch is required to be applied before your patch can be applied to a repo. This can be used, for example, if a piece of code requires that a function be defined, which has was defined in an earlier patch.

If you want to manually define any dependencies for your patch, you can use the --ask-deps flag, and darcs will ask you for the patch's dependencies.

FIXME: Change this code to use the Readline module so arrow keys, etc, will work properly for entering in the text.

If you configure darcs to run a test suite, darcs will run this test on the recorded repo to make sure it is valid. Darcs first creates a pristine copy of the source tree (in /tmp), then it runs the test, using its return value to decide if the record is valid. If it is not valid, the record will be aborted. This is a handy way to avoid making stupid mistakes like forgetting to `darcs add' a new file. It also can be tediously slow, so there is an option (--no-test) to skip the test.

darcs get

-o --repo-name REPONAME name of output repository
-t --tag-name TAGNAME name of version to pull
-m --patch-name PATCHNAME name of patch
-v --verbose give verbose output

Get is used to get a local copy of a repository. I recommend using the --verbose flag to get, as this command can take a while, and with no feedback, that can be rather boring.

If the remote repo and the current directory are in the same filesystem and that filesystem supports hard links, get will create hard links for the patch files, which means that the additional storage space needed will be minimal. This shouldn't cause any problems as darcs usually never modifies a patch file, and if it does it deletes the old file and creates a new file, which should mean that it won't affect the other repo which shares the same patch file.

If you want to get a specific version of a repository, you have a couple of options. The first is to use the --tag-name option, which allows you to specify a specific version of the repository by its tag, and get precisely that version. The argument is a regular expression, and get will grab the most recent tag which matches that regular expression. The other option is the --patch-name option, which will allow you to get that patch (i.e. the most recent one matching the specified regular expression) and all older patches. Note that when specifying a --patch-name, you may get a version of your code that has never before been seen, if the patches have gotten themselves reordered. If you ever want to be able to precisely reproduce a given version, you need to tag it.

darcs pull

-v --verbose give verbose output
-m --patch-name PATCHNAME name of patch
-a --all answer yes to all patches
  --ignore-times don't trust the file modification times
  --no-deps don't automatically fulfill dependencies

Pull is used to bring changes made in another repo into the current repo (that is, the one that is the current directory). Pull allows you to bring over all or some of the patches that are in that repo but not in the current one.

When called without a repository argument, pull will use the most recent repository that was either pushed to or pulled from.

The --patch-name argument can be used to specify a regexp, which should be of the extended type used by egrep. If this option is used, only patches which match this regexp (along with their dependencies) are considered.

If you give a --patch-name argument, darcs will silently pull along any other patches upon which the patches which match the patch-name depend. So --patch-name bugfix mean ``pull all the patches with `bugfix' in their name, along with any patches they require.'' If you really only want the patches with `bugfix' in their name, you should use the --no-deps option, which is only useful in combination with --patch-name, and makes darcs only pull in those matching patches which have no dependencies (apart from other matching patches).

darcs push

-v --verbose give verbose output
-m --patch-name PATCHNAME name of patch
-a --all answer yes to all patches
-A --author EMAIL specify author id
-t --to EMAIL specify destination email
-o --output FILE specify output filename
-s --sign sign the patch with your gpg key
  --edit-description edit the patch bundle description

Push is used to prepare a bundle of patches to send to another repository.

When called without a repository argument, pull will use the most recent repository that was either pushed to or pulled from.

The --output and --email flags determine what darcs does with the patch bundle after creating it. If you provide an --output argument, the patch bundle is saved to that file. If you give an --email argument, the bundle of patches is emailed to that person. If you don't provide either, darcs will prompt you for an email recipient.

The --patchname argument can be used to specify a regexp, which should be of the extended type used by egrep. If this option is used, only patches which match this regexp (along with their dependencies) are considered for pushing.

If you want to include a description or explanation along with the bundle of patches, you need to specify the --edit-description flag, which will cause darcs to open up an editor with which you can compose an email to go along with your patches.

darcs apply

-V --verify PUBRING verify that the patch was signed by a key in PUBRING
-v --verbose give verbose output
  --ignore-times don't trust the file modification times
  --no-resolve-conflicts don't try to resolve conflicts
  --test run the test script

Apply is used to apply a bundle of patches to this repository. Such a bundle may be created using push.

If you specify the --verify PUBRING option, darcs will check that the patch was gpg-signed by a key which is in PUBRING.

darcs unrecord

-v --verbose give verbose output

Unrecord is used to undo a single recorded patch. It will prompt you for which patch to unrecord, and then will undo that patch. Note that unrecord doesn't affect your working copy of the tree at all, so if you want to completely undo the change, you'll also need to darcs revert, or do an unpull.

If you don't revert after unrecording, then the changes made by the unrecorded patches are left in your working tree. If these patches are actually from another repository, interaction (either pushes or pulls) with that repository may be massively slowed down, as darcs tries to cope with the fact that you appear to have made a large number of changes that conflict with those present on the other repository. So if you really want to undo the result of a pull operation, use unpull! Unrecord is primarily intended for when you record a patch, realize it needs just one more change, but would rather not have a separate patch for just that one change.

FIXME: The one major bug remaining is that unrecording a `darcs add' causes that add to be lost, while it really should just be stuck pack in `pending'.

darcs unpull

-v --verbose give verbose output

Unpull is used to undo a single patch that has been pulled from another repository. It will prompt you for which patch to unpull, and then will undo that patch. Beware that unpull undoes the patch both from the repo records AND from the current working directory, and does NOT check that the patch originated with a pull. In otherwords, you could lose precious code by unpulling!

darcs revert

-v --verbose give verbose output
  --ignore-times don't trust the file modification times
-a --all answer yes to all patches

Revert is used to undo changes make to the local tree which have not yet been recorded. You will be prompted for which changes you wish to undo. Please be cautious with revert, as there is no way to unrevert. Although I could store an unrevert patch somewhere, if there is demand for such a feature...

darcs dist

-d --dist-name DISTNAME name of version
-v --verbose give verbose output

Create a distribution tarball.

Dist is a handy tool for implementing a ``make dist'' target in your makefile. It creates a tarball of the recorded edition of your tree. Basically, you will typically use it via a makefile rule such as

dist:
    ./darcs dist --dist-name darcs-`./darcs --version`
darcs dist then simply creates a clean copy of the source tree, which it then tars and gzips. If you use programs such as autoconf or automake, you really should run them on the clean tree before tarring it up and distributing it. You can do this using the pref value ``predist'', which is a shell command that is run prior to tarring up the distribution:
% darcs setpref predist "autoconf && automake"

darcs mv

-v --verbose give verbose output

Darcs mv needs to be called whenever you want to rename or move a file or directory. Unlike remove, mv actually performs the move itself in your working directory. This is why ``mv'' isn't called ``move'', since it is really almost equivalent to the unix command ``mv''. I could add an equivalent command named ``move'' for those who like vowels.

darcs replace

-v --verbose give verbose output

Replace allows you to change a specified token whereever it occurs in the specified files. Tokens here are defined by a regexp specifying the characters which are allowed. By default a token corresponds to a C identifier. FIXME: Currently there is no way to specify a different regexp (other than [A-Za-z_0-9]) to be used for a token replace. Actually, if one of your tokens contains a `-' or `.', you will then get the ``filename'' regexp, which is [A-Za-z_0-9\-\.].

darcs tag

-m --patch-name PATCHNAME name of patch
-A --author EMAIL specify author id
-v --verbose give verbose output

Tag is used to name a version of the tree. Tag differs from record in that it doesn't record any new changes, and it always depends on all patches residing in the repository when it is tagged. This means that one can later reproduce this version of the repository by calling, for example:

% darcs get --tag-name "darcs 3.14" REPOLOCATION

Each tagged version has a version name. The version is also flagged with the person who tagged it (taken by default from the `DARCS_EMAIL' or `EMAIL' environment variable. The date is also included in the version information.

A tagged version automatically depends on all patches in the repo. This allows you to later reproduce precisely that version. The tag does this by depending on all patches in the repo, except for those which are depended upon by other tags already in the repo. In the common case of a sequential series of tags, this means that the tag depends on all patches since the last tag, plut that tag itself.

darcs diff

-t --tag-name TAGNAME name of version to pull
-m --patch-name PATCHNAME name of patch

Diff can be used to create a diff between two versions which are in your repository.

Diff calls an external ``diff'' command to do the actual work, and passes any unrecognized flags to this diff command. Thus you can call

% darcs diff -t 0.9.8 -t 0.9.10 -- -u
to get a diff in the unified format. Actually, thanks to the wonders of getopt you need the ``--'' shown above before any arguments to diff. FIXME: I probably should just bite the bullet and figure out how to get diff flags passed through properly. Any hints from getopt gurus would be appreciated.

FIXME: I should allow the user to specify the external diff command. Currently it is hardwired to /usr/bin/diff.

darcs setpref

Usage example:

% darcs setpref test "echo I am not really testing anything."

Setpref allows you to set a preferences value in a way that will propogate to other repositories. If you just want to set the pref value in your repository only, you can just edit ``_darcs/prefs/prefs''. Changes you make in that file will be preserved.

The ``_darcs/prefs/prefs'' holds the only preferences information that can propogate between repositories via pushes and pulls, and the only way this happens is when the setprefs command is used. Note that although prefs settings are included in patches, they are not fully version controlled. In particular, depending on the order in which a series of merges is perform, you may end up with a different final prefs configuration. In practice I don't expect this to be a problem, as the prefs usually won't be changed very often.

The following values are valid preferences options which can be configured using setpref:


Web interface

The darcs web interface allows you to conveniently browse the information stored in a repository. You can view the repo by file and see the history of that file as various patches were applied, or you can browse in patch view mode, seeing which files were modified in each patch.

The darcs_cgi cgi script allows you to browse changes made in your darcs repository via the web. To use it with apache, you can install it using make installserver, and create a cache directory at /var/cache/darcs_cgi. This cache directory must be writeable by the cgi script, which for me means chowning it to the user and group www-data Finally, you should create a directory named repos in /var/www, in which you will place symlinks to the repos themselves. Once all this is done, the user can the browse the repos at http://your.site/cgi-bin/darcs.

The repos directory is configurable via the configuration file /etc/darcs/cgi.conf. This file can contain comments (any line starting with a `#' char) and key value pairs with an equal sign in between. For example:

# This is an example for cgi.conf

# reposdir is the directory containing the repositories

reposdir = /var/www/repos

# cachedir is a directory writeable by www-data (or whatever user your cgi
# scripts run as) which is used to cache the web pages.

cachedir = /var/cache/darcs

The page, http://your.site/cgi-bin/darcs, displays a listing of all repos available on the server. From this page, the user can get to any available repository.

Clicking on a given repository will take you to the file view page of that repository, which shows a listing of all the files in the repo. This page also has a link to the patch view page, which is a bit more interesting.

In patch view mode, the web interface displays a listing of all the patches in the repo. Clicking on a patch gives a listing of all files that were in the repo at the time that patch was applied.

Clicking on one of the files shows the file contents, with added lines shown in green, and removed ones in red. To the left of each line is a small `+' and `-'. These are links to the patch which added or removed that line.


The Darcs Patcher

The darcs-patcher E-mail-based server allows you to (easily?) set up a centralized darcs repository to which multiple users can commit patches without giving those users accounts on the server machine. darcs-patcher authentication is performed using gnupg signatures. Users use darcs push --sign to email a signed patch to the repository. darcs-patcher verifies that the patch is signed by an authorized user. It then runs the darcs_test, if available, to make sure the patch doesn't break anything (in which case it would reject it), and applies the patch to the repo.

To use darcs-patcher, you first need to creat a user for its use (one user per repository, I'm afraid). In this user's home directory, create a repository named ``repo''. You have to be a bit careful when creating this repo since if you just run a darcs get on a local repository owned by a different user, darcs will use hard links for the patch files, which may not work since you won't have the right to change them later. This is a bug in darcs get (FIXME).

You next need to set up a gnupg keyring named allowed_keys in the .gnupg/ directory containing the gnupg public keys of all users authorized to commit to the repository. Finally, you create a .forward file containing the single line ``|/usr/sbin/darcs-patcher'' (adjusted for where you actually install darcs-patcher), which tells your mailer to pipe any mail that user receives through darcs-patcher. Note also that darcs itself must reside in the system path.


Creating pushable repositories

A convenient utility called darcs-createrepo is provided to easily set up darcs-patcher-based repositories. This utility creates a new user and sets that user up to recieve and validate patches via email. Because darcs-createrepo must create a new user, it needs to be run as root. It will prompt you for all the information it needs.

darcs-createrepo creates a repo with no users having write privileges. Moreover, the allowed_keys file is created as root-owned, so only root will be able to add allowed users. You probably will want to chown this file to some administrative user. In any case, you'll need to add a few users' gpg keys to this file via gpg's --import or --recv-keys commands.


Theory of patches

Background

I think a little background on the author is in order. I am a physicist, and think like a physicist. The proofs and theorems given here are what I would call ``physicist'' proofs and theorems, which is to say that while the proofs may not be rigorous, they are practical, and the theorems are intended to give physical insight. It would be great to have a mathematician work on this, but I am not a mathematician, and don't care for math.

From the beginning of this theory, which originated as the result of a series of email discussions with Tom Lord, I have looked at patches as being analagous to the operators of quantum mechanics. I include in this appendix footnotes explaining the theory of patches in terms of the theory of quantum mechanics. I know that for most people this won't help at all, but many of my friends (and as I write this all three of darcs' users) are physicists, and this will be helpful to them. To nonphysicists, perhaps it will provide some insight into how at least this physicist things.

Introduction

A patch describes a change to the tree. It could be either a primitive patch (such as a file add/remove, a directory rename, or a hunk replacement within a file), or a compostive patch describing many such changes. Every patch type must satisfy the conditions described in this appendix. The theory of patches is independent of the data which the patches manipulate, which is what makes it both powerful and useful, as it provides a framework upon which one can build a revision control system in a sane manner.

Although in a sense, the defining property of any patch is that it can be applied to a certain tree, and thus make a certain change, this change does not wholly define the patch. A patch is defined by a representation, together with a set of rules for how it behaves (which it has in common with its patch type). The representation of a patch defines what that change that particular patch makes, and must be defined in the context of a specific tree. The theory of patches is a theory of the many ways one can change the representation of a patch to place it in the context of a different tree. The patch itself is not changed, since it describes a single change, which must be the same regardless of its representationA.1.

So how does one define a tree, or the context of a patch? The simplest way to define a tree is as the result of a series of patches applied to the empty treeA.2. Thus, the context of a patch consists of the set of patches that precede it.

The simplest relationship between two patches is that of ``sequential'' patches, which means that the context of the second patch (the one on the left) consists of the first patch (on the right) plus the context of the first patch. The composition of two patches (which is also a patch) refers to the patch which is formed by first applying one and then the other. The composition of two patches, $P_1$ and $P_2$ is represented as $P_2P_1$, where $P_1$ is to be applied first, then $P_2$A.3

There is one other very useful relationship that two patches can have, which is to be parallel patches, which means that the two patches have an identical context (i.e. their representation applies to identical trees). This is represented by $P_1\parallel P_2$. Of course, two patches may also have no simple relationship to one another. In that case, if you want to do something with them, you'll have to manipulate them with respect to other patches until they are either in sequence or in parallel.

The most fundamental and simple property of patches is that they must be invertible. The inverse of a patch is decribed by: $P^{ -1}$. In the darcs implementation, the inverse is required to be computable from knowledge of the patch only, without knowledge of its context, but that (although convenient) is not required by the theory of patches.

Definition 1   The inverse of patch $P$ is $P^{ -1}$, which is the ``simplest'' patch for which the composition \( P^{ -1} P \) makes no changes to the tree.

Using this definition, it is trivial to prove the following theorem relating to the inverse of a composition of two patches.

Theorem 1   The inverse of the composition of two patches is

\begin{displaymath}(P_2 P_1)^{ -1} = P_1^{ -1} P_2^{ -1}. \end{displaymath}

Moreover, it is possible to show that the right inverse of a patch is equal to its left inverse. In this respect, patches continue to be analagous to square matrices, and indeed the proofs relating to these properties of the inverse are entirely analagous to the proofs in the case of matrix multiplication. The compositions proofs can also readily be extended to the composition of more than two patches.

The first way (of only two) to change the context of a patch is by commutation, which is the process of changing the order of two sequential patches.

Definition 2   The commutation of patches $P_1$ and $P_2$ is represented by

\begin{displaymath}P_2 P_1 \longleftrightarrow {P_1}' {P_2}'. \end{displaymath}

Here $P_1'$ is intended to describe the same change as $P_1$, with the only difference being that $P_1'$ is applied after $P_2'$ rather than before $P_2$.

The above definition is obviously rather vague, the reason being that what is the ``same change'' has not been defined, and we simply assume (and hope) that the code's view of what is the ``same change'' will match those of its human users. The ` $\longleftrightarrow $' operator should be read as something like the $==$ operator in C, indicating that the right hand side performs identical changes to the left hand side, but the two patches are in reversed order. When read in this manner, it is clear that commutation must be a reversible process, and indeed this means that commutation can fail, and must fail in certain cases. For example, the creation and deletion of the same file cannot be commuted. When two patches fail to commute, it is said that the second patch depends on the first, meaning that it must have the first patch in its context (remembering that the context of a patch is a set of patches, which is how we represent a tree). A.4

Merge

The second way one can change the context of a patch is by a merge operation. A merge is an operation that takes two parallel patches and gives a pair of sequenctial patches. The merge operation is represented by the arrow `` \( \Longrightarrow \)''.

Definition 3   The result of a merge of two patches, $P_1$ and $P_2$ is one of two patches, $P_1'$ and $P_2'$, which satisfy the relationship:

\begin{displaymath}P_2 \parallel P_1 \Longrightarrow {P_2}' P_1 \longleftrightarrow {P_1}' P_2. \end{displaymath}

Note that the sequential patches resulting from a merge are required to commute. This is an important consideration, as without it most of the manipulations we would like to perform would not be possible. The other important fact is that a merge cannot fail. Naively, those two requirements seem contradictory. In reality, what it means is that the result of a merge may be a patch which is much more complex than any we have yet consideredA.5.

How merges are actually performed

The constraint that any two compatible patches (patches which can successfully be applied to the same tree) can be merged is actually quite difficult to apply. The above merge constraints also imply that the result of a series of merges must be independent of the order of the merges. So I'm putting a whole section here for the interested to see what algorithms I use to actually perform the merges (as this is pretty close to being the most difficult part of the code).

The first case is that in which the two merges don't actually conflict, but don't trivially merge either (e.g. hunk patches on the same file, where the line number has to be shifted as they are merged). This kind of merge can actually be very elegantly dealt with using only commutation and inversion.

There is a handy little theorem which is immensely useful when trying to merge two patches.

Theorem 2   $ P_2' P_1 \longleftrightarrow P_1' P_2 $ if and only if $ P_1'^{ -1}
P_2' \longleftrightarrow P_2 P_1^{ -1} $, provided both commutations succeed. If either commute fails, this theorem does not apply.

This can easily be proven by multiplying both sides of the first commutation by $P_1'^{ -1}$ on the left, and by $P_1^{ -1}$ on the right. Besides being used in merging, this theorem is also useful in the recursive commutations of mergers. From Theorem 2, we see that the merge of $P_1$ and $P_2'$ is simply the commutation of $P_2$ with $P_1^{ -1}$ (making sure to do the commutation the right way. Of course, if this commutation fails, the patches conflict. Moreover, one must check that the merged result actually commutes with $P_1$, as the theorem applies only when both commutations are successful.

Of couse, there are patches that actually conflict, meaning a merge where the two patches truly cannot both be applied (e.g. trying to create a file and a directory with the same name). We deal with this case by creating a special kind of patch to support the merge, which we will call a ``merger''. Basically, a merger is a patch that contains the two patches that conflicted, and instructs darcs basically to resolve the conflict. By construction a merger will satisfy the commutation property (see Definition 3) that characterizes all merges. Moreover the merger's properties are what makes the order of merges unimportant (which is a rather critical property for darcs as a whole).

The job of a merger is basically to undo the two conflicting patches, and then apply some sort of a ``resolution'' of the two instead. In the case of two conflicting hunks, this will look much like what CVS does, where it inserts both versions into the file. In general, of course, the two conflicting patches may both be mergers themselves, in which case the situation is considerably more complicated.

Much of the merger code depends on a routine which recreates from a single merger the entire sequence of patches which led up to that merger (this is, of course, assuming that this is the complicated general case of a merger of mergers of mergers). This ``unwind'' procedure is rather complicated, but absolutely critical to the merger code, as without it we wouldn't even be able to undo the effects of the patches involved in the merger, since we wouldn't know what patches were all involved in it.

Basically, unwind takes a merger such as

M( M(A,B), M(A,M(C,D)))
From which it recreates a merge history:
C
A
M(A,B)
M( M(A,B), M(A,M(C,D)))
(For the curious, yes I can easily unwind this merger in my head [and on paper can unwind insanely more complex mergers]--that's what comes of working for a few months on an algorithm.) Let's start with a simple unwinding. The merger M(A,B) simply means that two patches (A and B) conflicted, and of the two of them A is first in the history. The last two patches in the unwinding of any merger are always just this easy. So this unwinds to:
A
M(A,B)
What about a merger of mergers? How about M(A,M(C,D)). In this case we know the two most recent patches are:
A
M(A,M(C,D))
But obviously the unwinding isn't complete, since we don't yet see where C and D came from. In this case we take the unwinding of M(C,D) and drop its latest patch (which is M(C,D) itself) and place that at the beginning of our patch train:
C
A
M(A,M(C,D))
As we look at M( M(A,B), M(A,M(C,D))), we consider the unwindings of each of its subpatches:
          C
A         A
M(A,B)    M(A,M(C,D))
As we did with M(A,M(C,D)), we'll drop the first patch on the right and insert the first patch on the left. That moves us up to the two A's. Since these agree, we can use just one of them (they ``should'' agree). That leaves us with the C which goes first.

The catch is that things don't always turn out this easily. There is no guarantee that the two A's would come out at the same time, and if they didn't, we'd have to rearrange things until they did. Or if there was no way to rearrange things so that they would agree, we have to go on to plan B, which I will explain now.

Consider the case of M( M(A,B), M(C,D)). We can easily unwind the two subpatches

A         C
M(A,B)    M(C,D)
Now we need to reconcile the A and C. How do we do this? Well, as usual, the solution is to use the most wonderful Theorem 2. In this case we have to use it in the reverse of how we used it when merging, since we know that A and C could either one be the last patch applied before M(A,B) or M(C,D). So we can find C' using

\begin{displaymath}
A^{ -1} C \longleftrightarrow C' A'^{ -1}
\end{displaymath}

Giving an unwinding of
C'
A
M(A,B)
M( M(A,B), M(C,D) )
There is a bit more complexity to the unwinding process (mostly having to do with cases where you have deeper nesting), but I think the general principles that are followed are pretty much included in the above discussion.

There are a couple of simple constraints on the routine which determines how to resolve two conflicting patches (which is called `glump'). These must be satisfied in order that the result of a series of merges is always independent of their order. Firstly, the output of glump cannot change when the order of the two conflicting patches is switched. If it did, then commuting the merger could change the resulting patch, which would be bad. Secondly, the result of the merge of three (or more) conflicting patches cannot depend on the order in which the merges are performed.

The conflict resolution code (glump) begins by ``unravelling'' the merger into a set of sequences of patches. Each sequence of patches corresponds to one non-conflicted patch that got merged together with the others. The result of the unravelling of a series of merges must obviously be independent of the order in which those merges are performed. This unravelling code (which uses the unwind code mentioned above) uses probably the second most complicated algorithm. Fortunately, if we can successfully unravel the merger, almost any function of the unravelled merger satisfies the two constraints mentioned above that the conflict resolution code must satisfy.

It can sometimes be handy to have a canonical representation of a given patch. We achieve this by defining a canonical form for each patch type, and a function ``canonize'' which takes a patch and puts it into canonical form. This routine is used by the diff function to create an optimal patch (based on an LCS algorithm) from a simple hunk describing the old and new version of a file. Note that canonization may fail, if the patch is internally inconsistent.

A simpler, faster (and more generally useful) cousin of canonize is the coalescing function. This takes two sequential patches, and tries to turn them into one patch. This function is used to deal with ``split'' patches, which are created when the commutation of a primitive patch can only be represented by a composite patch. In this case the resulting composite patch must return to the original primitive patch when the commutation is reversed, which a split patch accomplishes by trying to coalesce its contents each time it is commuted.

File patches

A file patch is a patch which only modifies a single file. There are some rules which can be made about file patches in general, which makdes them a handy class. For example, commutation of two filepatches is trivial if they modify different files. There is an exception when one of the files has a name ending with ``-conflicted'', in which case it may not commute with a file having the same name, but without the ``-conflicted.'' If they happen to modify the same file, we'll have to check whether or not they commute.

There is another handy function, which primarily affects file patches (although it can also affect other patches, such as rename patches or dir add/remove patches), which is the submerge-in-directory function. This function changes the patch to act on a patch within a subdirectory rather than in the current directory, and is useful when performing the recursive diff.

Hunks are an example of a complex filepatch. A hunk is a set of lines of a text file to be replaced by a different set of lines. Either of these sets may be empty, which would mean a deletion or insertion of lines. The hunk is the simplest patch that has a commuting pattern in which the commuted patches differ from the originals (rather than simple success or failure). This makes commuting or merging two hunks a tad tedious. Hunks, of course, can be coalesced if they have any overlap. Note that coalesce code doesn't check if the two patches are conflicting. If you are coalescing two conflicting hunks, you've already got a bug somewhere.

One of the most important pieces of code is the canonization of a hunk, which is where the ``diff'' algorithm is performed. This algorithm begins with chopping off the identical beginnings and endings of the old and new hunks. This isn't strictly necesary, but is a good idea, since this process is $O(n)$, while the primary diff algorithm is something considerably more painful than that... actually the head would be dealt with all right, but with more space complexity. I think it's more efficient to just chop the head and tail off first.


Token replace patches

Although most filepatches will be hunks, darcs is clever enough to support other types of changes as well. A ``token replace'' patch replaces all instances of a given token with some other version. A token, here, is defined by a regular expression, which must be of the simple [a-z...] type, indicating which characters are allowed in a token, with all other characters acting as delimiters. For example, a C identifier would be a token with the flag [A-Za-z_0-9].

What makes the token replace patch special is the fact that a token replace can be merged with almost any ordinary hunk, giving exactly what you would want. For example, you might want to change the patch type TokReplace to TokenReplace (if you decided that saving two characters of space was stupid). If you did this using hunks, it would modify every line where TokReplace occurred, and quite likely provoke a conflict with another patch modifying those lines. On the other hand, if you did is using a token replace patch, the only change that it could conflict with would be if someone else had used the token ``TokenReplace'' in their patch rather than TokReplace--and that actually would be a real conflict!

Composite patches

Composite patches are made up of a series of patches intended to be applied sequentially. They are represented by a list of patches, with the first patch in the list being applied first.

Patch string formatting

Of course, in order to store our patches in a file, we'll have to save them as some sort of strings. The convention is that each patch string will end with a newline, but on parsing we skip any amount of whitespace between patches.

Composite patch

A patch made up of a few other patches.
{
  <put patches here> (indented two)
}

Split patch

A split patch is similar to a composite patch (identical in how it's stored), but rather than being composed of several patches grouped together, it is created from one patch that has been split apart, typically through a merge or commutation.
(
  <put patches here> (indented two)
)

Hunk

Replace a hunk (set of contiguous lines) of text with a new hunk.
hunk FILE LINE#
-LINE
...
+LINE
...

Token replace

Replace a token with a new token. Note that this format means that the white space must not be allowed within a token. If you know of a practical application of whitespace within a token, let me know and I may change this.

replace FILENAME [REGEX] OLD NEW

Binary file modification

Modify a binary file

binary FILENAME
oldhex
*HEXHEXHEX
...
newhex
*HEXHEXHEX
...

Add file

Add an empty file to the tree.

addfile filename

Remove file

Delete a file from the tree.

rmfile filename

Move

Rename a file or directory.

move oldname newname

Change Pref

Change one of the preference settings. Darcs stores a number of simple string settings. Among these are the name of the test script and the name of the script that must be called prior to packing in a make dist.
changepref prefname
oldval
newval

Add dir

Add an empty directory to the tree.

adddir filename

Remove dir

Delete a directory from the tree.

rmdir filename

Merger patches

Merge two patches. The MERGERVERSION is included to allow some degree of backwards compatibility if the merger algorithm needs to be changed.
merger MERGERVERSION
<first patch>
<second patch>

Named patches

Named patches are diplayed as a `patch id' which is in square brackets, followed by a patch. Optionally, after the patch id (but before the patch itself) can come a list of dependencies surrounded by angle brackets. Each dependency consists of a patch id.


Repository format

A repository consists of a working directory, which has within it a directory called _darcs. There must also be subdirectories named current and patches. current contains the version of the tree which has been recorded. patches contains the actual patches which are in the repository.

Within _darcs is the inventory file, which lists all the patches that are in the repo. Moreover, it also gives the order of the representation of the patches as they are stored. Given a source of patches, i.e. any other set of repositories which have between them all the patches contained in a given repo, that repo can be reproduced based on only the information in the inventory file. Under those circumstances, the order of the patches specified in the inventory file would be unimportant, as this order is only needed to provide context for the interperetation of the stored patches in this repository.

There is a very special patch which may be stored in patches which is called `pending'. This patch describes any changes which have not yet been recorded, and cannot be determined by a simple diff. For example file additions or renames are placed in pending until they are recorded. Similarly, token replaces are stored in pending until they are recorded.

prefs

The _darcs directory will also typically contain a prefs directory. This directory exists simply to hold user configuration settings specific to this repository. This directory may be freely deleted, and its contents are intended to be modifiable by the user, although a mistake in such a modification may cause darcs to behave strangely or cause your cat to cough up a hairball.

defaults

Default values for darcs commands can be configured on a per-repository basis by editing (and possibly creating) the _darcs/prefs/defaults file. Each line of this file has the following form:

COMMAND FLAG VALUE
where COMMAND is either the name of the command to which the default applies, or ALL to indicate that the default applies to all commands accepting that flag. The FLAG term is the name of the long argument option without the ``--'', i.e. verbose rather than --verbose. Finally, the VALUE option can be omitted if the flag is one such as verbose that doesn't involve a value.

For example, if your system clock is bizarre, you could instruct darcs to always ignore the file modification times by adding the following line to your _darcs/prefs/defaults file. (Note that this would have to be done for each repository!)

ALL ignore-times

If you never want to run a test when recording to a particular repository (but still want to do so when running check on that repo), and like to name all your patches ``Stupid patch'', you could use the following:

record no-test
record patch-name Stupid patch

repos

The _darcs/prefs/repos file contains a list of repositories you have pulled from or pushed to, and is used for autocompletion of pull and push commands in bash. Feel free to delete any lines from this list that might get in there, or to delete the file as a whole.

boring

The _darcs/prefs/boring file may contain a list of regular expressions describing files, such as object files, that you do not expect to add to your project. As an example, the boring file that I use with my darcs repository is:
\.hi$
\.o$
^\.[^/]
^_
~$
(^|/)CVS($|/)
The last line is actually irrelevant because I don't use CVS, but if I did it would be handy. You may want to have the boring file under version control. To do this you can use darcs setpref to set the value ``boringfile'' to the name of your desired boring file (e.g. ``darcs setpref boringfile ./.boring'', where the .boring is a file that has been darcs added to your repository). You could also use this to configure your repo to work with a global boring file, something like ``/etc/darcs/boring''.

binary

The _darcs/prefs/binaries file may contain a list of regular expressions describing files that should be treated as binary files rather than text files. You probably will want to have the binaries file under version control. To do this you can use darcs setpref to set the value ``binariesfile'' to the name of your desired binaries file (e.g. ``darcs setpref binariesfile ./.binaries'', where .binaries is a file that has been darcs added to your repository).


GNU General Public License

Version 2, June 1991

Copyright © 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The ``Program'', below, refers to any such program or work, and a ``work based on the Program'' means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term ``modification''.) Each licensee is addressed as ``you''.

    Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

  2. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

    You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

  3. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:

    1. You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.

    2. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.

    3. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

    These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

    Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

    In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

  4. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:

    1. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

    2. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

    3. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

    The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

    If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

  5. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

  6. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

  7. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

  8. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

    If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

    It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

    This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

  9. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

  10. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

    Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and ``any later version'', you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

  11. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

    NO WARRANTY

  12. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  13. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

About this document ...

Darcs 0.9.12
David's advanced revision control system

This document was generated using the LaTeX2HTML translator Version 2K.1beta (1.48)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -split 0 -external_file darcs -prefix big -no_auto_link -local_icons -dir manual bigpage.tex

The translation was initiated by David Roundy on 2003-07-29


Footnotes

... representationA.1
For those comfortable with quantum mechanics, think of a patch as a quantum mechanical operator, and the representation as the basis set. The analogy breaks down pretty quickly, however, since an operator could be described in any complete basis set, while a patch modifying the file foo can only be described in the rather small set of contexts which have a file foo to be modified.
... treeA.2
This is very similar to the second-quantized picture, in which any state is seen as the result of a number of creation operators acting on the vacuum, and provides a similar set of simplifications--in particular, the exclusion principle is very elegantly enforced by the properties of the anti-hermitian fermion creation operators.
...$P_2$A.3
This notation is inspired by the notation of matrix multiplication or the application of operators upon a Hilbert space. In the algebra of patches, there is multiplication (i.e. composition), which is associative but not commutative, but no addition or subtraction.
... tree).A.4
The fact that commutation can fail makes a huge difference in the whole patch formalism. It may be possible to create a formalism in which commutation always succeeds, with the result of what would otherwise be a commutation that fails being something like a virtual particle (which can violate conservation of energy), and it may be that such a formalism would allow strict mathematical proofs (whereas those used in the current formalism are mostly only hand waving ``physicist'' proofs). However, I'm not sure how you'd deal with a request to delete a file that has not yet been created, for example. Obviously you'd need to create some kind of antifile, which would annihilate with the file when that file finally got created, but I'm not entirely sure how I'd go about doing this. $\ddot\frown$ So I'm sticking with my hand waving formalism.
... consideredA.5
Alas, I don't know how to prove that the two constraints even can be satisfied. The best I have been able to do is to believe that they can be satisfied, and to be unable to find an case in which my implementation fails to satisfy them. These two requirements are the foundation of the entire theory of patches (have you been counting how many foundations it has?).

next_inactive up previous
David Roundy 2003-07-29