Subsections


Configuring darcs

There are several ways you can adjust darcs' behavior to suit your needs. The first is to edit files in the _darcs/prefs/ directory of a repository. Such configuration only applies when working with that repository. To configure darcs on a per-user rather than per-repository basis (but with essentially the same methods), you can edit (or create) files in the ~/.darcs/ directory. Finally, the behavior of some darcs commands can be modified by setting appropriate environment variables.

prefs

The _darcs directory contains a prefs directory. This directory exists simply to hold user configuration settings specific to this repository. The contents of this directory are intended to be modifiable by the user, although in some cases a mistake in such a modification may cause darcs to behave strangely.


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. Each line only takes one flag. To set multiple defaults for the same command (or for ALL commands), use multiple lines.

Note that the use of ALL easily can have unpredicted consequences, especially if commands in newer versions of darcs accepts flags that they didn't in previous versions. A command like obliterate could be devastating with the ``wrong'' flags (for example -all). Only use safe flags with ALL.

~/.darcs/defaults provides defaults for this user account
repo/_darcs/prefs/defaults provides defaults for one project,
  overrules changes per user

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 repository), and like to name all your patches ``Stupid patch'', you could use the following:

record no-test
record patch-name Stupid patch

If you would like a command to be run every time patches are recorded in a particular repository (for example if you have one central repository, that all developers contribute to), then you can set apply to always run a command when apply is successful. For example, if you need to make sure that the files in the repository have the correct access rights you might use the following. There are two things to note about using darcs this way:

apply posthook chmod -R a+r *
apply run-posthook

There are some options which are meant specifically for use in _darcs/prefs/defaults. One of them is --disable. As the name suggests, this option will disable every command that got it as argument. So, if you are afraid that you could damage your repositories by inadvertent use of a command like amend-record, add the following line to _darcs/prefs/defaults:

amend-record disable

Also, a global preferences file can be created with the name .darcs/defaults in your home directory. Options present there will be added to the repository-specific preferences. If they conflict with repository-specific options, the repository-specific ones will take precedence.

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.


author

The _darcs/prefs/author file contains the email address (or name) to be used as the author when patches are recorded in this repository, e.g. David Roundy <droundy@abridgegame.org>. This file overrides the contents of the environment variables $DARCS_EMAIL and $EMAIL.


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($|/)
A newly created repository has a longer boring file that includes many common source control, backup, temporary, and compiled files.

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 .boring is the repository path of a file that has been darcs added to your repository). The boringfile preference overrides _darcs/prefs/boring, so be sure to copy that file to the boringfile.

You can also set up a ``boring'' regexps file in your home directory, named ~/.darcs/boring, which will be used with all of your darcs repositories.

