<!--  vim: set sw=2 sts=2 et ft=docbk:

  Part of the A-A-P recipe executive: Tutorial - Using CVS

  Copyright (C) 2002-2003 Stichting NLnet Labs
  Permission to copy and use this file is specified in the file COPYING.
  If this file is missing you can find it here: http://www.a-a-p.org/COPYING

-->

<para>
CVS is often used for development of Open Source Software.
A-A-P provides facilities to obtain the latest version of an application and
for checking in changes you made.
</para>


<bridgehead>Downloading (Checkout)</bridgehead>

<para>
For downloading a whole module you only need to specify the location of the
CVS server and the name of the module.  Here is an example that obtains the
A-A-P Recipe Executive:
</para>

<programlisting>
   CVSROOT = :pserver:anonymous@a-a-p.cvs.sourceforge.net:/cvsroot/a-a-p
   all:
        :fetch {fetch = cvs://$CVSROOT} Exec
</programlisting>

<para>
Write this recipe as "main.aap" and run <userinput>aap</userinput>.  The directory
"Exec" will be created and all files in the module obtained from the CVS
server:
</para>

<literallayout>    % <userinput>aap</userinput>
    Aap: CVS checkout for node "Exec"
    Aap: cvs -d:pserver:anonymous@a-a-p.cvs.sf.net:/cvsroot/a-a-p checkout 'Exec'
    cvs server: Updating Exec
    U Exec/Action.py
    U Exec/Args.py
    [....]
    %
</literallayout>

<para>
If there is a request for a password just hit enter (mostly there is no
password).
</para>

<para>
The <computeroutput>:fetch</computeroutput> command takes care of obtaining the latest
version of the items mentioned as arguments.  Usually the argument is one
module, in this example it is "Exec".  That CVS needs to be used is
specified with the <literal>fetch</literal> attribute.  This is a kind of URL,
starting with "cvs://" and then the CVS root specification.  In the example
the <literal>CVSROOT</literal> variable was used.  This is not required, it just 
makes the recipe easier to understand.
</para>

<para>
If the software has been updated, you can get the latest version by running
"aap" again.  CVS will take care of obtaining the changed files.
</para>

<para>
Note that all this only works when you have the "cvs" command installed.
When it cannot be found &Aap; will ask you want &Aap; to install it for you.
Whether this works depends on your system.
</para>


<bridgehead>Getting Past A Firewall</bridgehead>

<para>
Firewalls may block the use of a CVS connection.
Some servers have setup another way to connect, so that firewalls will not
cause problems.  This uses port 80, normally used for http connections.
Here is the above example using a different "pserver" address:
</para>

<programlisting>
   CVSROOT = :pserver:anonymous@a-a-p.cvs.sourceforge.net:/cvsroot/a-a-p
   all:
        :fetch {fetch = cvs://$CVSROOT} Exec
</programlisting>

<para>
This doesn't always work through a proxy though.  If you have problems
connecting to the CVS server, try reading the information at
<ulink url="http://sourceforge.net/docman/display_doc.php?docid=768&amp;group_id=1">
this link</ulink>.
</para>


<bridgehead>Uploading (Checkin)</bridgehead>

<para>
You are the maintainer of a project and want to distribute your latest
changes, so that others can obtain the software with a recipe as used above.
This means you need to checkin your files to the CVS server.  This is done by
listing the files that need to be distributed and giving them a
<literal>commit</literal> attribute.  Example:
</para>

<programlisting>
   CVSUSER_FOO = johndoe
   CVSROOT = :ext:$CVSUSER_FOO@cvs.foo.sf.net:/cvsroot/foo
   Files =  main.c
            common.h
            version.c
   :attr {commit = cvs://$CVSROOT} $Files
</programlisting>

<para>
Write this as "cvs.aap" and run <userinput>aap -f cvs.aap revise</userinput> .  What
will happen is:
<orderedlist>
  <listitem>
    <para>
    Files that you changed since the last checkin will be checked in to the
    CVS server.
    </para>
  </listitem>
  <listitem>
    <para>
    Files that you added to the list of files with a <literal>commit</literal>
    attribute will be added to the CVS module.
    </para>
  </listitem>
  <listitem>
    <para>
    Files that you removed from the list of files with a <literal>commit</literal>
    attribute will be removed from the CVS module.
    </para>
  </listitem>
</orderedlist>
This means that you must take care the <literal>Files</literal> variable lists
exactly those files you want to appear in the CVS module, nothing more and
nothing less.  Be careful with using something like
<computeroutput>*.c</computeroutput>, it might find more files that you intended.
</para>

<para>
Note: This only works when the CVS module was already setup.  Read the CVS
documentation on how to do this.  The A-A-P user manual has useful hints as
well.
</para>

<para>
In the example the <literal>CVSUSER_FOO</literal> variable is explicitly set, thus
this recipe only works for one user.  Better is to move this line to your own
default recipe, e.g., "~/.aap/startup/default.aap".  Then the above recipe
does not explicitly contain your user name and can also be used by others.
</para>

<para>
Once you tested this recipe and it works, you can easily distribute your
software with <userinput>aap -f cvs.aap revise</userinput>.  You don't have to worry
about the exact CVS commands to be used.  However, don't use this when you
want to checkin only some of the changes you made.  And the example does not
work well when others are also changing the same module.
</para>

<bridgehead>Further Reading</bridgehead>

<para>
  The User manual <xref linkend="user-version"/> has more information about
  version control and <xref linkend="user-cvs"/> about using CVS.
</para>
