The general format of a darcs command is
% darcs COMMAND OPTIONS ARGUMENTS ...Here COMMAND is a command such as add or record, which of course may have one or more arguments. Options have the form
--option
or -o
, while arguments vary from command to
command. There are many options which are common to a number of different
commands, which will be summarized here.
Every COMMAND accepts --help
as an argument, which tells it to
provide a bit of help. Among other things, this help always provides an
accurate listing of the options available with that command, and is
therefore frequently useful as a supplement to the somewhat spartan help
given in this manual.
% darcs COMMAND --help
Most commands also accept the --verbose
option, which tells darcs to
provide additional output. The amount of verbosity varies from command to
command.
Darcs optimizes its operations by keeping track of the modification times
of your files. This dramatically speeds up commands such as
whatsnew
and record
which would otherwise require reading
every file in the repo and comparing it with a reference version. However,
there are times when this can cause problems, such as when running a series
of darcs commands from a script, in which case often a file will be
modified twice in the same second, which can lead to the second
modification going unnoticed. The solution to such predicaments is the
--ignore-times
option, which instructs darcs not to trust the file
modification times, but instead to check each file's contents explicitely.
Several commands need to be able to identify you. Conventionally, you
provide an email address for this purpose. The easiest way to do this is
to define an environment variable EMAIL
or DARCS_EMAIL
(with
the latter overriding the former). You can also override this using the
--author
flag to any command. Alternatively, you could set your
email address on a per-repository basis using the ``defaults'' mechanism
for ``ALL'' commands, as described in Appendix B.
Calling darcs with just ``-help'' as an argument gives a brief summary of what commands are available. Calling darcs with the flag ``-version'' tells you the version of darcs you are using. Similarly calling darcs with only ``-commands'' gives a simple list of available commands. This latter arrangement is primarily intended for the use of command-line autocompletion facilities, as are available in bash.
-v |
--verbose |
give verbose output |
Initialize a new source tree as a darcs repository.
Generally you will only call inittree once for each project you work on, and calling it is just about the first thing you do. Just make sure you are in the main directory of the project, and inittree will set up all the directories and files darcs needs in order to start keeping track of revisions for your project.
inittree actually follows a very simple procedure. It simply creates the directories _darcs, _darcs/current and _darcs/patches, and then creates an empty file, _darcs/inventory. However, it is strongly recommended that you use darcs inittree to do this, as this procedure may change in a future version of darcs.
-v |
--verbose |
give verbose output |
--boring |
don't skip boring files | |
--case-ok |
don't refuse to add files differing only in case | |
-r |
--recursive |
add contents of subdirectories |
Add needs to be called whenever you add a new file or directory to your project. Of course, it also needs to be called when you first create the project, to let darcs know which files should be kept track of.
Darcs will refuse to add a file or directory that differs from an existing one only in case. This is because the HFS+ file system used on under MacOS treats such files as being one and the same.
-v |
--verbose |
give verbose output |
Remove should be called when you want to remove a file from your project, but don't actually want to delete the file. Otherwise just delete the file or directory, and darcs will notice that it has been removed.
-v |
--verbose |
give verbose output |
--ignore-times |
don't trust the file modification times |
Display unrecorded changes in the working directory.
What's-new gives you a view of what changes you've made in your working directory that haven't yet been recorded. The changes are displayed in darcs patch format. Darcs whatsnew will return a non-zero value if there are no changes, which can be useful if you just want to see in a script if anything has been modified. FIXME: If I feel motivated, I may create options for different (possibly more user-friendly) views, such as a unidiff view.
-v |
--verbose |
give verbose output |
--no-test |
don't run the test script |
Check the repository for consistency.
Check verifies that the patches stored in the repository, when successively applied to an empty tree, properly recreate the stored current tree.
If you like, you can configure your repository to be able to run a test suite of some sort. There are two ways you can do this. One is to use ``setpref'' to set the ``test'' value to be a command to run. e.g.
% darcs setpref test "sh configure && make && make test"
Alternatively, you can add to your repo a file called darcs_test
.
Darcs will recognize this, and make it executable and run it as a test
script. Typically you would make darcs_test
a simple script that
compiles your project and possibly runs a test suite. You should make sure
that your darcs_test
returns an error code indicating either success
or failure so darcs will know whether or not the code worked.
If you just want to check the consistency of your repository without
running the test, you can call darcs check with the --no-test
option.
-m |
--patch-name PATCHNAME |
name of patch |
-A |
--author EMAIL |
specify author id |
-v |
--verbose |
give verbose output |
--no-test |
don't run the test script | |
-a |
--all |
answer yes to all patches |
--ask-deps |
ask about dependencies | |
--ignore-times |
don't trust the file modification times |
Record is used to name a set of changes and record the patch to the
repository.
Each patch is given a name, which typically would consist of a brief
description of the changes. This name is later used to describe the patch.
The name must fit on one line (i.e. cannot have any embedded newlines). If
you have more to say, stick it in the log. (FIXME: Currently recording a
patch deletes any pending changes that aren't included in the recorded
patch. This is clearly a bug, but is a bit tedious to fix.)
The patch is also flagged with the author of the change, taken by default
from the DARCS_EMAIL
environment variable, and if that doesn't
exist, from the EMAIL
environment variable. The date on which the
patch was recorded is also included. Currently there is no provision for
keeping track of when a patch enters a given repository.
Finally, each changeset should have a full log (which may be empty). This
log is for detailed notes which are too lengthy to fit in the name. If you
answer that you do want to create a comment file, darcs will open an editor
so that you can enter the comment in. The choice of editor proceeds as
follows. If one of the $DARCSEDITOR
, $VISUAL
or
$EDITOR
environment variables is defined, its value is used (with
precedence proceeding in the order listed). If not, ``vi'', ``emacs'',
``emacs -nw'' and ``nano'' are tried in that order.
Each patch may depend on any number of previous patches. If you choose to make your patch depend on a previous patch, that patch is required to be applied before your patch can be applied to a repo. This can be used, for example, if a piece of code requires that a function be defined, which has was defined in an earlier patch.
If you want to manually define any dependencies for your patch, you can use
the --ask-deps
flag, and darcs will ask you for the patch's
dependencies.
FIXME: Change this code to use the Readline module so arrow keys, etc, will work properly for entering in the text.
If you configure darcs to run a test suite, darcs will run this test on the
recorded repo to make sure it is valid. Darcs first creates a pristine
copy of the source tree (in /tmp
), then it runs the test, using its
return value to decide if the record is valid. If it is not valid, the
record will be aborted. This is a handy way to avoid making stupid
mistakes like forgetting to `darcs add' a new file. It also can be
tediously slow, so there is an option (--no-test
) to skip the test.
-o |
--repo-name REPONAME |
name of output repository |
-t |
--tag-name TAGNAME |
name of version to pull |
-m |
--patch-name PATCHNAME |
name of patch |
-v |
--verbose |
give verbose output |
Get is used to get a local copy of a repository.
I recommend using the --verbose
flag to get, as
this command can take a while, and with no feedback, that can be rather
boring.
If the remote repo and the current directory are in the same filesystem and that filesystem supports hard links, get will create hard links for the patch files, which means that the additional storage space needed will be minimal. This shouldn't cause any problems as darcs usually never modifies a patch file, and if it does it deletes the old file and creates a new file, which should mean that it won't affect the other repo which shares the same patch file.
If you want to get a specific version of a repository, you have a couple of
options. The first is to use the --tag-name
option, which allows
you to specify a specific version of the repository by its tag, and get
precisely that version. The argument is a regular expression, and get will
grab the most recent tag which matches that regular expression. The other
option is the --patch-name
option, which will allow you to get that
patch (i.e. the most recent one matching the specified regular expression)
and all older patches. Note that when specifying a --patch-name
,
you may get a version of your code that has never before been seen, if the
patches have gotten themselves reordered. If you ever want to be able to
precisely reproduce a given version, you need to tag it.
-v |
--verbose |
give verbose output |
-m |
--patch-name PATCHNAME |
name of patch |
-a |
--all |
answer yes to all patches |
--ignore-times |
don't trust the file modification times | |
--no-deps |
don't automatically fulfill dependencies |
Pull is used to bring changes made in another repo into the current repo (that is, the one that is the current directory). Pull allows you to bring over all or some of the patches that are in that repo but not in the current one. Pull accepts an argument, which is the URL from which to pull, and when called without an argument, pull will use the repository from which you have most recently either pushed or pulled.
The --patch-name
argument can be used to specify a regexp, which
should be of the extended type used by egrep
. If this option is
used, only patches which match this regexp (along with their dependencies)
are considered.
If you give a --patch-name
argument, darcs will silently pull along
any other patches upon which the patches which match the patch-name depend.
So --patch-name bugfix
mean ``pull all the patches with `bugfix' in
their name, along with any patches they require.'' If you really only want
the patches with `bugfix' in their name, you should use the
--no-deps
option, which is only useful in combination with
--patch-name
, and makes darcs only pull in those matching patches
which have no dependencies (apart from other matching patches).
-v |
--verbose |
give verbose output |
-m |
--patch-name PATCHNAME |
name of patch |
-a |
--all |
answer yes to all patches |
-A |
--author EMAIL |
specify author id |
-t |
--to EMAIL |
specify destination email |
-o |
--output FILE |
specify output filename |
-s |
--sign |
sign the patch with your gpg key |
--edit-description |
edit the patch bundle description |
Push is used to prepare a bundle of patches to send to another repository. Push accepts the URL of the repository as an argument, and when called without an argument, pull will use the most recent repository that was either pushed to or pulled from.
The --output
and --email
flags determine what darcs does with
the patch bundle after creating it. If you provide an --output
argument, the patch bundle is saved to that file. If you give an
--email
argument, the bundle of patches is emailed to that person.
If you don't provide either, darcs will prompt you for an email recipient.
The --patchname
argument can be used to specify a regexp, which
should be of the extended type used by egrep
. If this option is
used, only patches which match this regexp (along with their dependencies)
are considered for pushing.
If you want to include a description or explanation along with the bundle
of patches, you need to specify the --edit-description
flag, which
will cause darcs to open up an editor with which you can compose an email
to go along with your patches.
-V |
--verify PUBRING |
verify that the patch was signed by a key in PUBRING |
-v |
--verbose |
give verbose output |
--ignore-times |
don't trust the file modification times | |
--no-resolve-conflicts |
don't try to resolve conflicts | |
--test |
run the test script |
Apply is used to apply a bundle of patches to this repository. Such a bundle may be created using push.
If you specify the --verify PUBRING
option, darcs will check that
the patch was gpg-signed by a key which is in PUBRING
.
-v |
--verbose |
give verbose output |
Unrecord is used to undo a single recorded patch. It will prompt you
for which patch to unrecord, and then will undo that patch.
Note that unrecord doesn't affect your working copy
of the tree at all, so if you want to completely undo the change, you'll
also need to darcs revert
, or do an unpull.
If you don't revert after unrecording, then the changes made by the unrecorded patches are left in your working tree. If these patches are actually from another repository, interaction (either pushes or pulls) with that repository may be massively slowed down, as darcs tries to cope with the fact that you appear to have made a large number of changes that conflict with those present on the other repository. So if you really want to undo the result of a pull operation, use unpull! Unrecord is primarily intended for when you record a patch, realize it needs just one more change, but would rather not have a separate patch for just that one change.
FIXME: The one major bug remaining is that unrecording a `darcs add' causes that add to be lost, while it really should just be stuck pack in `pending'.
-v |
--verbose |
give verbose output |
Unpull is used to undo a single patch that has been pulled from another repository. It will prompt you for which patch to unpull, and then will undo that patch. Beware that unpull undoes the patch both from the repo records AND from the current working directory, and does NOT check that the patch originated with a pull. In otherwords, you could lose precious code by unpulling!
-v |
--verbose |
give verbose output |
--ignore-times |
don't trust the file modification times | |
-a |
--all |
answer yes to all patches |
Revert is used to undo changes make to the local tree which have not yet been recorded. You will be prompted for which changes you wish to undo. Please be cautious with revert, as there is no way to unrevert. Although I could store an unrevert patch somewhere, if there is demand for such a feature...
-d |
--dist-name DISTNAME |
name of version |
-v |
--verbose |
give verbose output |
Create a distribution tarball.
Dist is a handy tool for implementing a ``make dist'' target in your makefile. It creates a tarball of the recorded edition of your tree. Basically, you will typically use it via a makefile rule such as
dist: ./darcs dist --dist-name darcs-`./darcs --version`
darcs dist
then simply creates a clean copy of the source tree,
which it then tars and gzips. If you use programs such as autoconf or
automake, you really should run them on the clean tree before tarring it up
and distributing it. You can do this using the pref value ``predist'',
which is a shell command that is run prior to tarring up the distribution:
% darcs setpref predist "autoconf && automake"
-v |
--verbose |
give verbose output |
Darcs mv needs to be called whenever you want to rename or move a file or directory. Unlike remove, mv actually performs the move itself in your working directory. This is why ``mv'' isn't called ``move'', since it is really almost equivalent to the unix command ``mv''. I could add an equivalent command named ``move'' for those who like vowels.
-v |
--verbose |
give verbose output |
Replace allows you to change a specified token whereever it
occurs in the specified files. Tokens here are defined by a
regexp specifying the characters which are allowed. By default
a token corresponds to a C identifier.
FIXME: Currently there is no way to specify a
different regexp (other than [A-Za-z_0-9]
) to be used for a token
replace. Actually, if one of your tokens contains a `-' or `.', you will
then get the ``filename'' regexp, which is [A-Za-z_0-9\-\.]
.
-m |
--patch-name PATCHNAME |
name of patch |
-A |
--author EMAIL |
specify author id |
-v |
--verbose |
give verbose output |
Tag is used to name a version of the tree. Tag differs from record in that it doesn't record any new changes, and it always depends on all patches residing in the repository when it is tagged. This means that one can later reproduce this version of the repository by calling, for example:
% darcs get --tag-name "darcs 3.14" REPOLOCATION
Each tagged version has a version name. The version is also flagged with the person who tagged it (taken by default from the `DARCS_EMAIL' or `EMAIL' environment variable. The date is also included in the version information.
A tagged version automatically depends on all patches in the repo. This allows you to later reproduce precisely that version. The tag does this by depending on all patches in the repo, except for those which are depended upon by other tags already in the repo. In the common case of a sequential series of tags, this means that the tag depends on all patches since the last tag, plut that tag itself.
-t |
--tag-name TAGNAME |
name of version to pull |
-m |
--patch-name PATCHNAME |
name of patch |
Diff can be used to create a diff between two versions which are in your repository.
Diff calls an external ``diff'' command to do the actual work, and passes any unrecognized flags to this diff command. Thus you can call
% darcs diff -t 0.9.8 -t 0.9.10 -- -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.
FIXME: I probably should just bite the bullet and figure out how to get
diff flags passed through properly. Any hints from getopt gurus would be
appreciated.
FIXME: I should allow the user to specify the external diff command. Currently it is hardwired to /usr/bin/diff.
Usage example:
% darcs setpref test "echo I am not really testing anything."
Setpref allows you to set a preferences value in a way
that will propogate to other repositories.
If you just want to set the pref value in your
repository only, you can just edit ``_darcs/prefs/prefs
''. Changes
you make in that file will be preserved.
The ``_darcs/prefs/prefs
'' holds the only preferences information
that can propogate between repositories via pushes and pulls, and the only
way this happens is when the setprefs command is used. Note that although
prefs settings are included in patches, they are not fully version
controlled. In particular, depending on the order in which a series of
merges is perform, you may end up with a different final prefs
configuration. In practice I don't expect this to be a problem, as the
prefs usually won't be changed very often.
The following values are valid preferences options which can be configured using setpref:
sh ./darcs_test
''.