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 propagate 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.
.
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 when pulling
patches. darcs has built-in support for using ssh to write to a remote file
system. A darcs executable is called on the remote system to apply the patches.
Arbitrary other transport protocols are supported, through an environment
variable describing a command that will run darcs on the remote system.
See the documentation for DARCS_APPLY_FOO in Chapter
for details.
The recommended method is to send patches through gpg-signed email messages, which has the advantage of being mostly asynchronous.
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).
Other revision control systems are centered upon the job of keeping 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.
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. As a result, 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.
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 he really wants to change, rather than the users merging the
patch. An example of this is the token replace patch (See
Section
). This feature makes it possible to create a
patch, for example, which changes every instance of the variable
``stupidly_named_var'' to ``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 involve 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
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 of 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 invertibility. In
particular, invertibility is required to make use of
Theorem
, which is used extensively in the manipulation of
merges.
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 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 by simply calling from the root directory of your project:
$ cd my_project/ $ darcs initializeThis 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 add2.1:
$ darcs add *.c Makefile.am configure.acWhen 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.
Now that we have created our repository, make a change to one or more of your files. After making the modification run:
$ darcs whatsnewThis 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
, which describes the whatsnew 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 recorddarcs 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.
$ cd /var/www/repos $ ln -s /home/username/myproject .
cd into my repository,
and there type:
$ darcs pull http://your.server.org/repos/yourprojectDarcs 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 on 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 http://your.server.org/repos/yourprojectwhich gets the whole repository.
I could instead create an empty repository and fetch all of your patches with pull. Get is just a more efficient way to clone a whole repository.
Get, pull and push also work over ssh. Ssh-paths are of the same form
accepted by scp, namely [username@]host:/path/to/repository.
Darcs is flexible as to how you move patches from one repository to another. This section will introduce all the ways you can get patches from one place to another, starting with the simplest and moving to the most complicated.
The simplest method is the ``all-pull'' method. This involves making each
repository readable (by http, ftp, nfs-mounted disk, whatever), and you
run darcs pull in the repository you want to move the patch to. This is nice,
as it doesn't require you to give write access to anyone else, and is
reasonably simple.
Sometimes you have a machine on which it is not convenient to set up a web
server, perhaps because it's behind a firewall or perhaps for security
reasons, or because it is often turned off. In this case you can use
darcs send
from that computer to generate a patch bundle destined for another
repository. You can either let darcs email the patch for you, or save it
as a file and transfer it by hand. Then in the destination repository you
(or the owner of that repository) run darcs apply to apply the patches contained
in the bundle. This is also quite a simple method since, like the all-pull
method, it doesn't require that you give anyone write access to your
repository. But it's less convenient, since you have to keep track of the
patch bundle (in the email, or whatever).
If you use the send and apply method with email, you'll probably want to
create a _darcs/prefs/email file containing your email address.
This way anyone who sends to your repository will automatically send the
patch bundle to your email address.
If you receive many patches by email, you probably will benefit by running
darcs apply directly from your mail program. I have in my .muttrc
the following:
auto_view text/x-patch text/x-darcs-patch
macro pager A "<pipe-entry>darcs apply --verbose --mark-conflicts \
--reply droundy@abridgegame.org --repodir ~/darcs"
which allows me to view a sent patch, and then apply the patch directly from mutt, sending a
confirmation email to the person who sent me the patch. The autoview line relies on on the following
lines, or something like them, being present in one's .mailcap:
text/x-patch; cat; copiousoutput text/x-darcs-patch; cat; copiousoutput
If you use ssh (and preferably also ssh-agent, so you won't have to keep retyping your password), you can use the push method to transfer changes (using the scp protocol for communication). This method is again not very complicated, since you presumably already have the ssh permissions set up. Push can also be used when the target repository is local, in which case ssh isn't needed. On the other hand, in this situation you could as easily run a pull, so there isn't much benefit.
Note that you can use push to administer a multiple-user repository. You
just need to create a user for the repository (or repositories), and give
everyone with write access ssh access, perhaps using
.ssh/authorized_keys. Then they run
$ darcs push repouser@repo.server:repo/directory
Now we get more subtle. If you like the idea in the previous paragraph about creating a repository user to own a repository which is writable by a number of users, you have one other option.
Push --apply-as can run on either a local repository or one accessed
with ssh, but uses sudo to run a darcs apply command (having created
a patch bundle as in send) as another user. You can add the following line
in your sudoers file to allow the users to apply their patches to a
centralized repository:
ALL ALL = (repo-user) NOPASSWD: /usr/bin/darcs apply --all --repodir /repo/path*This method is ideal for a centralized repository when all the users have accounts on the same computer, if you don't want your users to be able to run arbitrary commands as repo-user.
Most of the previous methods are a bit clumsy if you don't want to give each person with write access to a repository an account on your server. Darcs send can be configured to send a cryptographically signed patch by email. You can then set up your mail system to have darcs verify that patches were signed by an authorized user and apply them when a patch is received by email. The results of the apply can be returned to the user by email. Unsigned patches (or patches signed by unauthorized users) will be forwarded to the repository owner (or whoever you configure them to be forwarded to...).
This method is especially nice when combined with the --test option
of darcs apply, since it allows you to run the test suite (assuming you
have one) and reject patches that fail--and it's all done on the server,
so you can happily go on working on your development machine without
slowdown while the server runs the tests.
Setting up darcs to run automatically in response to email is by far the most complicated way to get patches from one repository to another... so it'll take a few sections to explain how to go about it.
When you set up darcs to run apply on signed patches, you should assume
that a user with write access can write to any file or directory that is
writable by the user under which the apply process runs. Unless you
specify the --no-test flag to darcs apply (and this is not
the default), you are also allowing anyone with write access to that
repository to run arbitrary code on your machine (since they can run a test
suite--which they can modify however they like). This is quite a
potential security hole.
For these reasons, if you don't implicitly trust your users, it is recommended that you create a user for each repository to limit the damage an attacker can do with access to your repository. When considering who to trust, keep in mind that a security breach on any developer's machine could give an attacker access to their private key and passphrase, and thus to your repository.
You also must install the following programs: gnupg, a mailer configured to receive mail (e.g. exim, sendmail or postfix), and a web server (usually apache).
You create your gpg key by running (as your normal user):
$ gpg --gen-keyYou will be prompted for your name and email address, among other options. 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 with the following command (again as your normal user):
$ gpg --export "email@address" > /tmp/exported_keyAnd 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 send patches to the repository.
You should now be able to send a patch to the repository by running as your normal user, in a working copy of the repository:
$ darcs send --sign http://your.computer/repos/myprojectYou may want to add ``send sign'' to the file
_darcs/prefs/defaults
so that you won't need to type --sign every time you want to
send...
If your gpg key is protected by a passphrase, then executing send
with the --sign option might give you the following error:
darcs failed: Error running external program 'gpg'The most likely cause of this error is that you have a misconfigured gpg that tries to automatically use a non-existent gpg-agent program. GnuPG will still work without gpg-agent when you try to sign or encrypt your data with a passphrase protected key. However, it will exit with an error code 2 (
ENOENT) causing darcs to
fail. To fix this, you will need to edit your ~/.gnupg/gpg.conf
file and comment out or remove the line that says:
use-agentIf after commenting out or removing the
use-agent line in your
gpg configuration file you still get the same error, then you probably
have a modified GnuPG with use-agent as a hard-coded option. In that
case, you should change use-agent to no-use-agent to
disable it explicitly.
To begin with, you must configure your repository so that a darcs send to
your repository will know where to send the email. Do this by creating a
file in /path/to/your/repo/_darcs/prefs called email
containing your email address. As a trick (to be explained below), we will
create the email address with ``darcs repo'' as your name, in an email
address of the form ``David Roundy
droundy@abridgegame.org
.''
$ echo 'my darcs repo <user@host.com>' \
> /path/to/your/repo/_darcs/prefs/email
The next step is to set up a gnupg keyring containing the public keys of people authorized to send to your repository. Here I'll give a second way of going about this (see above for the first). This time I'll assume you want to give me write access to your repository. You can do this by:
gpg --no-default-keyring \
--keyring /path/to/the/allowed_keys --recv-keys D3D5BCEC
This works because ``D3D5BCEC'' is the ID of my gpg key, and I have
uploaded my key to the gpg keyservers. Actually, this also requires that
you have configured gpg to access a valid keyserver. You can, of course,
repeat this command for all keys you want to allow access to.
Finally, we add a few lines to your .procmailrc:
:0
* ^TOmy darcs repo
|(umask 022; darcs apply --reply user@host.com \
--repodir /path/to/your/repo --verify /path/to/the/allowed_keys)
The purpose for the ``my darcs repo'' trick is partially to make it easier
to recognize patches sent to the repository, but is even more crucial to
avoid nasty bounce loops by making the --reply option have an email
address that won't go back to the repository. This means that unsigned
patches that are sent to your repository will be forwarded to your ordinary
email.
Like most mail-processing programs, Procmail by default sets a tight umask.
However, this will prevent the repository from remaining world-readable;
thus, the ``umask 022'' is required to relax the umask.
(Alternatively, you could set Procmail's global UMASK variable
to a more suitable value.)
After sending a patch with darcs send, you may not receive any feedback,
even if the patch is applied. You can confirm whether or not your patch was applied
to the remote repository by pointing darcs changes at a remote repository:
darcs changes --last=10 --repo=http://darcs.net/
That shows you the last 10 changes in the remote repository. You can adjust the options given
to changes if a more advanced query is needed.
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.
The global darcs directory is %APPDATA%\darcs\. This typically expands to
C:\Documents And Settings\user\Application Data\darcs\.
This folder contains the cache, as well as all the per-user
settings files: preferences, boring etc... These will became the new defaults
that can be overridden on per-repository basis.
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.
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 VALUEwhere
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.
If the value has spaces in it, use single quotes, not double quotes, to surround it.
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, on MS Windows ![]() |
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:
darcs add; doing so would
allow people to modify that file and then run arbitrary scripts on
your main repository, possibly damaging or violating security.
apply posthook chmod -R a+r * apply run-posthook
Similarly, if you need a command to run automatically before darcs performs an action you can use a prehook. Using prehooks it could be possible to canonicalize line endings before recording patches.
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, on MS Windows
.
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.
_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.
_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.
_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,
on MS Windows
, which will be
used with all of your darcs repositories.
Any file not already managed by darcs and 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.
Note that once a file has been added to darcs, it is not considered
boring, even if it matches the boring file filter.
_darcs/prefs/binaries file may contain a list of regular
expressions describing files that should be treated as binary files rather
than text files. Darcs automatically treats files containing
^Z\ or '\0' within the first 4096 bytes as being binary 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, on MS Windows
.
_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.
_darcs/prefs/sources file is used to indicate alternative
locations from which to download patches when using a ``hashed''
repository. This file contains lines such as:
cache:/home/droundy/.darcs/cache readonly:/home/otheruser/.darcs/cache repo:http://darcs.netThis would indicate that darcs should first look in
/home/droundy/.darcs/cache for patches that might be missing, and if
the patch isn't there, it should save a copy there for future use. In that
case, darcs will look in /home/otheruser/.darcs/cache to see if that
user might have downloaded a copy, but won't try to save a copy there, of
course. Finally, it will look in http://darcs.net. Note that the
sources file can also exist in ~/.darcs/. Also note that the
sources mentioned in your sources file will be tried before
the repository you are pulling from. This can be useful in avoiding
downloading patches multiple times when you pull from a remote repository
to more than one local repository.
We strongly advise that you enable a global cache directory, which will allow darcs to avoid re-downloading patches (for example, when doing a second darcs get of the same repository), and also allows darcs to use hard links to reduce disk usage. To do this, simply
mkdir -p $HOME/.darcs/cache echo cache:$HOME/.darcs/cache > $HOME/.darcs/sourcesNote that the cache directory should reside on the same filesystem as your repositories, so you may need to vary this. You can also use multiple cache directories on different filesystems, if you have several filesystems on which you use darcs.
_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.
There are a few environment variables whose contents affect darcs' behavior. Here is a quick list of all the variables and their documentation in the rest of the manual:
The environment variable $DARCS_SSH can be used to specify an alternative SSH client. Arguments may be included, separated by whitespace. The value is not interpreted by a shell, so shell constructs cannot be used; in particular, it is not possible for the program name to contain whitespace by using quoting or escaping.
If transfer-mode fails, Darcs will fall back on scp(1) and sftp(1). The commands invoked can be customized with the environment variables $DARCS_SCP and $DARCS_SFTP respectively, which behave like $DARCS_SSH. If the remote end allows only sftp, try setting DARCS_SCP=sftp.
[protocol://]<host>[:port]
In which case libcurl will use the proxy for the associated protocol (HTTP, HTTPS and FTP). The environment variable ALL_PROXY can be used to set a single proxy for all libcurl requests.
If the environment variable NO_PROXY is a comma-separated list of host names, access to those hosts will bypass proxies defined by the above variables. For example, it is quite common to avoid proxying requests to machines on the local network with
NO_PROXY=localhost,*.localdomain
For compatibility with lynx et al, lowercase equivalents of these environment variables (e.g. $http_proxy) are also understood and are used in preference to the uppercase versions.
If Darcs was not built with libcurl, all these environment variables are silently ignored, and there is no way to use a web proxy.
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 -
Apart from such toy examples, it is likely that you will need to manipulate the argument before passing it to the actual fetcher program. For example, consider the problem of getting read access to a repository on a CIFS (SMB) share without mount privileges:
export DARCS_GET_SMB="smbclient -c get" darcs get smb://fs/twb/Desktop/hello-world
The above command will not work for several reasons. Firstly, Darcs will pass it an argument beginning with `smb:', which smbclient does not understand. Secondly, the host and share `//fs/twb' must be presented as a separate argument to the path `Desktop/hello-world'. Thirdly, smbclient requires that `get' and the path be a single argument (including a space), rather than two separate arguments. Finally, smbclient's `get' command writes the file to disk, while Darcs expects it to be printed to standard output.
In principle, we could get around such problems by making the variable contain a shell script, e.g.
export DARCS_GET_SMB='sh -c "...; smbclient $x -c \"get $y\""'
Unfortunately, Darcs splits the command on whitespace and does not understand that quotation or escaping, so there is no way to make Darcs pass the text after `-c' to sh as a single argument. Therefore, we instead need to put such one-liners in separate, executable scripts.
Continuing our smbclient example, we create an executable script
~/.darcs/libexec/get_smb with the following contents:
#!/bin/bash -e
IFS=/ read host share file <<<"${1#smb://}"
smbclient //$host/$share -c "get $file -"
And at last we can say
export DARCS_GET_SMB=~/.darcs/libexec/get_smb darcs get smb://fs/twb/Desktop/hello-world
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
These commands are not interpreted by a shell, so you cannot use shell meta-characters.
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.
In addition, there is an extra-colorful mode, which is not enabled by
default, which can be activated with DARCS_DO_COLOR_LINES.
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.
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
\<hex code>).
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 or later. 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).
This chapter is intended to review various scenarios and describe in each case effective ways of using darcs. There is no one ``best practice'', and darcs is a sufficiently low-level tool that there are many high-level ways one can use it, which can be confusing to new users. The plan (and hope) is that various users will contribute here describing how they use darcs in different environments. However, this is not a wiki, and contributions will be edited and reviewed for consistency and wisdom.
This section will lay down the concepts around patch creation. The aim is to develop a way of thinking that corresponds well to how darcs is behaving -- even in complicated situations.
In a single darcs repository you can think of two ``versions'' of the source tree.
They are called the working and pristine trees.
Working is your normal source tree, with or without darcs alongside.
The only thing that makes it part of a darcs repository
is the _darcs directory in its root.
Pristine is the recorded state of the source tree.
The pristine tree is constructed from groups of changes,
called patches (some other version control systems use the
term changeset instead of patch).4.1 Darcs will create and store these patches
based on the changes you make in working.
whatsnew (as well as diff) can show
the difference between working and pristine to you.
It will be shown as a difference in working.
In advanced cases it need not be working that has changed;
it can just as well have been pristine, or both.
The important thing is the difference and what darcs can do with it.
record it to keep it, or revert it to lose the changes.4.2
If you have a difference between working and pristine--for example after editing some files in working--whatsnew will show some ``unrecorded changes''.
To save these changes, use record.
It will create a new patch in pristine with the same changes,
so working and pristine are no longer different.
To instead undo the changes in working, use revert.
It will modify the files in working to be the same as in pristine
(where the changes do not exist).
unrecord is a command meant to be run only in private
repositories. Its intended purpose is to allow developers the flexibility
to undo patches that haven't been distributed yet.
However, darcs does not prevent you from unrecording a patch that has been copied to another repository. Be aware of this danger!
If you unrecord a patch, that patch will be deleted from pristine.
This will cause working to be different from pristine,
and whatsnew to report unrecorded changes.
The difference will be the same as just before that patch was recorded.
Think about it.
record examines what's different with working
and constructs a patch with the same changes in pristine
so they are no longer different.
unrecord deletes this patch;
the changes in pristine disappear and the difference is back.
If the recorded changes included an error, the resulting flawed patch can be unrecorded. When the changes have been fixed, they can be recorded again as a new--hopefully flawless--patch.
If the whole change was wrong it can be discarded from working too,
with revert.
revert will update working to the state of pristine,
in which the changes do no longer exist after the patch was deleted.
Keep in mind that the patches are your history,
so deleting them with unrecord makes it impossible to track
what changes you really made.
Redoing the patches is how you ``cover the tracks''.
On the other hand,
it can be a very convenient way to manage and organize changes
while you try them out in your private repository.
When all is ready for shipping,
the changes can be reorganized in what seems as useful and impressive patches.
Use it with care.
All patches are global, so don't ever replace an already ``shipped'' patch in this way! If an erroneous patch is deleted and replaced with a better one, you have to replace it in all repositories that have a copy of it. This may not be feasible, unless it's all private repositories. If other developers have already made patches or tags in their repositories that depend on the old patch, things will get complicated.
The patches described in the previous sections have mostly been hunks. A hunk is one of darcs' primitive patch types, and it is used to remove old lines and/or insert new lines. There are other types of primitive patches, such as adddir and addfile which add new directories and files, and replace which does a search-and-replace on tokens in files.
Hunks are always calculated in place with a diff algorithm
just before whatsnew or record.
But other types of primitive patches need to be explicitly created
with a darcs command.
They are kept in pending4.3until they are either recorded or reverted.
Pending can be thought of as a special extension of working.
When you issue, e.g., a darcs replace command,
the replace is performed on the files in working
and at the same time a replace patch is put in pending.
Patches in pending describe special changes made in working.
The diff algorithm will fictively apply these changes to pristine
before it compares it to working,
so all lines in working that are changed by a replace command
will also be changed in pending
pristine
when the hunks are calculated.
That's why no hunks with the replaced lines will be shown by whatsnew;
it only shows the replace patch in pending responsible for the change.
If a special patch is recorded, it will simply be moved to pristine. If it is instead reverted, it will be deleted from pending and the accompanying change will be removed from working.
Note that reverting a patch in pending is not the same as
simply removing it from pending.
It actually applies the inverse of the change to working.
Most notable is that reverting an addfile patch
will delete the file in working (the inverse of adding it).
So if you add the wrong file to darcs by mistake,
don't revert the addfile.
Instead use remove, which cancels out the addfile in pending.
This section will lay down the concepts around patch distribution and branches. The aim is to develop a way of thinking that corresponds well to how darcs is behaving -- even in complicated situations.
A repository is a collection of patches. Patches have no defined order, but patches can have dependencies on other patches. Patches can be added to a repository in any order as long as all patches depended upon are there. Patches can be removed from a repository in any order, as long as no remaining patches depend on them.
Repositories can be cloned to create branches. Patches created in different branches may conflict. A conflict is a valid state of a repository. A conflict makes the working tree ambiguous until the conflict is resolved.
There are two kinds of dependencies: implicit dependencies and explicit dependencies.
Implicit dependencies is the far most common kind. These are calculated automatically by darcs. If a patch removes a file or a line of code, it will have to depend on the patch that added that file or line of code.4.4If a patch adds a line of code, it will usually have to depend on the patch or patches that added the adjacent lines.
Explicit dependencies can be created if you give the --ask-deps option to darcs record.
This is good for assuring that logical dependencies hold between patches.
It can also be used to group patches--a patch with explicit dependencies doesn't need to change anything--and pulling the patch also pulls all patches it was made to depend on.
Darcs does not have branches--it doesn't need to. Every repository can be used as a branch. This means that any two repositories are ``branches'' in darcs, but it is not of much use unless they have a large portion of patches in common. If they are different projects they will have nothing in common, but darcs may still very well be able to merge them, although the result probably is nonsense. Therefore the word ``branch'' isn't a technical term in darcs; it's just the way we think of one repository in relation to another.
Branches are very useful in darcs.
They are in fact necessary if you want to do more than only simple work.
When you get someone's repository from the Internet,
you are actually creating a branch of it.
It may first seem inefficient (or if you come from CVS--frightening),
not to say plain awkward.
But darcs is designed this way, and it has means to make it efficient.
The answer to many questions about how to do a thing with darcs is: ``use a branch''.
It is a simple and elegant solution with great power and flexibility,
which contributes to darcs' uncomplicated user interface.
You create new branches (i.e., clone repositories)
with the get and put commands.
Patches are global, and a copy of a patch either is or is not present in a branch. This way you can rig a branch almost any way you like, as long as dependencies are fulfilled--darcs won't let you break dependencies. If you suspect a certain feature from some time ago introduced a bug, you can remove the patch/patches that adds the feature, and try without it.4.5
Patches are added to a repository with pull
and removed from the repositories with obliterate.
Don't confuse these two commands with record and unrecord,
which constructs and deconstructs patches.
It is important not to lose patches when (re)moving them around.
pull needs a source repository to copy the patch from,
whereas obliterate just erases the patch.
Beware that if you obliterate all copies of a patch
it is completely lost--forever.
Therefore you should work with branches when you obliterate patches.
The obliterate command can wisely be disabled in a dedicated main repository
by adding obliterate disable to the repository's defaults file.
For convenience, there is a push command.
It works like pull but in the other direction.
It also differs from pull in an important way:
it starts a second instance of darcs to apply the patch in the target repository,
even if it's on the same computer.
It can cause surprises if you have a ``wrong'' darcs in your PATH.
While pull and obliterate can be used to
construct different ``versions'' in a repository,
it is often desirable to name specific configurations of patches
so they can be identified and retrieved easily later.
This is how darcs implements what is usually known as versions.
The command for this is tag,
and it records a tag in the current repository.
A tag is just a patch, but it only contains explicit dependencies. It will depend on all the patches in the current repository.4.6Darcs can recognize if a patch is as a tag; tags are sometimes treated specially by darcs commands.
While traditional revision control systems tag versions in the time line history, darcs lets you tag any configuration of patches at any time, and pass the tags around between branches.
With the option --tag to get you can easily get
a named version in the repository
as a new branch.
This part of darcs becomes a bit complicated, and the description given here is slightly simplified.
Conflicting patches are created when you record changes to the same line in two different repositories. Same line does not mean the same line number and file name, but the same line added by a common depended-upon patch.
If you are using a darcs-2 repository (Section
),
darcs does not consider two patches making the same change to be a
conflict, much in the same fashion as other version control systems.
(The caveat here is two non-identical patches with some identical
changes may conflict. For the most part, darcs should just do what you
expect).
A conflict happens when two conflicting patches meet in the same repository. This is no problem for darcs; it can happily pull together just any patches. But it is a problem for the files in working (and pristine). The conflict can be thought of as two patches telling darcs different things about what a file should look like.
Darcs escapes this problem by ignoring those parts4.7of the patches that conflict. They are ignored in both patches. If patch A changes the line ``FIXME'' to ``FIXED'', and patch B changes the same line to ``DONE'', the two patches together will produce the line ``FIXME''. Darcs doesn't care which one you pulled into the repository first, you still get the same result when the conflicting patches meet. All other changes made by A and B are performed as normal.
Darcs can mark a conflict for you in working.
This is done with mark-conflicts.
Conflicts are marked such that both conflicting changes
are inserted with special delimiter lines around them.
Then you can merge the two changes by hand,
and remove the delimiters.
When you pull patches,
darcs automatically performs a mark-conflicts for you if a conflict happens.
You can remove the markup with revert,
Remember that the result will be the lines from
the previous version common to both conflicting patches.
The conflict marking can be redone again with mark-conflicts.
A special case is when a pulled patch conflicts with unrecorded changes in the repository.
The conflict will be automatically marked as usual,
but since the markup is also an unrecorded change,
it will get mixed in with your unrecorded changes.
There is no guarantee you can revert only the markup after this,
and resolve will not be able to redo this markup later if you remove it.
It is good practice to record important changes before pulling.
mark-conflicts can't mark complicated conflicts.
In that case you'll have to use darcs diff and other commands
to understand what the conflict is all about.
If for example two conflicting patches create the same file,
mark-conflicts will pick just one of them,
and no delimiters are inserted.
So watch out if darcs tells you about a conflict.
mark-conflicts can also be used to check for unresolved conflicts.
If there are none, darcs replies ``No conflicts to resolve''.
While pull reports when a conflict happens,
obliterate and get don't.
A conflict is resolved
(not marked, as with the command mark-conflicts)
as soon as some new patch depends on the conflicting patches.
This will usually be the resolve patch you record after manually putting together the pieces
from the conflict markup produced by mark-conflicts (or pull).
But it can just as well be a tag.
So don't forget to fix conflicts before you accidently ``resolve'' them by recording other patches.
If the conflict is with one of your not-yet-published patches, you may choose to amend that patch rather than creating a resolve patch.
If you want to back out and wait with the conflict,
you can obliterate the conflicting patch you just pulled.
Before you can do that you have to revert the conflict markups
that pull inserted when the conflict happened.
When working with darcs 2 it is recommended to use a global cache, as this is one of the biggest performance enhancing tools of darcs 2. The global cache acts as a giant patch pool where darcs first looks for a patch when grabbing new patches. This saves time by not downloading the same patch twice from a remote server. It also saves space by storing the patch only once, if you ensure your cache and your repositories are on the same hardlink-supporting filesystem.
Darcs now enables a global patch cache under your home directory by default. Older darcs 2.x versions required this manual step:
$ mkdir -p $HOME/.darcs/cache $ echo cache:$HOME/.darcs/cache > $HOME/.darcs/sources
On MS Windows
, using cmd.exe (Command Prompt under Accessories):
> md "%UserProfile%\Application Data\darcs\cache" (notice double quotes!) > echo cache:%UserProfile%\Application Data\darcs\cache > "%UserProfile%\Application Data\darcs\sources"
There are some other advanced things you can do in _darcs/prefs/sources,
such as create per-repository caches, read-only caches and even set a
primary source repository above any used in a darcs get or
darcs pull command.
This is how darcs itself is developed. There are many contributors to
darcs, but every contribution is reviewed and manually applied by myself.
For this sort of a situation, darcs send is ideal, since the barrier for
contributions is very low, which helps encourage contributors.
One could simply set the _darcs/prefs/email value to the project
mailing list, but I also use darcs send to send my changes to the main
server, so instead the email address is set to
``Davids Darcs Repo <droundy@abridgegame.org>''. My
.procmailrc
file on the server has the following rule:
:0
* ^TODavids Darcs Repo
|(umask 022; darcs apply --reply darcs-devel@abridgegame.org \
--repodir /path/to/repo --verify /path/to/allowed_keys)
This causes darcs apply to be run on any email sent to ``Davids Darcs
Repo''.
apply actually applies them only if they are signed by an
authorized key. Currently, the only authorized key is mine, but of course
this could be extended easily enough.
The central darcs repository contains the following values in its
_darcs/prefs/defaults:
apply test apply verbose apply happy-forwardingThe first line tells apply to always run the test suite. The test suite is in fact the main reason I use send rather than push, since it allows me to easily continue working (or put my computer to sleep) while the tests are being run on the main server. The second line is just there to improve the email response that I get when a patch has either been applied or failed the tests. The third line makes darcs not complain about unsigned patches, but just to forward them to
darcs-devel.
On my development computer, I have in my .muttrc the following
alias, which allows me to easily apply patches that I get via email
directly to my darcs working directory:
macro pager A "<pipe-entry>(umask 022; darcs apply --no-test -v \
--repodir ~/darcs)"
This section describes the development method used for the density
functional theory code DFT++, which is available at
http://dft.physics.cornell.edu/dft.
We have a number of workstations which all mount the same /home via NFS.
We created a special ``dft'' user, with the central repository living in that
user's home directory. The ssh public keys of authorized persons are added to
the ``dft'' user's .ssh/allowed_keys, and we commit patches to this
repository using
darcs push. As in Section
,
we have the central repository set to run the test suite before the push goes
through.
Note that no one ever runs as the dft user.
A subtlety that we ran into showed up in the running of the test suite.
Since our test suite includes the running of MPI programs, it must be run
in a directory that is mounted across our cluster. To achieve this, we set
the $DARCS_TMPDIR environment variable to ~/tmp.
Note that even though there are only four active developers at the moment,
the distributed nature of darcs still plays a large role. Each developer
works on a feature until it is stable, a process that often takes quite a
few patches, and only once it is stable does he
push to the central repository.
It's easy to have several personal development trees using darcs, even when working on a team or with shared code. The number and method of using each personal tree is limited only by such grand limitations as: your disk space, your imagination, available time, etc.
For example, if the central darcs repository for your development team
is
, you can create a local working directory for feature
. This local working directory contains a full copy of
(as of the time of the ``darcs get'' operation) and can be denoted
. In the midst of working on feature
, you realize it
requires the development of a separate feature
. Rather than
intermingling
and
in the same working tree, you can create
a new working tree for working on
, where that working tree
contains the repository
.
While working on
, other developers may have made other changes;
these changes can be retrieved on a per-patch selection basis by
periodic ``darcs pull'' operations.
When your work on
is completed, you can publish it for the use
of other developers by a ``darcs push'' (or ``darcs send'') from
to
. Independently of the publishing of
, you can merge
your
work into your
working tree by a ``darcs pull
''
in the
development tree (or ``darcs push'' from
to
).
When your work on
is completed, you publish it as well by a
``darcs push'' from
to
.
Your local feature development efforts for
or
can each
consist of multiple patches. When pushing or pulling to other trees,
these patches can either all be selected or specific patches can be
selected. Thus, if you introduce a set of debugging calls into the
code, you can commit the debugging code in a distictly separate patch
(or patches) that you will not push to
.
As discussed in the section above, a developer may have various changes to their local development repositories that they do not ever wish to publish to a group repository (e.g. personal debugging code), but which they would like to keep in their local repository, and perhaps even share amongst their local repositories.
This is easily done via darcs, since those private changes can be
committed in patches that are separate from other patches; during the
process of pushing patches to the common repository (
), the
developer is queried for which patches should be moved to (
) on a
patch-by-patch basis.
The --complement flag for the ``darcs pull'' operation can
further simplify this effort. If the developer copies (via ``darcs
push'' or ``darcs pull'') all private patches into a special
repository/working tree (
), then those patches are easily
disregarded for pulling by adding --complement to the ``darcs
pull'' line and listing
after the primary source repository.
The --complement flag is only available for ``darcs pull'', and
not ``darcs push'' or ``darcs send'', requiring the user to have pull
access to the target repository. While the actual public repository
is often not shared in this manner, it's simple to create a local
version of the public repository to act as the staging area for that
public repository.
The following example extends the two feature addition example in the
previous section using a local staging repository (
) and a
private patch repository:
$ cd working-dir $ darcs get http://server/repos/Rc Rl $ darcs get Rl R1 $ cd R1 ...development of f1 $ darcs record -m'p1: f1 initial work' ... $ darcs record -m'p2: my debugging tracepoints' ... $ cd .. $ darcs get http://server/repos/Rc R2 $ cd R2 $ darcs pull -p p2 ../R1 ... development of f2 $ darcs record -m'p3: f2 finished' $ cd .. $ darcs get Rl Rp $ cd Rp $ darcs pull -p p2 ../R2 $ cd ../Rl $ darcs pull --complement ../R2 ../Rp $ darcs send ... for publishing f2 patches to Rc $ cd ../R1 $ darcs pull ../R2 ... updates R1 with f2 changes from R2 ... more development of f1 $ darcs record -m'p4: f1 feature finished.' $ cd ../Rl $ darcs pull --complement ../R1 ../Rp $ darcs send
Darcs 2 supports three repository formats:
Note that references to the hashed format refer to hashed darcs-1 repositories. All darcs-2 repositories are also hashed, and `darcs show repo' in a darcs-2 repository will report the format as `hashed, darcs-2'.
The hashed (and darcs-2) format improves on the darcs-1 format in the following ways:
For example, in darcs-1 running find -name "*.gif" -delete
instead of find -name _darcs -prune -o -name "*.gif" -delete
would result in GIF files in pristine files being deleted.
Lazy repositories are first-class repositories, and all operations are supported as long as the parent repository remains accessible. This isn't the case for the `partial' feature of the darcs-1 format.
The darcs-2 format improves on the hashed format in the following ways:
See also `darcs initialize' (
), `darcs convert'
(
) and `darcs get' (
).
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.
If you wish, you may use any unambiguous beginning of a command name as a
shortcut: for darcs record, you could type darcs recor or
darcs rec, but not darcs re since that could be confused with
darcs replace, darcs revert and darcs remove.
In some cases, COMMAND actually consists of two words, a
super-command and a subcommand. For example, the ``display the
manifest'' command has the form darcs query manifest.
Not all commands modify the ``patches'' of your repository (that is, the named patches which other users can pull); some commands only affect the copy of the source tree you're working on (your ``working directory''), and some affect both. This table summarizes what you should expect from each one and will hopefully serve as guide when you're having doubts about which command to use.
| affects | patches | working directory |
| record | yes | no |
| unrecord | yes | no |
| rollback | yes | yes |
| revert | no | yes |
| unrevert | no | yes |
| pull | yes | yes |
| obliterate | yes | yes |
| apply | yes | yes |
| push6.1 | no | no |
| send6.2 | no | no |
| put6.3 | no | no |
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
guaranteed never to be out of sync with the version of darcs you actually
have installed (unlike this manual, which could be for an entirely
different version of darcs).
% darcs COMMAND --help
--disable option, which can be used in
_darcs/prefs/defaults to disable some commands in the repository. This
can be helpful if you want to protect the repository from accidental use of
advanced commands like obliterate, unpull, unrecord or amend-record.
--verbose option, which tells darcs to
provide additional output. The amount of verbosity varies from command to
command. Commands that accept --verbose also accept --quiet,
which surpresses non-error output, and --normal-verbosity which can be
used to restore the default verbosity if --verbose or --quiet is in
the defaults file.
--debug option, which causes darcs to generate
additional output that may be useful for debugging its behavior, but which otherwise
would not be interesting. Option --debug-http makes darcs output debugging
info for libcurl.
--repodir option, which allows you to
specify the directory of the repository in which to perform the command.
This option is used with commands, such as whatsnew, that ordinarily would
be performed within a repository directory, and allows you to use those
commands without actually being in the repository directory when calling the
command. This is useful when running darcs in a pipe, as might be the case
when running apply from a mailer.
Some commands, such as pull require a remote repository to be specified,
either from the command line or as a default. The --remote-repo
provides an alternative way to supply this remote repository path. This flag
can be seen as temporarily ``replacing'' the default repository. Setting it
causes the command to ignore the default repository (it also does not affect,
i.e. overwrite the default repository). On the other hand, if any other
repositories are supplied as command line arguments, this flag will be ignored
(and the default repository may be overwritten).
Many commands operate on a patch or patches that have already been recorded.
There are a number of options that specify which patches are selected for
these operations: --patch, --match, --tag, and variants
on these, which for --patch are --patches,
--from-patch, and --to-patch. The --patch and
--tag forms simply take (POSIX extended, aka egrep) regular
expressions and match them against tag and patch names. --match,
described below, allows more powerful patterns.
The plural forms of these options select all matching patches. The singular forms select the last matching patch. The range (from and to) forms select patches after or up to (both inclusive) the last matching patch.
These options use the current order of patches in the repository. darcs may reorder patches, so this is not necessarily the order of creation or the order in which patches were applied. However, as long as you are just recording patches in your own repository, they will remain in order.
When a patch or a group of patches is selected, all patches they depend on
get silently selected too. For example: darcs pull --patches bugfix
means ``pull all the patches with `bugfix' in their name, along with any
patches they require.'' If you really only want patches with `bugfix' in
their name, you should use the --no-deps option, which makes darcs
exclude any matched patches from the selection which have dependencies that
are themselves not explicitly matched by the selection.
For unrecord, unpull and obliterate, patches that
depend on the selected patches are silently included, or if
--no-deps is used selected patches with dependencies on not selected
patches are excluded from the selection.
Currently --match accepts six primitive match types, although
there are plans to expand it to match more patterns. Also, note that the
syntax is still preliminary and subject to change.
The first match type accepts a literal string which is checked against the patch name. The syntax is
darcs annotate --summary --match 'exact foo+bar'This is useful for situations where a patch name contains characters that could be considered special for regular expressions.
In this and the other match types, the argument must be enclosed in double quotes if it contains spaces. You can escape a quote in the argument with a backslash; backslash escapes itself, but it is treated literally if followed by a character other than a double quote or backslash, so it is typically not necessary to escape a backslash. No such escaping is necessary unless the argument is enclosed in double quotes.
The second match type accepts a regular expression which is checked against the patch name. The syntax is
darcs annotate --summary --match 'name foo'Note that to match regexp metacharacters, such as
(, literally, they
must be escaped with backslash along with any embedded double quotes. To
match a literal backslash it must be written quadrupled in general, but often
it need not be escaped, since backslash is only special in regexps when
followed by a metacharacter. In the following example pairs, the first
literal is matched by the second sequence in the match name:
``"'':``\"'', ``\'':``\\\\'',
``\x'':``\x'', ``('':``\(''.
The third match type matches the darcs hash for each patch:
darcs annotate --summary --match \ 'hash 20040403105958-53a90-c719567e92c3b0ab9eddd5290b705712b8b918ef'Note you need to provide the full hash string as above. This is intended to be used, for example, by programs allowing you to view darcs repositories (e.g. CGI scripts like viewCVS).
The fourth match type accepts a regular expression which is checked against the patch author. The syntax is
darcs annotate --summary --match 'author foo'
There is also support for matching by date. This is done using commands such as
darcs annotate --summary --match 'date "last week"' darcs annotate --summary --match 'date yesterday' darcs annotate --summary --match 'date "today 14:00"' darcs annotate --summary --match 'date "tea time yesterday"' darcs annotate --summary --match 'date "3 days before last year at 17:00"' darcs changes --from-match 'date "Sat Jun 30 11:31:30 EDT 2004"'
Only English date specifications are supported--specifically you must use English day and month names. Also, only a limited set of time zones is supported (compatible with GNU coreutils' date parsing). Unrecognized zones are treated as UTC, which may result in the timestamps printed in change entries not being recognized by the date matching. You can avoid this problem on a POSIX-like system by running darcs in the UTC zone to get the times initially, e.g.:
TZ=UTC darcs changes
When matching on the ISO format, a partial date is treated as a range. English dates can either refer to a specific day (``6 months ago',``day before yesterday''), or to an interval from some past date (``last month'') to the present. Putting this all together, if today is ``2004-07-24'' then the following matches should work:
| date | patches selected |
|---|---|
| 2004 | from 2004-01-01 up to and including 2004-12-31 |
| 2004-01 | from 2004-01-01 up to and including 2004-01-31 |
| 2004-01-01 | during 2004-01-01 |
| today | during 2004-07-24 (starting midnight in your timezone) |
| yesterday | during 2004-07-23 |
| 6 months ago | during 2004-01-23 |
| last 6 months | since 2004-01-23 |
| last month | since 2004-06-23 (not 2004-06-01!) |
| last week | since 2004-07-16 |
For more precise control, you may specify an interval, either in a small subset of English or of the ISO 8601 format. If you use the ISO format, note that durations, when specified alone, are interpreted as being relative to the current date and time.
darcs annotate --summary --match 'date "between 2004-03-12 and last week"' darcs annotate --summary --match 'date "after 2005"' darcs annotate --summary --match 'date "in the last 3 weeks"' darcs annotate --summary --match 'date "P3M/2006-03-17"' darcs annotate --summary --match 'date "2004-01-02/2006-03-17"' darcs annotate --summary --match 'date "P2M6D"'
You may also prefer to combine date matching with a more specific pattern.
darcs annotate --summary --match 'date "last week" && name foo'
The sixth match type accepts a regular expression which is checked against file paths that the patch touches. The syntax is
darcs annotate --summary --match 'touch foo/bar.c'
The --match pattern can include the logical operators &&,
|| and not, as well as grouping of patterns with parentheses.
For example
darcs annotate --summary --match 'name record && not name overrode'
whatsnew and record which would otherwise require reading
every file in the repository 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 explicitly.
--dont-compress option, which causes darcs not to compress the patch
file.
--dry-run option will cause darcs not to actually take the specified
action, but only print what would have happened. Not all commands accept
--dry-run, but those that do should accept the --summary option.
--summary option shows a summary of the patches that would have been
pulled/pushed/whatever. The format is similar to the output format of
cvs update and looks like this:
A ./added_but_not_recorded.c A! ./added_but_not_recorded_conflicts.c a ./would_be_added_if_look_for_adds_option_was_used.h M ./modified.t -1 +1 M! ./modified_conflicts.t -1 +1 R ./removed_but_not_recorded.c R! ./removed_but_not_recorded_conflicts.c
You can probably guess what the flags mean from the clever file names.
--look-for-adds option available for
whatsnew and record. They have not been added yet, but would be
added automatically if --look-for-adds were used with the next
record command.
To resolve conflicts using an external tool, you need to specify a command to use, e.g.
--external-merge 'opendiff %1 %2 -ancestor %a -merge %o'The
%1 and %2 are replaced with the two versions to be
merged, %a is replaced with the common ancestor of the two versions.
Most importantly, %o is replaced with the name of the output file
that darcs will require to be created holding the merged version. The
above example works with the FileMerge.app tool that comes with Apple's
developer tools. To use xxdiff, you would use
--external-merge 'xxdiff -m -O -M %o %1 %a %2'To use
kdiff3, you can use
--external-merge 'kdiff3 --output %o %a %1 %2'To use
tortoiseMerge, you can use
--external-merge 'tortoiseMerge /base:"%a" /mine:"%1" /theirs:"%2" /merged:"%o"'(
tortoiseMerge is a nice merge tool that comes with TortoiseSVN and works well
on Windows.)
Note that the command is split into space-separated words and the first one is
execed with the rest as arguments--it is not a shell command. In particular,
on Windows this means that the first command path should not contain spaces and
you should make sure the command is in your PATH.
The substitution of the % escapes is done everywhere. If you need to prevent
substitution you can use a double percentage sign, i.e. %%a is substituted with
%a. Here is an example script to use the Emacs' Ediff package for merging.
#! /bin/sh
# External merge command for darcs, using Emacs Ediff, via server if possible.
# It needs args %1 %2 %a %o, i.e. the external merge command is, say,
# `emerge3 %1 %2 %a %o'.
test $# -eq 4 || exit 1
form="(ediff-merge-files-with-ancestor"
while test $# -gt 0; do
count=$count.
if [ $count = .... ]; then
form=$form\ nil # Lisp STARTUP-HOOKS arg
fi
case $1 in # Worry about quoting -- escape " and \
*[\"\\]* ) form=$form\ \"$(echo $1 | sed -e's/["\\]/\\\0/g')\" ;;
*) form=$form\ \"$1\" ;;
esac
shift
done
form=$form')'
( emacsclient --eval "$form" || # Emacs 22 server
gnudoit "$form" || # XEmacs/Emacs 21 server
emacs --eval "$form" || # Relatively slow to start up
xemacs -eval "$form" # Horribly slow to start up
) 2>/dev/null
It would be invoked like:
--external-merge 'emerge3 %1 %2 %a %o'
If you figure out how to use darcs with another merge tool, please let me know what flags you used so I can mention it here.
Note that if you do use an external merge tool, most likely you will want
to add to your defaults file
(_darcs/prefs/defaults or ~/.darcs/prefs, see
,
on MS Windows
)
a line such as
ALL external-merge kdiff3 --output %o %a %1 %2or
ALL external-merge tortoiseMerge /base:"%a" /mine:"%1" /theirs:"%2" /merged:"%o"
Note that the defaults file does not want quotes around the command.
--posthook to specify the command. This is useful
for people who want to have a command run whenever a patch is applied. Using
--no-posthook will disable running the command.
--prompt-posthook to have darcs prompt before running the
posthook command. You may use -run-posthook to reenable the default
behavior of running user-specified posthooks.
Some darcs commands export to the posthook command information about the
changes being made. In particular, three environment variables are defined.
DARCS_PATCHES contains a human-readable summary of the patches being
acted upon. The format is the same as "darcs changes". DARCS_PATCHES_XML
Contains the same details, in the same XML format as "darcs changes". Finally,
DARCS_FILES contains a list of the files affected, one file per line.
If your repository has filenames including newlines, you'll just have to
cope. Note, however, that none of these environment variables are
defined when running under windows. Note also that we refuse to pass
environment variables greater in size than 10k, in order to avoid triggering
E2BIG errors.
--prehook to specify the command. An example use is
for people who want to have a command run whenever a patch is to be recorded, such as
translating line endings before recording patches. Using
--no-prehook will disable running the command.
For commands which invoke ssh, darcs will normally multiplex ssh sessions over a single connection as long as your version of ssh has the ControlMaster feature from OpenSSH versions 3.9 and above. This option will avoid darcs trying to use this feature even if your ssh supports it.
When compiled with libcurl (version 7.18.0 and above), darcs can use HTTP pipelining. It is enabled by default for libcurl (version 7.19.1 and above). This option will make darcs enable or disable HTTP pipelining, overwriting default. Note that if HTTP pipelining is really used depends on the server.
Do not use patch caches.
--umask will cause Darcs to switch to a different umask before
writing to the repository.
But sometimes you may want to manage a group of ``sub'' repositories'
preference files with a global repository, or use darcs in some other
advanced way. The best way is probably to put
ALL dont-restrict-paths in _darcs/prefs/defaults. This turns
off all sanity checking for file paths in patches.
Path checking can be temporarily turned on with --restrict-paths on
the command line, when pulling or applying unknown patches.
--help as an argument gives a brief
summary of what commands are available.
--version tells you the version of
darcs you are using. Calling darcs with the flag --exact-version
gives the precise version of darcs, even if that version doesn't correspond
to a released version number. This is helpful with bug reports, especially
when running with a ``latest'' version of darcs.
--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.
Usage: darcs help [OPTION]... [<DARCS_COMMAND> [DARCS_SUBCOMMAND]]
Options:
Display help about darcs and darcs commands.
When converting a project to Darcs from some other VCS, translating the full revision history to native Darcs patches is recommended. (The Darcs wiki lists utilities for this.) Because Darcs is optimized for small patches, simply importing the latest revision as a single large patch can PERMANENTLY degrade Darcs performance in your repository by an order of magnitude.
This command creates the `_darcs' directory, which stores version control metadata. It also contains per-repository settings in _darcs/prefs/, which you can read about in the user manual.
In addition to the default `darcs-2' format, there are two backward compatibility formats for the _darcs directory. These formats are only useful if some of your contributors do not have access to Darcs 2.0 or higher. In that case, you need to use the original format (called `old-fashioned inventory' or `darcs-1') for any repositories those contributors access.
As patches cannot be shared between darcs-2 and darcs-1 repositories, you cannot use the darcs-2 format for private branches of such a project. Instead, you should use the `hashed' format, which provides most of the features of the darcs-2 format, while retaining the ability to share patches with darcs-1 repositories. The `darcs get' command will do this by default.
Once all contributors have access to Darcs 2.0 or higher, a darcs-1 project can be migrated to darcs-2 using the `darcs convert' command.
Darcs will create a hashed repository by default when you `darcs get' a repository in old-fashioned inventory format. Once all contributors have upgraded to Darcs 2.0 or later, use `darcs convert' to convert the project to the darcs-2 format.
Initialize is commonly abbreviated to `init'.
Usage: darcs initialize [OPTION]...
Options:
--hashed |
|
||
--darcs-2 |
|
||
--old-fashioned-inventory |
|
||
--repodir DIRECTORY |
|
By default Darcs will copy every patch from the original repository. This means the copy is completely independent of the original; you can operate on the new repository even when the original is inaccessible. If you expect the original repository to remain accessible, you can use -lazy to avoid copying patches until they are needed (`copy on demand'). This is particularly useful when copying a remote repository with a long history that you don't care about.
The -lazy option isn't as useful for local copies, because Darcs will automatically use `hard linking' where possible. As well as saving time and space, you can move or delete the original repository without affecting a complete, hard-linked copy. Hard linking requires that the copy be on the same filesystem and the original repository, and that the filesystem support hard linking. This includes NTFS, HFS+ and all general-purpose Unix filesystems (such as ext3, UFS and ZFS). FAT does not support hard links.
Darcs get will not copy unrecorded changes to the source repository's working tree.
It is often desirable to make a copy of a repository that excludes some patches. For example, if releases are tagged then `darcs get -tag .' would make a copy of the repository as at the latest release.
An untagged repository state can still be identified unambiguously by a context file, as generated by `darcs changes -context'. Given the name of such a file, the -context option will create a repository that includes only the patches from that context. When a user reports a bug in an unreleased version of your project, the recommended way to find out exactly what version they were running is to have them include a context file in the bug report.
You can also make a copy of an untagged state using the -to-patch or -to-match options, which exclude patches `after' the first matching patch. Because these options treat the set of patches as an ordered sequence, you may get different results after reordering with `darcs optimize', so tagging is preferred.
If the source repository is in a legacy darcs-1 format and contains at least one checkpoint (see `darcs optimize'), the -partial option will create a partial repository. A partial repository discards history from before the checkpoint in order to reduce resource requirements. For modern darcs-2 repositories, -partial is a deprecated alias for the -lazy option.
A repository created by `darcs get' will be in the best available format: it will be able to exchange patches with the source repository, but will not be directly readable by Darcs binaries older than 2.0.0. Use the `-old-fashioned-inventory' option if the latter is required.
Usage: darcs get [OPTION]... <REPOSITORY> [<DIRECTORY>]
Options:
--repo-name DIRECTORY,--repodir DIRECTORY |
|
||
--partial |
|
||
--lazy |
|
||
--ephemeral |
|
||
--complete |
|
||
--to-match PATTERN |
|
||
--to-patch REGEXP |
|
||
-t |
--tag REGEXP |
|
|
--context FILENAME |
|
||
--set-default |
|
||
--no-set-default |
|
||
--set-scripts-executable |
|
||
--dont-set-scripts-executable,--no-set-scripts-executable |
|
||
--nolinks |
|
||
--hashed |
|
||
--old-fashioned-inventory |
|
Advanced options:
--ssh-cm |
|
||
--no-ssh-cm |
|
||
--http-pipelining |
|
||
--no-http-pipelining |
|
||
--no-cache |
|
||
--remote-darcs COMMAND |
|
Currently this command just uses `darcs init' to create the target repository, then `darcs push -all' to copy patches to it. Options passed to `darcs put' are passed to the init and/or push commands as appropriate. See those commands for an explanation of each option.
Usage: darcs put [OPTION]... <NEW REPOSITORY>
Options:
--to-match PATTERN |
|
||
--to-patch REGEXP |
|
||
-t |
--tag REGEXP |
|
|
--context FILENAME |
|
||
--set-scripts-executable |
|
||
--dont-set-scripts-executable,--no-set-scripts-executable |
|
||
--hashed |
|
||
--old-fashioned-inventory |
|
||
--set-default |
|
||
--no-set-default |
|
||
--repodir DIRECTORY |
|
Advanced options:
--apply-as USERNAME |
|
||
--no-apply-as |
|
||
--ssh-cm |
|
||
--no-ssh-cm |
|
||
--http-pipelining |
|
||
--no-http-pipelining |
|
||
--no-cache |
|
||
--remote-darcs COMMAND |
|
When an existing project is first imported into a Darcs repository, it is common to run `darcs add -r *' or `darcs record -l' to add all initial source files into darcs.
Adding symbolic links (symlinks) is not supported.
Darcs will ignore all files and folders that look `boring'. The -boring option overrides this behaviour.
Darcs will not add file if another file in the same folder has the same name, except for case. The -case-ok option overrides this behaviour. Windows and OS X usually use filesystems that do not allow files a folder to have the same name except for case (for example, `ReadMe' and `README'). If -case-ok is used, the repository might be unusable on those systems!
The -date-trick option allows you to enable an experimental trick to make add conflicts, in which two users each add a file or directory with the same name, less problematic. While this trick is completely safe, it is not clear to what extent it is beneficial.
Usage: darcs add [OPTION]... <FILE or DIRECTORY> ...
Options:
--boring |
|
||
--no-boring |
|
||
--case-ok |
|
||
--no-case-ok |
|
||
--reserved-ok |
|
||
--no-reserved-ok |
|
||
-r |
--recursive |
|
|
--not-recursive,--no-recursive |
|
||
--date-trick |
|
||
--no-date-trick |
|
||
--repodir DIRECTORY |
|
||
--dry-run |
|
Advanced options:
--umask UMASK |
|
Note that applying a removal patch to a repository (e.g. by pulling the patch) will ALWAYS affect the working tree of that repository.
Usage: darcs remove [OPTION]... <FILE or DIRECTORY> ...
Options:
--repodir DIRECTORY |
|
||
-r |
--recursive |
|
|
--not-recursive,--no-recursive |
|
Advanced options:
--umask UMASK |
|
Darcs will not rename a file if another file in the same folder has the same name, except for case. The -case-ok option overrides this behaviour. Windows and OS X usually use filesystems that do not allow files a folder to have the same name except for case (for example, `ReadMe' and `README'). If -case-ok is used, the repository might be unusable on those systems!
Usage: darcs move [OPTION]... <SOURCE> ... <DESTINATION>
Options:
--case-ok |
|
||
--no-case-ok |
|
||
--reserved-ok |
|
||
--no-reserved-ok |
|
||
--repodir DIRECTORY |
|
Advanced options:
--umask UMASK |
|
Files are tokenized according to one simple rule: words are strings of valid token characters, and everything between them (punctuation and whitespace) is discarded. By default, valid token characters are letters, numbers and the underscore (i.e. [A-Za-z0-9_]). However if the old and/or new token contains either a hyphen or period, BOTH hyphen and period are treated as valid (i.e. [A-Za-z0-9_.-]).
The set of valid characters can be customized using the -token-chars
option. The argument must be surrounded by square brackets. If a
hyphen occurs between two characters in the set, it is treated as a
set range. For example, in most locales [A-Z] denotes all uppercase
letters. If the first character is a caret, valid tokens are taken to
be the complement of the remaining characters. For example, [^:
n]
could be used to match fields in the passwd(5), where records and
fields are separated by newlines and colons respectively.
If you choose to use -token-chars, you are STRONGLY encouraged to do so consistently. The consequences of using multiple replace patches with different -token-chars arguments on the same file are not well tested nor well understood.
By default Darcs will refuse to perform a replacement if the new token is already in use, because the replacements would be not be distinguishable from the existing tokens. This behaviour can be overridden by supplying the -force option, but an attempt to `darcs rollback' the resulting patch will affect these existing tokens.
Limitations:
The tokenizer treats files as byte strings, so it is not possible for -token-chars to include multi-byte characters, such as the non-ASCII parts of UTF-8. Similarly, trying to replace a `high-bit' character from a unibyte encoding will also result in replacement of the same byte in files with different encodings. For example, an acute a from ISO 8859-1 will also match an alpha from ISO 8859-7.
Due to limitations in the patch file format, -token-chars arguments
cannot contain literal whitespace. For example, [^
n
t] cannot be
used to declare all characters except the space, tab and newline as
valid within a word, because it contains a literal space.
Unlike POSIX regex(7) bracket expressions, character classes (such as [[:alnum:]]) are NOT supported by -token-chars, and will be silently treated as a simple set of characters.
Usage: darcs replace [OPTION]... <OLD> <NEW> <FILE> ...
Options:
--token-chars "[CHARS]" |
|
||
-f |
--force |
|
|
--no-force |
|
||
--repodir DIRECTORY |
|
Advanced options:
--ignore-times |
|
||
--no-ignore-times |
|
||
--umask UMASK |
|
$ darcs replace newtoken aaack ./foo.c $ darcs replace oldtoken newtoken ./foo.c $ darcs recordwill be valid, even if
newtoken and oldtoken are both present
in the recorded version of foo.c, while the sequence
$ [manually edit foo.c replacing newtoken with aaack] $ darcs replace oldtoken newtoken ./foo.cwill fail because ``newtoken'' still exists in the recorded version of
foo.c. The reason for the difference is that when recording, a
``replace'' patch always is recorded before any manual changes,
which is usually what you want, since often you will introduce new
occurrences of the ``newtoken'' in your manual changes. In contrast,
multiple ``replace'' changes are recorded in the order in which
they were made.
Every patch has a name, an optional description, an author and a date.
The patch name should be a short sentence that concisely describes the patch, such as `Add error handling to main event loop.' You can supply it in advance with the -m option, or provide it when prompted.
The patch description is an optional block of free-form text. It is used to supply additional information that doesn't fit in the patch name. For example, it might include a rationale of WHY the change was necessary. By default Darcs asks if you want to add a description; the -edit-long-comment and -skip-long-comment can be used to answer `yes' or `no' (respectively) to this prompt. Finally, the -logfile option allows you to supply a file that already contains the patch name (first line) and patch description (subsequent lines). This is useful if a previous record failed and left a darcs-record-0 file.
Each patch is attributed to its author, usually by email address (for example, `Fred Bloggs <fred@example.net>'). Darcs looks in several places for this author string: the -author option, the files _darcs/prefs/author (in the repository) and /.darcs/author (in your home directory), and the environment variables $DARCS_EMAIL and $EMAIL. If none of those exist, Darcs will prompt you for an author string and write it to _darcs/prefs/author.
The patch date is generated automatically. It can only be spoofed by using the -pipe option.
If a test command has been defined with `darcs setpref', attempting to record a patch will cause the test command to be run in a clean copy of the working tree (that is, including only recorded changes). If the test fails, the record operation will be aborted.
The -set-scripts-executable option causes scripts to be made executable in the clean copy of the working tree, prior to running the test. See `darcs get' for an explanation of the script heuristic.
If your test command is tediously slow (e.g. `make all') and you are recording several patches in a row, you may wish to use -no-test to skip all but the final test.
Usage: darcs record [OPTION]... [FILE or DIRECTORY]...
Options:
-m |
--patch-name PATCHNAME |
|
|
-A |
--author EMAIL |
|
|
--no-test |
|
||
--test |
|
||
--leave-test-directory |
|
||
--remove-test-directory |
|
||
-a |
--all |
|
|
--pipe |
|
||
-i |
--interactive |
|
|
--ask-deps |
|
||
--no-ask-deps |
|
||
--edit-long-comment |
|
||
--skip-long-comment |
|
||
--prompt-long-comment |
|
||
-l |
--look-for-adds |
|
|
--dont-look-for-adds,--no-look-for-adds |
|
||
--repodir DIRECTORY |
|
Advanced options:
--logfile FILE |
|
||
--delete-logfile |
|
||
--no-delete-logfile |
|
||
--compress |
|
||
--dont-compress,--no-compress |
|
||
--ignore-times |
|
||
--no-ignore-times |
|
||
--umask UMASK |
|
||
--set-scripts-executable |
|
||
--dont-set-scripts-executable,--no-set-scripts-executable |
|
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 repository. This can be used, for example, if a piece of code requires a function to be defined, which 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.
It is possible to record a patch which has no actual changes but which
has specific dependencies. This type of patch can be thought of as a
``partial tag''. The darcs tag command will record a patch
with no actual changes but which depends on the entire current
inventory of the repository. The darcs record --ask-deps with
no selected changes will record a patch that depends on only those
patches selected via the --ask-deps operation, resulting in a
patch which describes a set of patches; the presence of this primary
patch in a repository implies the presence of (at least) the
depended-upon patches.
If you run record with the --pipe option, you will be prompted for
the patch date, author, and the long comment. The long comment will extend
until the end of file or stdin is reached (ctrl-D on Unixy systems, ctrl-Z
on systems running a Microsoft OS).
This interface is intended for scripting darcs, in particular for writing
repository conversion scripts. The prompts are intended mostly as a useful
guide (since scripts won't need them), to help you understand the format in
which to provide the input. Here's an example of what the --pipe
prompts look like:
What is the date? Mon Nov 15 13:38:01 EST 2004 Who is the author? David Roundy What is the log? One or more comment lines
By default, record works interactively. Probably the only thing you need
to know about using this is that you can press ? at the prompt to be
shown a list of the rest of the options and what they do. The rest should be
clear from there. Here's a
``screenshot'' to demonstrate:
hunk ./hello.pl +2 +#!/usr/bin/perl +print "Hello World!\n"; Shall I record this patch? (2/2) [ynWsfqadjk], or ? for help: ? How to use record... y: record this patch n: don't record it w: wait and decide later, defaulting to no s: don't record the rest of the changes to this file f: record the rest of the changes to this file d: record selected patches a: record all the remaining patches q: cancel record j: skip to next patch k: back up to previous patch h or ?: show this help <Space>: accept the current default (which is capitalized)What you can't see in that ``screenshot'' is that
darcs will also try to use
color in your terminal to make the output even easier to read.
Usage: darcs pull [OPTION]... [REPOSITORY]...
Options:
--matches PATTERN |
|
||
-p |
--patches REGEXP |
|
|
-t |
--tags REGEXP |
|
|
-a |
--all |
|
|
-i |
--interactive |
|
|
--mark-conflicts |
|
||
--allow-conflicts |
|
||
--dont-allow-conflicts,--no-allow-conflicts |
|
||
--skip-conflicts |
|
||
--external-merge COMMAND |
|
||
--test |
|
||
--no-test |
|
||
--dry-run |
|
||
--xml-output |
|
||
-s |
--summary |
|
|
--no-summary |
|
||
--no-deps |
|
||
--dont-prompt-for-dependencies |
|
||
--prompt-for-dependencies |
|
||
--set-default |
|
||
--no-set-default |
|
||
--repodir DIRECTORY |
|
||
--ignore-unrelated-repos |
|
Advanced options:
--intersection |
|
||
--union |
|
||
--complement |
|
||
--compress |
|
||
--dont-compress,--no-compress |
|
||
--nolinks |
|
||
--ignore-times |
|
||
--no-ignore-times |
|
||
--remote-repo URL |
|
||
--set-scripts-executable |
|
||
--dont-set-scripts-executable,--no-set-scripts-executable |
|
||
--umask UMASK |
|
||
--restrict-paths |
|
||
--dont-restrict-paths,--no-restrict-paths |
|
||
--ssh-cm |
|
||
--no-ssh-cm |
|
||
--http-pipelining |
|
||
--no-http-pipelining |
|
||
--no-cache |
|
||
--remote-darcs COMMAND |
|
If you provide more than one repository as an argument to pull, darcs'
behavior is determined by the presence of the --complement,
--intersection, and --union flags.
--union) behavior is to pull any patches
that are in any of the specified repositories (
--intersection flag, darcs
will only pull those patches which are present in all source
repositories (
--complement flag, darcs will only
pull elements in the first repository that do not exist in any of the
remaining repositories6.4 (
You can use an external interactive merge tool to resolve conflicts with the
flag --external-merge. For more details see
subsection
.
The --patches, --matches, --tags, and --no-deps
options can be used to select which patches to pull, as described in
subsection
.
If you specify the --test option, pull will run the test (if a test
exists) on a scratch copy of the repository contents prior to actually performing
the pull. If the test fails, the pull will be aborted.
Adding the --verbose option causes another section to appear in the
output which also displays a summary of patches that you have and the remote
repository lacks. Thus, the following syntax can be used to show you all the patch
differences between two repositories:
darcs pull --dry-run --verbose
Usage: darcs push [OPTION]... [REPOSITORY]
Options:
--matches PATTERN |
|
||
-p |
--patches REGEXP |
|
|
-t |
--tags REGEXP |
|
|
--no-deps |
|
||
--dont-prompt-for-dependencies |
|
||
--prompt-for-dependencies |
|
||
-a |
--all |
|
|
-i |
--interactive |
|
|
--sign |
|
||
--sign-as KEYID |
|
||
--sign-ssl IDFILE |
|
||
--dont-sign,--no-sign |
|
||
--dry-run |
|
||
--xml-output |
|
||
-s |
--summary |
|
|
--no-summary |
|
||
--repodir DIRECTORY |
|
||
--set-default |
|
||
--no-set-default |
|
||
--ignore-unrelated-repos |
|
Advanced options:
--apply-as USERNAME |
|
||
--no-apply-as |
|
||
--nolinks |
|
||
--remote-repo URL |
|
||
--ssh-cm |
|
||
--no-ssh-cm |
|
||
--http-pipelining |
|
||
--no-http-pipelining |
|
||
--no-cache |
|
||
--remote-darcs COMMAND |
|
For obvious reasons, you can only push to repositories to which you have
write access. In addition, you can only push to repos that you access
either on the local file system or with ssh. In order to apply with ssh,
darcs must also be installed on the remote computer. The command invoked
to run ssh may be configured by the DARCS_SSH environment variable
(see subsection
). The command invoked via ssh is always
darcs, i.e. the darcs executable must be in the default path on
the remote machine.
Push works by creating a patch bundle, and then running darcs apply in the
target repository using that patch bundle. This means that the default
options for apply in the target repository (such as, for
example, --test) will affect the behavior of push. This also means
that push is somewhat less efficient than pull.
When you receive an error message such as
bash: darcs: command not foundthen this means that the darcs on the remote machine could not be started. Make sure that the darcs executable is called
darcs and is found in the default path. The default path can
be different in interactive and in non-interactive shells. Say
ssh login@remote.machine darcsto try whether the remote darcs can be found, or
ssh login@remote.machine 'echo $PATH'(note the single quotes) to check the default path.
If you give the --apply-as flag, darcs will use sudo to apply the
changes as a different user. This can be useful if you want to set up a
system where several users can modify the same repository, but you don't
want to allow them full write access. This isn't secure against skilled
malicious attackers, but at least can protect your repository from clumsy,
inept or lazy users.
The --patches, --matches, --tags, and --no-deps
options can be used to select which patches to push, as described in
subsection
.
When there are conflicts, the behavior of push is determined by the default
flags to apply in the target repository. Most commonly, for
pushed-to repositories, you'd like to have --dont-allow-conflicts as
a default option to apply (by default, it is already the default...). If
this is the case, when there are conflicts on push, darcs will fail with an
error message. You can then resolve by pulling the conflicting patch,
recording a resolution and then pushing the resolution together with the
conflicting patch.
Darcs does not have an explicit way to tell you which patch conflicted, only the file name. You may want to pull all the patches from the remote repository just to be sure. If you don't want to do this in your working directory, you can create another darcs working directory for this purpose.
If you want, you could set the target repository to use --allow-conflicts.
In this case conflicting patches will be applied, but the conflicts will
not be marked in the working directory.
If, on the other hand, you have --mark-conflicts specified as a
default flag for apply in the target repository, when there is a conflict,
it will be marked in the working directory of the target repository. In
this case, you should resolve the conflict in the target repository itself.
Usage: darcs send [OPTION]... [REPOSITORY]
Options:
--matches PATTERN |
|
||
-p |
--patches REGEXP |
|
|
-t |
--tags REGEXP |
|
|
--no-deps |
|
||
--dont-prompt-for-dependencies |
|
||
--prompt-for-dependencies |
|
||
-a |
--all |
|
|
-i |
--interactive |
|
|
--from EMAIL |
|
||
-A |
--author EMAIL |
|
|
--to EMAIL |
|
||
--cc EMAIL |
|
||
--subject SUBJECT |
|
||
--in-reply-to EMAIL |
|
||
-o |
--output FILE |
|
|
-O |
--output-auto-name[=DIRECTORY] |
|
|
--sign |
|
||
--sign-as KEYID |
|
||
--sign-ssl IDFILE |
|
||
--dont-sign,--no-sign |
|
||
--dry-run |
|
||
--xml-output |
|
||
-s |
--summary |
|
|
--no-summary |
|
||
--edit-description |
|
||
--dont-edit-description,--no-edit-description |
|
||
--set-default |
|
||
--no-set-default |
|
||
--repodir DIRECTORY |
|
||
--sendmail-command COMMAND |
|
||
--ignore-unrelated-repos |
|
Advanced options:
--logfile FILE |
|
||
--delete-logfile |
|
||
--no-delete-logfile |
|
||
--remote-repo URL |
|
||
--context FILENAME |
|
||
--ssh-cm |
|
||
--no-ssh-cm |
|
||
--http-pipelining |
|
||
--no-http-pipelining |
|
||
--no-cache |
|
||
--remote-darcs COMMAND |
|
Do not confuse the --author options with the return address
that darcs send will set for your patch bundle.
For example, if you have two email addresses A and B:
--author A but your machine is configured to send mail from
address B by default, then the return address on your message will be B.
--from A and your mail client supports setting the
From: address arbitrarily (some non-Unix-like mail clients, especially,
may not support this), then the return address will be A; if it does
not support this, then the return address will be B.
--from nor --author, then the return
address will be B.
In addition, unless you specify the sendmail command with
--sendmail-command, darcs sends email using the default email
command on your computer. This default command is determined by the
configure script. Thus, on some non-Unix-like OSes,
--from is likely to not work at all.
The --output, --output-auto-name, and --to 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
specify --output-auto-name, the patch bundle is saved to a file with an
automatically generated name. If you give one or more --to arguments,
the bundle of patches is sent to those locations. The locations may either be email
addresses or urls that the patch should be submitted to via HTTP.
If you don't provide any of these options, darcs will look at the contents of
the _darcs/prefs/email file in the target repository (if it exists), and
send the patch by email to that address. In this case, you may use the
--cc option to specify additional recipients without overriding the
default repository email address.
If _darcs/prefs/post exists in the target repository, darcs will upload to the URL contained in that file, which may either be a mailto: URL, or an http:// URL. In the latter case, the patch is posted to that URL.
If there is no email address associated with the repository, darcs will prompt you for an email address.
Use the --subject flag to set the subject of the e-mail to be sent.
If you don't provide a subject on the command line, darcs will make one up
based on names of the patches in the patch bundle.
Use the --in-reply-to flag to set the In-Reply-To and References headers
of the e-mail to be sent. By default no additional headers are included so e-mail
will not be treated as reply by mail readers.
The --patches, --matches, --tags, and --no-deps
options can be used to select which patches to send, as described in
subsection
.
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 a message
to go along with your patches.
If you want to use a command different from the default one for sending email,
you need to specify a command line with the --sendmail-command option. The
command line can contain some format specifiers which are replaced by the actual
values. Accepted format specifiers are %s for subject, %t for to,
%c for cc, %b for the body of the mail, %f for from, %a
for the patch bundle and the same specifiers in uppercase for the URL-encoded values.
Additionally you can add %< to the end of the command line if the command
expects the complete email message on standard input. E.g. the command lines for evolution
and msmtp look like this:
evolution "mailto:%T?subject=%S&attach=%A&cc=%C&body=%B" msmtp -t %<
If no file is supplied, the bundle is read from standard input.
If given an email instead of a patch bundle, Darcs will look for the bundle as a MIME attachment to that email. Currently this will fail if the MIME boundary is rewritten, such as in Courier and Mail.app.
If the `-reply noreply@example.net' option is used, and the bundle is attached to an email, Darcs will send a report (indicating success or failure) to the sender of the bundle (the To field). The argument to noreply is the address the report will appear to originate FROM.
The -cc option will cause the report to be CC'd to another address, for example `-cc reports@lists.example.net,admin@lists.example.net'. Using -cc without -reply is undefined.
If gpg(1) is installed, you can use `-verify pubring.gpg' to reject bundles that aren't signed by a key in pubring.gpg.
If -test is supplied and a test is defined (see `darcs setpref'), the bundle will be rejected if the test fails after applying it. In that case, the rejection email from -reply will include the test output.
A patch bundle may introduce unresolved conflicts with existing patches or with the working tree. By default, Darcs will add conflict markers (see `darcs mark-conflicts').
The -allow-conflicts option will skip conflict marking; this is useful when you want to treat a repository as just a bunch of patches, such as using `darcs pull -union' to download of your co-workers patches before going offline.
This can mess up unrecorded changes in the working tree, forcing you to resolve the conflict immediately. To simply reject bundles that introduce unresolved conflicts, using the -dont-allow-conflicts option. Making this the default in push-based workflows is strongly recommended.
Unlike most Darcs commands, `darcs apply' defaults to -all. Use the -interactive option to pick which patches to apply from a bundle.
Usage: darcs apply [OPTION]... <PATCHFILE>
Options:
--verify PUBRING |
|
||
--verify-ssl KEYS |
|
||
--no-verify |
|
||
-a |
--all |
|
|
-i |
--interactive |
|
|
--dry-run |
|
||
--xml-output |
|
||
--mark-conflicts |
|
||
--allow-conflicts |
|
||
--no-resolve-conflicts |
|
||
--dont-allow-conflicts,--no-allow-conflicts |
|
||
--skip-conflicts |
|
||
--external-merge COMMAND |
|
||
--no-test |
|
||
--test |
|
||
--leave-test-directory |
|
||
--remove-test-directory |
|
||
--repodir DIRECTORY |
|
Advanced options:
--reply FROM |
|
||
--cc EMAIL |
|
||
--happy-forwarding |
|
||
--no-happy-forwarding |
|
||
--sendmail-command COMMAND |
|
||
--ignore-times |
|
||
--no-ignore-times |
|
||
--compress |
|
||
--dont-compress,--no-compress |
|
||
--set-scripts-executable |
|
||
--dont-set-scripts-executable,--no-set-scripts-executable |
|
||
--umask UMASK |
|
||
--restrict-paths |
|
||
--dont-restrict-paths,--no-restrict-paths |
|
Darcs apply accepts a single argument, which is the name of the patch file to be applied. If you omit this argument, the patch is read from standard input. Darcs also interprets an argument of `' to mean it should read the file from standard input. This allows you to use apply with a pipe from your email program, for example.
You can use an external interactive merge tool to resolve conflicts with the
flag --external-merge. For more details see
subsection
.
If you want to use a command different from the default one for sending mail,
you need to specify a command line with the --sendmail-command option.
The command line can contain the format specifier %t for to
and you can add %< to the end of the command line if the command
expects the complete mail on standard input. For example, the command line for
msmtp looks like this:
msmtp -t %<
With the -summary option, the changes are condensed to one line per file, with mnemonics to indicate the nature and extent of the change. The -look-for-adds option causes candidates for `darcs add' to be included in the summary output. Summary mnemonics are as follows:
`A f' and `A d/' respectively mean an added file or directory. `R f' and `R d/' respectively mean a removed file or directory. `M f -N +M rP' means a modified file, with N lines deleted, M lines added, and P lexical replacements. `f -> g' means a moved file or directory.
An exclamation mark (!) as in `R! foo.c', means the hunk is known to conflict with a hunk in another patch. The phrase `duplicated' means the hunk is known to be identical to a hunk in another patch.
By default, `darcs whatsnew' uses Darcs' internal format for changes. To see some context (unchanged lines) around each change, use the -unified option. To view changes in conventional `diff' format, use the `darcs diff' command; but note that `darcs whatsnew' is faster.
This command exits unsuccessfully (returns a non-zero exit status) if there are no unrecorded changes.
Usage: darcs whatsnew [OPTION]... [FILE or DIRECTORY]...
Options:
-s |
--summary |
|
|
--no-summary |
|
||
-u |
--unified |
|
|
--no-unified |
|
||
-l |
--look-for-adds |
|
|
--dont-look-for-adds,--no-look-for-adds |
|
||
--repodir DIRECTORY |
|
Advanced options:
--ignore-times |
|
||
--no-ignore-times |
|
||
--boring |
|
||
--no-boring |
|
||
--no-cache |
|
When given one or more files or directories as arguments, only patches which affect those files or directories are listed. This includes changes that happened to files before they were moved or renamed.
When given a -from-tag, -from-patch or -from-match, only changes since that tag or patch are listed. Similarly, the -to-tag, -to-patch and -to-match options restrict the list to older patches.
The -last and -max-count options both limit the number of patches listed. The former applies BEFORE other filters, whereas the latter applies AFTER other filters. For example `darcs changes foo.c -max-count 3' will print the last three patches that affect foo.c, whereas `darcs changes -last 3 foo.c' will, of the last three patches, print only those that affect foo.c.
Three output formats exist. The default is -human-readable. You can also select -context, which is the internal format (as seen in patch bundles) that can be re-read by Darcs (e.g. `darcs get -context').
Finally, there is -xml-output, which emits valid XML... unless a the patch metadata (author, name or description) contains a non-ASCII character and was recorded in a non-UTF8 locale.
Note that while the -context flag may be used in conjunction with -xml-output or -human-readable, in neither case will darcs get be able to read the output. On the other hand, sufficient information WILL be output for a knowledgeable human to recreate the current state of the repository.
Usage: darcs changes [OPTION]... [FILE or DIRECTORY]...
Options:
--to-match PATTERN |
|
||
--to-patch REGEXP |
|
||
--to-tag REGEXP |
|
||
--from-match PATTERN |
|
||
--from-patch REGEXP |
|
||
--from-tag REGEXP |
|
||
--last NUMBER |
|
||
-n |
--index N-M |
|
|
--matches PATTERN |
|
||
-p |
--patches REGEXP |
|
|
-t |
--tags REGEXP |
|
|
--max-count NUMBER |
|
||
--only-to-files |
|
||
--no-only-to-files |
|
||
--context |
|
||
--xml-output |
|
||
--human-readable |
|
||
--number |
|
||
--count |
|
||
-s |
--summary |
|
|
--no-summary |
|
||
--reverse |
|
||
--no-reverse |
|
||
--repo URL |
|
||
--repodir DIRECTORY |
|
||
-a |
--all |
|
|
-i |
--interactive |
|
Advanced options:
--ssh-cm |
|
||
--no-ssh-cm |
|
||
--http-pipelining |
|
||
--no-http-pipelining |
|
||
--no-cache |
|
||
--remote-darcs COMMAND |
|
The show command provides access to several subcommands which can be used to investigate the state of a repository.
An author's name or email address may change over time. To tell Darcs when multiple author strings refer to the same individual, create an `.authorspellings' file in the root of the working tree. Each line in this file begins with an author's canonical name and address, and may be followed by a comma separated list of extended regular expressions. Blank lines and lines beginning with two hyphens are ignored. The format of .authorspelling can be described by this pattern:
name <address> [, regexp ]*
There are some pitfalls concerning special characters: Whitespaces are stripped, if you need space in regexp use [ ]. Because comma serves as a separator you have to escape it if you want it in regexp. Note that .authorspelingfile use extended regular expressions so +, ? and so on are metacharacters and you need to escape them to be interpreted literally.
Any patch with an author string that matches the canonical address or any of the associated regexps is considered to be the work of that author. All matching is case-insensitive and partial (it can match a substring). Use ^,$ to match the whole string in regexps
Currently this canonicalization step is done only in `darcs show authors'. Other commands, such as `darcs changes' use author strings verbatim.
An example .authorspelling file is:
- This is a comment.
Fred Nurk <fred@example.com>
John Snagge <snagge@bbc.co.uk>, John, snagge@, js@(si|mit).edu
Chuck Jones
, Jr. <chuck@pobox.com>, cj
+user@example.com
Usage: darcs show authors [OPTION]...
Options:
--repodir DIRECTORY |
|
Usage: darcs show contents [OPTION]... [FILE]...
Options:
--match PATTERN |
|
||
-p |
--patch REGEXP |
|
|
-t |
--tag REGEXP |
|
|
-n |
--index N |
|
|
--repodir DIRECTORY |
|
A file is `pending' if it has been added but not recorded. By default, pending files (and directories) are listed; the -no-pending option prevents this.
By default `darcs show files' lists both files and directories, but the alias `darcs show manifest' only lists files. The -files, -directories, -no-files and -no-directories modify this behaviour.
By default entries are one-per-line (i.e. newline separated). This can cause problems if the files themselves contain newlines or other control characters. To get aroudn this, the -null option uses the null character instead. The script interpreting output from this command needs to understand this idiom; `xargs -0' is such a command.
For example, to list version-controlled files by size:
darcs show files -0 | xargs -0 ls -ldS
Usage: darcs show files [OPTION]... [FILE or DIRECTORY]...
Options:
--files |
|
||
--no-files |
|
||
--directories |
|
||
--no-directories |
|
||
--pending |
|
||
--no-pending |
|
||
-0 |
--null |
|
|
--match PATTERN |
|
||
-p |
--patch REGEXP |
|
|
-t |
--tag REGEXP |
|
|
-n |
--index N |
|
|
--repodir DIRECTORY |
|
Tab characters (ASCII character 9) in tag names are changed to spaces for better interoperability with shell tools. A warning is printed if this happens.
Usage: darcs show tags [OPTION]...
Options:
--repodir DIRECTORY |
|
By default, the number of patches is shown. If this data isn't needed, use -no-files to accelerate this command from O(n) to O(1).
By default, output is in a human-readable format. The -xml-output option can be used to generate output for machine postprocessing.
Usage: darcs show repo [OPTION]...
Options:
--repodir DIRECTORY |
|
||
--files |
|
||
--no-files |
|
||
--xml-output |
|
To reproduce the state of a repository `R' as at tag `t', use the command `darcs get -tag t R'. The command `darcs show tags' lists all tags in the current repository.
Tagging also provides significant performance benefits: when Darcs reaches a shared tag that depends on all antecedent patches, it can simply stop processing.
Like normal patches, a tag has a name, an author, a timestamp and an optional long description, but it does not change the working tree. A tag can have any name, but it is generally best to pick a naming scheme and stick to it.
The `darcs tag' command accepts the -pipe option, which behaves as described in `darcs record'.
Usage: darcs tag [OPTION]... [TAGNAME]
Options:
-m |
--patch-name PATCHNAME |
|
|
-A |
--author EMAIL |
|
|
--pipe |
|
||
-i |
--interactive |
|
|
--edit-long-comment |
|
||
--skip-long-comment |
|
||
--prompt-long-comment |
|
||
--repodir DIRECTORY |
|
Advanced options:
--compress |
|
||
--dont-compress,--no-compress |
|
||
--umask UMASK |
|
Valid preferences are:
test - a shell command that runs regression tests predist - a shell command to run before `darcs dist' boringfile - the path to a version-controlled boring file binariesfile - the path to a version-controlled binaries file
For example, a project using GNU autotools, with a `make test' target to perform regression tests, might enable Darcs' integrated regression testing with the following command:
darcs setpref test 'autoconf && ./configure && make && make test'
Note that merging is not currently implemented for preferences: if two patches attempt to set the same preference, the last patch applied to the repository will always take precedence. This is considered a low-priority bug, because preferences are seldom set.
Usage: darcs setpref [OPTION]... <PREF> <VALUE>
Options:
--repodir DIRECTORY |
|
Advanced options:
--umask UMASK |
|
If the repository is in darcs-1 format and has a checkpoint, you can use the -partial option to start checking from the latest checkpoint. This is the default for partial darcs-1 repositories; the -complete option to forces a full check.
If a regression test is defined (see `darcs setpref') it will be run by `darcs check'. Use the -no-test option to disable this.
Usage: darcs check [OPTION]...
Options:
--complete |
|
||
--partial |
|
||
--no-test |
|
||
--test |
|
||
--leave-test-directory |
|
||
--remove-test-directory |
|
||
--repodir DIRECTORY |
|
||
--ignore-times |
|
||
--no-ignore-times |
|
If you like, you can configure your repository to be able to run a test suite of some sort. You can do this by using ``setpref'' to set the ``test'' value to be a command to run, e.g.
% darcs setpref test "sh configure && make && make test"Or, if you want to define a test specific to one copy of the repository, you could do this by editing the file
_darcs/prefs/prefs.
Normally darcs deletes the directory in which the test was run afterwards.
Sometimes (especially when the test fails) you'd prefer to be able to be
able to examine the test directory after the test is run. You can do this
by specifying the --leave-test-directory flag. Alas, there is no
way to make darcs leave the test directory only if the test fails. The
opposite of --leave-test-directory is
--remove-test-directory, which could come in handy if you choose to
make --leave-test-directory the default (see
section
).
The default optimization moves recent patches (those not included in the latest tag) to the `front', reducing the amount that a typical remote command needs to download. It should also reduce the CPU time needed for some operations.
The `darcs optimize -relink' command hard-links patches that the current repository has in common with its peers. Peers are those repositories listed in _darcs/prefs/sources, or defined with the `-sibling' option (which can be used multiple times).
Darcs uses hard-links automatically, so this command is rarely needed. It is most useful if you used `cp -r' instead of `darcs get' to copy a repository, or if you pulled the same patch from a remote repository into multiple local repositories.
A `darcs optimize -relink-pristine' command is also available, but generally SHOULD NOT be used. It results in a relatively small space saving at the cost of making many Darcs commands MUCH slower.
By default patches are compressed with zlib (RFC 1951) to reduce storage (and download) size. In exceptional circumstances, it may be preferable to avoid compression. In this case the `-dont-compress' option can be used (e.g. with `darcs record') to avoid compression.
The `darcs optimize -uncompress' and `darcs optimize -compress' commands can be used to ensure existing patches in the current repository are respectively uncompressed or compressed. Note that repositories in the legacy `old-fashioned-inventory' format have a .gz extension on patch files even when uncompressed.
There is one more optimization which CAN NOT be performed by this command. Every time your record a patch, a new inventory file is written to _darcs/inventories/, and old inventories are never reaped.
If _darcs/inventories/ is consuming a relatively large amount of space, you can safely reclaim it by using `darcs get' to make a complete copy of the repo. When doing so, don't forget to copy over any unsaved changes you have made to the working tree or to unversioned files in _darcs/prefs/ (such as _darcs/prefs/author).
Usage: darcs optimize [OPTION]...
Options:
--repodir DIRECTORY |
|
||
--reorder-patches |
|
||
--sibling URL |
|
||
--relink |
|
||
--relink-pristine |
|
||
--upgrade |
|
||
--pristine |
|
Advanced options:
--compress |
|
||
--dont-compress,--no-compress |
|
||
--uncompress |
|
||
--umask UMASK |
|
The --reorder-patches option causes Darcs to create an optimal
ordering of its internal patch inventory. This may help to produce shorter
`context' lists when sending patches, and may improve performance for some
other operations as well. You should not run --reorder-patches on a
repository from which someone may be simultaneously pulling or getting, as
this could lead to repository corruption.
The --upgrade option for darcs optimize performs an inplace
upgrade of your repository to the lastest compatible format. Right now
means that darcs 1 old-fashioned repositories will be upgraded to darcs-1
hashed repositories (and notably, not to darcs 2 repositories as that would not
be compatible; see darcs convert).
Do not copy draft patches between repositories, because a finished patch cannot be copied into a repository that contains a draft of the same patch. If this has already happened, `darcs obliterate' can be used to remove the draft patch.
Do not run amend-record in repository that other developers can pull from, because if they pull while an amend-record is in progress, their repository may be corrupted.
When recording a draft patch, it is a good idea to start the name with `DRAFT:' so that other developers know it is not finished. When finished, remove it with `darcs amend-record -edit-long-comment'. To change the patch name without starting an editor, use -patch-name.
Like `darcs record', if you call amend-record with files as arguments, you will only be asked about changes to those files. So to amend a patch to foo.c with improvements in bar.c, you would run:
darcs amend-record -match 'touch foo.c' bar.c
It is usually a bad idea to amend another developer's patch. To make amend-record only ask about your own patches by default, you can add something like `amend-record match David Roundy' to /.darcs/defaults, where `David Roundy' is your name. On Windows use C:/Documents And Settings/user/Application Data/darcs/defaults
Usage: darcs amend-record [OPTION]... [FILE or DIRECTORY]...
Options:
--match PATTERN |
|
||
-p |
--patch REGEXP |
|
|
-n |
--index N |
|
|
--no-test |
|
||
--test |
|
||
--leave-test-directory |
|
||
--remove-test-directory |
|
||
-a |
--all |
|
|
-i |
--interactive |
|
|
-A |
--author EMAIL |
|
|
-m |
--patch-name PATCHNAME |
|
|
--ask-deps |
|
||
--no-ask-deps |
|
||
--edit-long-comment |
|
||
--skip-long-comment |
|
||
--prompt-long-comment |
|
||
-l |
--look-for-adds |
|
|
--dont-look-for-adds,--no-look-for-adds |
|
||
--repodir DIRECTORY |
|
Advanced options:
--compress |
|
||
--dont-compress,--no-compress |
|
||
--ignore-times |
|
||
--no-ignore-times |
|
||
--umask UMASK |
|
||
--set-scripts-executable |
|
||
--dont-set-scripts-executable,--no-set-scripts-executable |
|
Usage: darcs rollback [OPTION]... [FILE or DIRECTORY]...
Options:
--from-match PATTERN |
|
||
--from-patch REGEXP |
|
||
--from-tag REGEXP |
|
||
--last NUMBER |
|
||
--matches PATTERN |
|
||
-p |
--patches REGEXP |
|
|
-t |
--tags REGEXP |
|
|
-a |
--all |
|
|
-i |
--interactive |
|
|
-A |
--author EMAIL |
|
|
-m |
--patch-name PATCHNAME |
|
|
--edit-long-comment |
|
||
--skip-long-comment |
|
||
--prompt-long-comment |
|
||
--no-test |
|
||
--test |
|
||
--leave-test-directory |
|
||
--remove-test-directory |
|
||
--repodir DIRECTORY |
|
Advanced options:
--compress |
|
||
--dont-compress,--no-compress |
|
||
--umask UMASK |
|
Usage: darcs unrecord [OPTION]...
Options:
--from-match PATTERN |
|
||
--from-patch REGEXP |
|
||
--from-tag REGEXP |
|
||
--last NUMBER |
|
||
--matches PATTERN |
|
||
-p |
--patches REGEXP |
|
|
-t |
--tags REGEXP |
|
|
--no-deps |
|
||
--dont-prompt-for-dependencies |
|
||
--prompt-for-dependencies |
|
||
-a |
--all |
|
|
-i |
--interactive |
|
|
--repodir DIRECTORY |
|
Advanced options:
--compress |
|
||
--dont-compress,--no-compress |
|
||
--umask UMASK |
|
Unrecord can be thought of as undo-record. If a record is followed by an unrecord, everything looks like before the record; all the previously unrecorded changes are back, and can be recorded again in a new patch. The unrecorded patch however is actually removed from your repository, so there is no way to record it again to get it back.6.5.
If you want to remove
the changes from the working copy too (where they otherwise will show
up as unrecorded changes again), you'll also need to darcs revert.
To do unrecord and revert in one go, you can use darcs obliterate.
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 in the other repository. So if you really want to undo the result of a pull operation, use obliterate! 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.
WARNING: Unrecord should not be run when there is a possibility that another user may be pulling from the same repository. Attempting to do so may cause repository corruption.
Usually you only want to unrecord the latest changes, and almost never would you want to unrecord changes before a tag--you would have to have unrecorded the tag as well to do that. Therefore, and for efficiency, darcs only prompts you for the latest patches, after some optimal tag.
If you do want to unrecord more patches in one go,
there are the --from and --last options
to set the earliest patch selectable to unrecord.
The --patches, --matches, --tags, and --no-deps
options can be used to select which patches to unrecord, as described in
subsection
.
With these options you can specify
what patch or patches to be prompted for by unrecord.
This is especially useful when you want to unrecord patches with dependencies,
since all the dependent patches (but no others) will be included in the choices.
Or if you use --no-deps you won't be asked about patches that can't be
unrecorded due to depending patches.
Selecting patches can be slow, so darcs cuts the search at the last
optimized tag. Use the --from or --last options to search
more or fewer patches.
Usage: darcs obliterate [OPTION]...
Options:
--from-match PATTERN |
|
||
--from-patch REGEXP |
|
||
--from-tag REGEXP |
|
||
--last NUMBER |
|
||
--matches PATTERN |
|
||
-p |
--patches REGEXP |
|
|
-t |
--tags REGEXP |
|
|
--no-deps |
|
||
--dont-prompt-for-dependencies |
|
||
--prompt-for-dependencies |
|
||
-a |
--all |
|
|
-i |
--interactive |
|
|
--repodir DIRECTORY |
|
||
-s |
--summary |
|
|
--no-summary |
|
||
--dry-run |
|
||
--xml-output |
|
Advanced options:
--compress |
|
||
--dont-compress,--no-compress |
|
||
--ignore-times |
|
||
--no-ignore-times |
|
||
--umask UMASK |
|
Note that unpull was the old name for obliterate. Unpull is still an hidden alias for obliterate.
WARNING: Obliterate should not be run when there is a possibility that another user may be pulling from the same repository. Attempting to do so may cause repository corruption.
Usually you only want to obliterate the latest changes, and almost never would you want to obliterate changes before a tag--you would have to have obliterated the tag as well to do that. Therefore, and for efficiency, darcs only prompts you for the latest patches, after some optimal tag.
If you do want to obliterate more patches in one go, there are the
--from and --last options to set the earliest patch
selectable to obliterate.
The --patches, --matches, --tags, and --no-deps
options can be used to select which patches to obliterate, as described in
subsection
.
With these options you can specify what patch or patches to be prompted for
by obliterate. This is especially useful when you want to obliterate patches with
dependencies, since all the dependent patches (but no others) will be
included in the choices. Or if you use --no-deps you won't be asked
about patches that can't be obliterated due to depending patches.
Selecting patches can be slow, so darcs cuts the search at the last
optimized tag. Use the --from or --last options to search
more or fewer patches.
In you accidentally reverted something you wanted to keep (for example, typing `darcs rev -a' instead of `darcs rec -a'), you can immediately run `darcs unrevert' to restore it. This is only guaranteed to work if the repository has not changed since `darcs revert' ran.
Usage: darcs revert [OPTION]... [FILE or DIRECTORY]...
Options:
-a |
--all |
|
|
-i |
--interactive |
|
|
--repodir DIRECTORY |
|
Advanced options:
--ignore-times |
|
||
--no-ignore-times |
|
||
--umask UMASK |
|
This command may fail if the repository has changed since the revert took place. Darcs will ask for confirmation before executing an interactive command that will DEFINITELY prevent unreversion.
Usage: darcs unrevert [OPTION]...
Options:
--ignore-times |
|
||
--no-ignore-times |
|
||
-a |
--all |
|
|
-i |
--interactive |
|
|
--repodir DIRECTORY |
|
Advanced options:
--umask UMASK |
|
Usage: darcs diff [OPTION]... [FILE or DIRECTORY]...
Options:
--to-match PATTERN |
|
||
--to-patch REGEXP |
|
||
--to-tag REGEXP |
|
||
--from-match PATTERN |
|
||
--from-patch REGEXP |
|
||
--from-tag REGEXP |
|
||
--match PATTERN |
|
||
-p |
--patch REGEXP |
|
|
--last NUMBER |
|
||
-n |
--index N-M |
|
|
--diff-command COMMAND |
|
||
--diff-opts OPTIONS |
|
||
-u |
--unified |
|
|
--no-unified |
|
||
--repodir DIRECTORY |
|
||
--store-in-memory |
|
||
--no-store-in-memory |
|
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 -- -uto get a diff in the unified format. Actually, thanks to the wonders of getopt you need the ``
--'' shown above before any arguments to diff.
You can also specify additional arguments to diff using the
--diff-opts flag. The above command would look like this:
% darcs diff --diff-opts -u -t 0.9.8 -t 0.9.10This may not seem like an improvement, but it really pays off when you want to always give diff the same options. You can do this by adding
% diff diff-opts -udpto your
_darcs/prefs/defaults file.
If you want to view only the differences to one or more files, you can do so with a command such as
% darcs diff foo.c bar.c baz/
You can use a different program to view differences by including
the flag --diff-command, e.g.
--diff-command 'opendiff %1 %2'.The
%1 and %2 are replaced with the two versions to be
merged. The above example works with the FileMerge.app tool that comes with
Apple's developer tools. To use xxdiff, you would use
--diff-command 'xxdiff %1 %2'To use
kdiff3, you can use
--diff-command 'kdiff3 %1 %2'
Note that the command is split into space-separated words and the first one is
execed with the rest as arguments--it is not a shell command. Also
the substitution of the % escapes is only done on complete words.
See
for how you might work around this fact, for example,
with Emacs' Ediff package.
Note also that the --diff-opts flag is ignored if you use this option.
The -summary option will result in a summarized patch annotation, similar to `darcs whatsnew'. It has no effect on file annotations.
By default, output is in a human-readable format. The -xml-output option can be used to generate output for machine postprocessing.
Usage: darcs annotate [OPTION]... [FILE or DIRECTORY]...
Options:
-s |
--summary |
|
|
--no-summary |
|
||
-u |
--unified |
|
|
--no-unified |
|
||
--human-readable |
|
||
--xml-output |
|
||
--match PATTERN |
|
||
-p |
--patch REGEXP |
|
|
-t |
--tag REGEXP |
|
|
-n |
--index N |
|
|
--creator-hash HASH |
|
||
--repodir DIRECTORY |
|
--unified flag implies --human-readable, and causes
the output to remain in a darcs-specific format that is similar to that produced
by diff --unified.
If a directory name is given, annotate will output details of the last modifying patch for each file in the directory and the directory itself. The details look like this:
# Created by [bounce handling patch
# mark**20040526202216] as ./test/m7/bounce_handling.pl
bounce_handling.pl
If a patch name and a directory are given, these details are output for the time after that patch was applied. If a directory and a tag name are given, the details of the patches involved in the specified tagged version will be output.
If a file name is given, the last modifying patch details of that file will be output, along with markup indicating patch details when each line was last (and perhaps next) modified.
If a patch name and a file name are given, these details are output for the time after that patch was applied.
The --creator-hash option should only be used in combination with a
file or directory to be annotated. In this case, the name of that file or
directory is interpreted to be its name at the time it was created,
and the hash given along with --creator-hash indicates the patch
that created the file or directory. This allows you to (relatively) easily
examine a file even if it has been renamed multiple times.
The show command provides access to several subcommands which can be used to investigate the state of a repository.
An author's name or email address may change over time. To tell Darcs when multiple author strings refer to the same individual, create an `.authorspellings' file in the root of the working tree. Each line in this file begins with an author's canonical name and address, and may be followed by a comma separated list of extended regular expressions. Blank lines and lines beginning with two hyphens are ignored. The format of .authorspelling can be described by this pattern:
name <address> [, regexp ]*
There are some pitfalls concerning special characters: Whitespaces are stripped, if you need space in regexp use [ ]. Because comma serves as a separator you have to escape it if you want it in regexp. Note that .authorspelingfile use extended regular expressions so +, ? and so on are metacharacters and you need to escape them to be interpreted literally.
Any patch with an author string that matches the canonical address or any of the associated regexps is considered to be the work of that author. All matching is case-insensitive and partial (it can match a substring). Use ^,$ to match the whole string in regexps
Currently this canonicalization step is done only in `darcs show authors'. Other commands, such as `darcs changes' use author strings verbatim.
An example .authorspelling file is:
- This is a comment.
Fred Nurk <fred@example.com>
John Snagge <snagge@bbc.co.uk>, John, snagge@, js@(si|mit).edu
Chuck Jones
, Jr. <chuck@pobox.com>, cj
+user@example.com
Usage: darcs show authors [OPTION]...
Options:
--repodir DIRECTORY |
|
Usage: darcs show contents [OPTION]... [FILE]...
Options:
--match PATTERN |
|
||
-p |
--patch REGEXP |
|
|
-t |
--tag REGEXP |
|
|
-n |
--index N |
|
|
--repodir DIRECTORY |
|
A file is `pending' if it has been added but not recorded. By default, pending files (and directories) are listed; the -no-pending option prevents this.
By default `darcs show files' lists both files and directories, but the alias `darcs show manifest' only lists files. The -files, -directories, -no-files and -no-directories modify this behaviour.
By default entries are one-per-line (i.e. newline separated). This can cause problems if the files themselves contain newlines or other control characters. To get aroudn this, the -null option uses the null character instead. The script interpreting output from this command needs to understand this idiom; `xargs -0' is such a command.
For example, to list version-controlled files by size:
darcs show files -0 | xargs -0 ls -ldS
Usage: darcs show files [OPTION]... [FILE or DIRECTORY]...
Options:
--files |
|
||
--no-files |
|
||
--directories |
|
||
--no-directories |
|
||
--pending |
|
||
--no-pending |
|
||
-0 |
--null |
|
|
--match PATTERN |
|
||
-p |
--patch REGEXP |
|
|
-t |
--tag REGEXP |
|
|
-n |
--index N |
|
|
--repodir DIRECTORY |
|
Tab characters (ASCII character 9) in tag names are changed to spaces for better interoperability with shell tools. A warning is printed if this happens.
Usage: darcs show tags [OPTION]...
Options:
--repodir DIRECTORY |
|
By default, the number of patches is shown. If this data isn't needed, use -no-files to accelerate this command from O(n) to O(1).
By default, output is in a human-readable format. The -xml-output option can be used to generate output for machine postprocessing.
Usage: darcs show repo [OPTION]...
Options:
--repodir DIRECTORY |
|
||
--files |
|
||
--no-files |
|
||
--xml-output |
|
This command DOES NOT modify the source repository; a new destination repository is created. It is safe to run this command more than once on a repository (e.g. for testing), before the final conversion.
WARNING: the repository produced by this command is not understood by Darcs 1.x, and patches cannot be exchanged between repositories in darcs-1 and darcs-2 formats.
Furthermore, darcs 2 repositories created by different invocations of this command SHOULD NOT exchange patches, unless those repositories had no patches in common when they were converted. (That is, within a set of repos that exchange patches, no patch should be converted more than once.)
Due to this limitation, migrating a multi-branch project is a little awkward. Sorry! Here is the recommended process:
1. for each branch `foo', tag that branch with `foo-final'; 2. merge all branches together (-allow-conflicts may help); 3. run `darcs optimize -reorder' on the result; 4. run `darcs convert' to create a merged darcs-2 repository; 5. re-create each branch by calling `darcs get -tag foo-final' on the darcs-2 repository; and finally 6. use `darcs obliterate' to delete the foo-final tags.
Usage: darcs convert [OPTION]... <SOURCE> [<DESTINATION>]
Options:
--repo-name DIRECTORY,--repodir DIRECTORY |
|
||
--set-scripts-executable |
|
||
--dont-set-scripts-executable,--no-set-scripts-executable |
|
Advanced options:
--ssh-cm |
|
||
--no-ssh-cm |
|
||
--http-pipelining |
|
||
--no-http-pipelining |
|
||
--no-cache |
|
||
--remote-darcs COMMAND |
|
However, you might revert or manually delete these markers without actually resolving the conflict. In this case, `darcs mark-conflicts' is useful to show where any unresolved conflicts. It is also useful if `darcs apply' is called with -apply-conflicts, where conflicts aren't marked initially.
Any unrecorded changes to the working tree WILL be lost forever when you run this command! You will be prompted for confirmation before this takes place.
This command was historically called `resolve', and this deprecated alias still exists for backwards-compatibility.
Usage: darcs mark-conflicts [OPTION]...
Options:
--ignore-times |
|
||
--no-ignore-times |
|
||
--repodir DIRECTORY |
|
Advanced options:
--umask UMASK |
|
If a predist command is set (see `darcs setpref'), that command will be run on the tarball contents prior to archiving. For example, autotools projects would set it to `autoconf && automake'.
By default, the tarball (and the top-level directory within the tarball) has the same name as the repository, but this can be overridden with the -dist-name option.
Usage: darcs dist [OPTION]...
Options:
-d |
--dist-name DISTNAME |
|
|
--repodir DIRECTORY |
|
||
--match PATTERN |
|
||
-p |
--patch REGEXP |
|
|
-t |
--tag REGEXP |
|
|
-n |
--index N |
|
|
--store-in-memory |
|
||
--no-store-in-memory |
|
Usage: darcs trackdown [OPTION]... [[INITIALIZATION] COMMAND]
Options:
--repodir DIRECTORY |
|
Advanced options:
--set-scripts-executable |
|
||
--dont-set-scripts-executable,--no-set-scripts-executable |
|
Trackdown is helpful for locating when something was broken. It creates a temporary directory with the latest repository content in it and cd to it. First, and only once, it runs the initialization command if any, for example
'autoconf; ./configure >/dev/null'Then it runs the test command, for example
'make && cd tests && sh /tmp/test.sh'While the test command exits with an error return code, darcs ``unapplies'' one patch from the version controlled files to retrieve an earlier version, and repeats the test command. If the test command finally succeeds, the name of the hunted down patch is found in the output before the last test run.
FIXME: It is still rather primitive. Currently it just goes back over the history in reverse order trying each version. I'd like for it to explore different patch combinations, to try to find the minimum number of patches that you would need to obliterate in order to make the test succeed.
FIXME: I also would like to add an interface by which you can tell it which patches it should consider not including. Without such a feature, the following command:
% darcs trackdown 'make && false'would result in compiling every version in the repository-which is a rather tedious prospect.
% darcs trackdown 'grep FIXME Record.lhs'
To find the latest version that compiles, you can run
% darcs trackdown 'autoconf' './configure && make'
Trackdown can also be used to see how other features of the code changed with time. For example
% darcs trackdown 'autoconf; ./configure' \ "make darcs > /dev/null && cd ~/darcs && time darcs check && false"would let you see how long `darcs check' takes to run on each previous version of darcs that will actually compile. The ``
&& false''
ensures that trackdown keeps going.
Usage: darcs repair [OPTION]...
Options:
--repodir DIRECTORY |
|
Advanced options:
--umask UMASK |
|
Darcs is refreshingly different from CVS.
CVS keeps version controlled data in a central repository, and requires that users check out a working directory whenever they wish to access the version-controlled sources. In order to modify the central repository, a user needs to have write access to the central repository; if he doesn't, CVS merely becomes a tool to get the latest sources.
In darcs there is no distinction between working directories and repositories. In order to work on a project, a user makes a local copy of the repository he wants to work in; he may then harness the full power of version control locally. In order to distribute his changes, a user who has write access can push them to the remote repository; one who doesn't can simply send them by e-mail in a format that makes them easy to apply on the remote system.
--dry-run
(summarize remote changes)
--summary
(summarize local changes)
^a
(list potential files to add)
Tools and instructions for migrating CVS repositories to darcs are provided on the darcs community website: http://wiki.darcs.net/DarcsWiki/ConvertingFromCvs
Although arch, like darcs, is a distributed system, and the two systems have many similarities (both require no special server, for example), their essential organization is very different.
Like CVS, arch keeps data in two types of data structures:
repositories (called ``archives'') and working directories. In order
to modify a repository, one must first check out a corresponding
working directory. This requires that users remember a number of
different ways of pushing data around -- tla get,
update, commit, archive-mirror and so on.
In darcs, on the other hand, there is no distinction between working
directories and repositories, and just checking out your sources
creates a local copy of a repository. This allows you to harness the
full power of version control in any scratch copy of your sources, and
also means that there are just two ways to push data around:
darcs record, which stores edits into your local
repository, and pull, which moves data between repositories.
(darcs push is merely the opposite of pull;
send and apply are just the two halves of push).
Because of the different models used by arch and darcs, it is
difficult to provide a complete equivalence between arch and darcs.
A rough correspondence for the everyday commands follows:
Tools and instructions for migrating arch repositories to darcs are provided on the darcs community website: http://wiki.darcs.net/DarcsWiki/ConvertingFromArch
If you have (or can install) the cabal-install package, this is the next best option, as this will resolve build dependencies automatically. To download, compile and install Darcs and its dependencies via cabal-install, simply run
cabal update cabal install darcs
ghc --make Setup ./Setup configure ./Setup build ./Setup install
This will require the following build dependencies:
Additional build dependencies are declared in the darcs.cabal file, and ./Setup configure will tell you if any required build dependencies aren't found. The build dependencies at time of writing (Darcs 2.3) are as follows:
Missing optional build dependencies are only listed if ./Setup configure is passed the -verbose argument. At time of writing they are:
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 to give patch theory better formalized foundations.
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 analogous 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 advise against taking this analogy too seriously, although it could provide some insight into how a physicist might think about darcs.
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 composite 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 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 representationB.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 treeB.2. Thus, the context of a patch consists of the set of patches that precede it.
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.
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 this 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!
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,
and
is represented as
,
where
is to be applied first, then
B.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
. 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 described by:
. 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.
addfile filename
rmfile filename
move oldname newname
changepref prefname oldval newval
adddir filename
rmdir filename
hunk FILE LINE# -LINE ... +LINE ...
Replace a token with a new token. Note that this format means that whitespace 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
Modify a binary file
binary FILENAME oldhex *HEXHEXHEX ... newhex *HEXHEXHEX ...
( <put patches here> (indented two) )
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.
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.
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 makes them a handy class. For example, commutation of two filepatches is trivial if they modify different files. If they happen to modify the same file, we'll have to check whether or not they commutex.
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 necessary, but is a good idea, since this
process is
, 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.
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.
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.
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.
, we see that the
merge of
Of course, 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
) 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
. 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
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.
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.
merger MERGERVERSION <first patch> <second patch>
Named patches are displayed 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.
A repository consists of a working directory, which has within it a
directory called _darcs. There must also be a subdirectory within
_darcs named patches. The patches directory contains
the actual patches which are in the repository. There must also be a
pristine tree, which may either be a directory containing a cache of
the version of the tree which has been recorded, or a stub, and may be
named either ``current'' or ``pristine''.
WARNING! Viewing files in the pristine cache is perfectly
acceptable, but if you view them with an editor (e.g. vi or Emacs), that
editor may create temporary files in the pristine tree
(_darcs/pristine/ or _darcs/current/), which will temporarily
cause your repository to be inconsistent. So don't record any
patches while viewing files in _darcs/current with an editor! A better
plan would be to restrict yourself to viewing these files with a pager such
as more or less.
Also within _darcs is the inventory file, which lists all the
patches that are in the repository. 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 repository, that repository 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
interpretation 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.
The _darcs directory also contains a directory called
``prefs'', which is described in Chapter
.
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.
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.
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.
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:
You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
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.
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.
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,
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,
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.
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.
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.
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the ``copyright'' line and a pointer to where the full notice is found.
one line to give the program's name and a brief idea of what it does.
![]()
Copyright (C)year
![]()
name of author
![]()
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C)year
![]()
name of author
![]()
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than show w and show c; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a ``copyright disclaimer'' for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
signature of Ty Coon
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.71)
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 -dir doc/manual doc/manual/bigpage.tex
The translation was initiated by darcs-unstable on 2010-03-10