Any file whose repository path (such as manual/index.html) matches any of the boring regular expressions is considered boring. The boring file is used to filter the files provided to darcs add, to allow you to use a simple darcs add newdir newdir/* without accidentally adding a bunch of object files. It is also used when the --look-for-adds flag is given to whatsnew or record.

binaries

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). As with the boring file, you can also set up a ~/.darcs/binaries file if you like.

email

The _darcs/prefs/email file is used to provide the e-mail address for your repository that others will use when they darcs send a patch back to you. The contents of the file should simply be an e-mail address.


motd

The _darcs/prefs/motd file may contain a ``message of the day'' which will be displayed to users who get or pull from the repository without the --quiet option.

Environment variables

There are a few environment variables whose contents affect darcs' behavior.

DARCS_EMAIL

The DARCS_EMAIL environment variable determines the ``author'' name used by darcs when recording if no _darcs/prefs/author exists. If DARCS_EMAIL is undefined, the contents of the EMAIL environment variable are used.

DARCS_EDITOR

When pulling up an editor (for example, when adding a long comment in record), darcs uses the contents of DARCS_EDITOR if it is defined. If not, it tries the contents of VISUAL, and if that isn't defined (or fails for some reason), it tries EDITOR. If none of those environment variables are defined, darcs tries vi, emacs, emacs -nw and nano in that order.

DARCS_PAGER

When using a pager for displaying a patch, darcs uses the contents of DARCS_PAGER if it is defined. If not, it tries the contents of PAGER and then more.

DARCS_TMPDIR

If the environment variable DARCS_TMPDIR is defined, darcs will use that directory for its temporaries. Otherwise it will use TMPDIR, if that is defined, and if not that then /tmp and if /tmp doesn't exist, it'll put the temporaries in _darcs.

This is very helpful, for example, when recording with a test suite that uses MPI, in which case using /tmp to hold the test copy is no good, as /tmp isn't shared over NFS and thus the mpirun call will fail, since the binary isn't present on the compute nodes.

HOME

HOME is used to find the per-user prefs directory, which is located at $HOME/.darcs.

TERM

If darcs is compiled with libcurses support and support for color output, it uses the environment variable TERM to decide whether or not color is supported on the output terminal.

SSH_PORT

When using ssh, if the SSH_PORT environment variable is defined, darcs will use that port rather than the default ssh port (which is 22).


DARCS_SSH

The DARCS_SSH environment variable defines the command that darcs will use when asked to run ssh. This command is not interpreted by a shell, so you cannot use shell metacharacters, and the first word in the command must be the name of an executable located in your path.

DARCS_SCP and DARCS_SFTP

The DARCS_SCP and DARCS_SFTP environment variables define the commands that darcs will use when asked to run scp or sftp. Darcs uses scp and sftp to access repositories whose address is of the form user@foo.org:foo or foo.org:foo. Darcs will use scp to copy single files (e.g. repository meta-information), and sftp to copy multiple files in batches (e.g. patches). These commands are not interpreted by a shell, so you cannot use shell metacharacters, and the first word in the command must be the name of an executable located in your path. By default, scp and sftp are used. When you can use sftp, but not scp (e.g. some ISP web sites), it works to set DARCS_SCP to `sftp'. The other way around does not work, i.e. DARCS_FTP must reference an sftp program, not scp.

DARCS_PROXYUSERPWD

This environment variable allows DARCS and libcurl to access remote repositories via a password-protected HTTP proxy. The proxy itself is specified with the standard environment variable for this purpose, namely 'http_proxy'. The DARCS_PROXYUSERPWD environment variable specifies the proxy username and password. It must be given in the form username:password.

DARCS_GET_FOO, DARCS_MGET_FOO and DARCS_APPLY_FOO

When trying to access a repository with a URL beginning foo://, darcs will invoke the program specified by the DARCS_GET_FOO environment variable (if defined) to download each file, and the command specified by the DARCS_APPLY_FOO environment variable (if defined) when pushing to a foo:// URL.

This method overrides all other ways of getting foo://xxx URLs.

Note that each command should be constructed so that it sends the downloaded content to STDOUT, and the next argument to it should be the URL. Here are some examples that should work for DARCS_GET_HTTP:

fetch -q -o -  
curl -s -f
lynx -source 
wget -q -O -

If set, DARCS_MGET_FOO will be used to fetch many files from a single repository simultaneously. Replace FOO and foo as appropriate to handle other URL schemes. These commands are not interpreted by a shell, so you cannot use shell metacharacters, and the first word in the command must be the name of an executable located in your path. The GET command will be called with a URL for each file. The MGET command will be invoked with a number of URLs and is expected to download the files to the current directory, preserving the file name but not the path. The APPLY command will be called with a darcs patchfile piped into its standard input. Example:

wget -q

DARCS_MGETMAX

When invoking a DARCS_MGET_FOO command, darcs will limit the number of URLs presented to the command to the value of this variable, if set, or 200.

DARCS_WGET

This is a very old option that is only used if libcurl is not compiled in and one of the DARCS_GET_FOO is not used. Using one of those is recommended instead.

The DARCS_WGET environment variable defines the command that darcs will use to fetch all URLs for remote repositories. The first word in the command must be the name of an executable located in your path. Extra arguments can be included as well, such as:

wget -q

Darcs will append -i to the argument list, which it uses to provide a list of URLS to download. This allows wget to download multiple patches at the same time. It's possible to use another command besides wget with this environment variable, but it must support the -i option in the same way.

These commands are not interpreted by a shell, so you cannot use shell meta-characters.

Highlighted output

If the terminal understands ANSI color escape sequences, darcs will highlight certain keywords and delimiters when printing patches. This can be turned off by setting the environment variable DARCS_DONT_COLOR to 1. If you use a pager that happens to understand ANSI colors, like less -R, darcs can be forced always to highlight the output by setting DARCS_ALWAYS_COLOR to 1. If you can't see colors you can set DARCS_ALTERNATIVE_COLOR to 1, and darcs will use ANSI codes for bold and reverse video instead of colors.

By default darcs will escape (by highlighting if possible) any kind of spaces at the end of lines when showing patch contents. If you don't want this you can turn it off by setting DARCS_DONT_ESCAPE_TRAILING_SPACES to 1. A special case exists for only carriage returns: DARCS_DONT_ESCAPE_TRAILING_CR.

Character escaping and non-ASCII character encodings

Darcs needs to escape certain characters when printing patch contents to a terminal. Characters like backspace can otherwise hide patch content from the user, and other character sequences can even in some cases redirect commands to the shell if the terminal allows it.

By default darcs will only allow printable 7-bit ASCII characters (including space), and the two control characters tab and newline. (See the last paragraph in this section for a way to tailor this behavior.) All other octets are printed in quoted form (as ^<control letter> or \).

Darcs has some limited support for locales. If the system's locale is a single-byte character encoding, like the Latin encodings, you can set the environment variable DARCS_DONT_ESCAPE_ISPRINT to 1 and darcs will display all the printables in the current system locale instead of just the ASCII ones. NOTE: This curently does not work on some architectures if darcs is compiled with GHC 6.4. Some non-ASCII control characters might be printed and can possibly spoof the terminal.

For multi-byte character encodings things are less smooth. UTF-8 will work if you set DARCS_DONT_ESCAPE_8BIT to 1, but non-printables outside the 7-bit ASCII range are no longer escaped. E.g., the extra control characters from Latin-1 might leave your terminal at the mercy of the patch contents. Space characters outside the 7-bit ASCII range are no longer recognized and will not be properly escaped at line endings.

As a last resort you can set DARCS_DONT_ESCAPE_ANYTHING to 1. Then everything that doesn't flip code sets should work, and so will all the bells and whistles in your terminal. This environment variable can also be handy if you pipe the output to a pager or external filter that knows better than darcs how to handle your encoding. Note that all escaping, including the special escaping of any line ending spaces, will be turned off by this setting.

There are two environment variables you can set to explicitly tell darcs to not escape or escape octets. They are DARCS_DONT_ESCAPE_EXTRA and DARCS_ESCAPE_EXTRA. Their values should be strings consisting of the verbatim octets in question. The do-escapes take precedence over the dont-escapes. Space characters are still escaped at line endings though. The special environment variable DARCS_DONT_ESCAPE_TRAILING_CR turns off escaping of carriage return last on the line (DOS style).

darcs-stable 2007-06-16