old-www/LDP/LG/issue57/nielsen.html

247 lines
11 KiB
HTML

<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<title>CVS: Concurrent Versions System LG #57</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<CENTER>
<A HREF="http://www.linuxgazette.com/">
<H1><IMG ALT="LINUX GAZETTE" SRC="../gx/lglogo.jpg"
WIDTH="600" HEIGHT="124" border="0"></H1></A>
<!-- *** BEGIN navbar *** -->
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="kasten.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue57/nielsen.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="nielsen2.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
<!-- *** END navbar *** -->
<P>
</CENTER>
<!--endcut ============================================================-->
<H4 ALIGN="center">
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H1><font color="maroon">CVS: Concurrent Versions System</font></H1>
<H1>A source control program used by Mark</H1>
<H4>By <a href="mailto:python@kepnet.com">Mark Nielsen</a></H4>
</center>
<P> <HR> <P>
<!-- END header -->
<ol>
<li>
<a href="#REf">References</a></li>
<li>
<a href="#Introduction">Introduction</a></li>
<li>
<a href="#Upload">Upload files to the CVS repository</a>-- creating your
first repository.</li>
<li>
<a href="#Download">Download files from CVS.</a></li>
<li>
<a href="#Download">Adding a file to the cvs repository "My_Files"</a></li>
<li>
<a href="#Download">Deleting a file from the cvs repository "My_Files"</a></li>
<li>
<a href="#Download">Changing a file and uploading changes to the repository
"My_Files"</a></li>
<li>
<a href="#Conclusion">Conclusion</a></li>
</ol>
<h3>
<a NAME="REf"></a>References</h3>
<ol>
<li>
<a href="http://www.cyclic.com/">www.cyclic.com</a></li>
<li>
<a href="http://www.cyclic.com/docs/manual/index.html">Manual for CVS</a></li>
<li>
<a href="http://www.cyclic.com/new_users.html">New user information.</a></li>
<li>
<a href="http://www.openave.com/cyclic/cyclic-pages/support.html">Suppor</a>t
----- I&nbsp;am not sure if this link is valid. There seems to be a company
which will support CVS.</li>
</ol>
<h3>
<a NAME="Introduction"></a>Introduction</h3>
CVS is a cool program to let people control different version of their
software. It has saved my butt before. It is relatively easy to use, and
everybody who is either new to programming, or who wants to stick to free
software, should use CVS. Recently, CVS has become officially supported
by a company.
<h2>
<a NAME="STARTED"></a>Getting Started</h2>
First off, I&nbsp;assume you are using the BASH shell, which is standard
on most intelligent Unix systems. I also assume you have root access to
the computer you are using. There are simple ways to let various people
have access to a CVS repository, but I&nbsp;will assume it will only be
used by one person for now.
<p>Login as root, and execute the following. I assume you are the user
"mark", but it can be any user on your system.
<br>mkdir /usr/local/cvs
<br>chown mark /usr/local/cvs
<p>Now login as "mark" and do the following.
<p>Edit your .bashrc file using vi or emacs or even pico, and enter these
commands.
<br>CVSROOT=/usr/local/cvs<BR>
export CVSROOT
<p>Save it and then execute "source .bashrc". Now when you log in, it will
setup your environment to use this directory by default if you don't specify
a directory to use.
<p>Make a directory, which is need for cvs.
<br>mkdir /usr/local/cvs/CVSROOT
<h2>
<a NAME="Upload"></a>Upload files to the CVS repository</h2>
The purpose of this exercise is to upload files into the repository so
that the files are under source control. Later, we will download the files
into another directory, or the Working directory.
<p>In your home directory for "mark", make a directory called "Temp_Source"
and put a few files in it. Such as,
<br>mkdir Temp_Source
<br>ls &gt;&nbsp;Temp_Source/File1.txt
<br>ls Temp_Source/* &gt;&nbsp;Temp_Source/File2.txt
<p>Now we want to put the files in Temp_Source into CVS. Do this, enter
the directory Temp_Source.
<br>cd Temp_Source
<br>then issue this command
<br>cvs import -m "Test Import" My_Files Revision1 start
<p>Now we are ready to make a working directory. We will forget about the
directory Temp_Source and pretend it never existed. By the way, take a
look at /usr/local/cvs and see what cvs has done to it. You can add more
packages to the cvs repository if you wish.
<h2>
<a NAME="Download"></a>Download files from CVS</h2>
Okay, now we want to download these files into a Working directory and
we will pretend that our Temp_Source directory doesn't exist. This will
often be the case where someone else enters files into CVS and expects
you to maintain them.
<p>When we checkout a package from cvs, it will create a directory for
us. The parameter "My_Files" that we specified when we uploaded the files
into cvs will be the name of the directory created for us when cvs downloads
the package for us.
<p>Now we need to get the cvs package.
<br>cvs checkout My_Files
<p>If we look, we now have a directory named "My_Files". Enter into the
directory,
<br>cd My_Files
<br>and execute the the "ls" command.
<br>ls
<br>&nbsp;
<h2>
<a NAME="Add"></a>Adding a file to the cvs repository "My_Files"</h2>
I assume you are in the directory My_Files. In order to add a file to the
repository, create one.
<br>ls /etc &gt;&nbsp;File3.txt
<br>Now execute the command to set it up so that the file will be added
to the cvs repository.
<br>cvs add File3.txt
<br>Now you need to actually upload the file. The previous command just
setup the configuration to do it.
<br>cvs commit
<p>"cvs commit" will bring you into your default editor, vi or emacs or
something else. Save the file, and when you quit the editor, cvs will ask
you to continue, and select the option to continue. Now you have uploaded
a file to the cvs repository "My_Files".
<p>Also, execute the "ls" command, and you will notice that you have a
directory called "CVS". cvs creates a directory "CVS" in every directory
that you download files from a repository and it keeps the changes up to
date.
<br>&nbsp;
<h2>
<a NAME="Delete"></a>Deleting a file to the cvs repository "My_Files"</h2>
In order to delete a file from the cvs repository, do this
<br>rm File3.txt
<br>cvs remove File3.txt
<br>cvs commit
<p>The first step actually deletes the file in your directory. The second
step removes it from the configuration of the current directory you are
in. The third step commits this change to the cvs repository"My_Files".
If you do not execute "cvs remove File3.txt", you will find it hard to
execute "cvs commit" in the future and it won't update the repository correctly,
at least that has been from my experience.
<h2>
<a NAME="Change"></a>Changing a file to the cvs repository "My_Files"</h2>
I assume you are in the directory "My_Files". Let us add some content to
the file File2.txt.
<p>ls /var &gt;&gt;&nbsp;File2.txt
<br>cvs commit
<br>&nbsp;
<h2>
<a NAME="Other"></a>Downloading updates that other people make</h2>
If you have downloaded a package from a repository that someone else is
maintaining, if you wish to download all the changes, then execute the
followign command,
<p>cvs update -dP
<p>The "d" creates any directories that are or are missing.
<br>The "P" removes any directories that were deleted from the repository.
<br>&nbsp;
<h3>
<a NAME="Conclusion"></a>Comments</h3>
I have noticed the the "cvs commit" command should recursively go through
all directories from where you are currently at and list all the changes
in one file. However, on some systems, it makes a one file per directory,
which means right before it uploads the changes to the repository, cvs
starts the editor for each directory that has changes, which is annoying.
I have to figure out how to set it up to list all the changes in one file
and not many.
<p>CVS is the best source control program I have used. It is the best because
it comes by default on major Linux distributions, and it is relatively
easy to use, unlike some other source control software I have seen. Major
free software websites use CVS, which is another plus, because if they
use it, then it will be an ongoing project. Also, you can download documents
using cvs over the internet. I downloaded all the sgml howtos from the
Linux Documentation Project using cvs using their anonymous CVS server.
This is very useful if you want to keep yourself up to date on various
versions of documentation.
<p>
<br><i>Mark works as a computer guy at <a href="http://www.tcu-inc.com">The
Computer Underground</a> and also at <a href="http://www.genericbooks.com">ZING</a>
and also at GNUJobs.com (soon).</i>
<!-- *** BEGIN copyright *** -->
<P> <hr> <!-- P -->
<H5 ALIGN=center>
Copyright &copy; 2000, Mark Nielsen<BR>
Published in Issue 57 of <i>Linux Gazette</i>, September 2000</H5>
<!-- *** END copyright *** -->
<!--startcut ==========================================================-->
<HR><P>
<CENTER>
<!-- *** BEGIN navbar *** -->
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="kasten.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue57/nielsen.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="nielsen2.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
<!-- *** END navbar *** -->
</CENTER>
</BODY></HTML>
<!--endcut ============================================================-->