|
27 January 2003 | |||||||||||||||
|
Dave O Connor <doc@redbrick.dcu.ie>
Table Of Contents
1. Explain yourself, sir. S. 1 - Explain yourself, sir.
1.1 What is CVS? $Id: cvs-tutorial.txt,v 1.8 2000/07/21 20:31:40 doc Exp $in a source file, and wonder what it means? I'll be telling you how to decipher such things, and how to make them appear in your project source files later. CVS, along with the likes of Bugzilla, are some of the tools that you use once, and never stop using. Trust me. You'll love it.
1.2 Why should I use CVS?
1.3 Where can I get CVS?
S. 2 - Down to Business then
2.1 How does CVS work?
2.2 Terminology
2.3 Getting Started
"Checking out" a module basically means you retrieve a working copy of it
from CVS to your hard disk.
'config' is now at version 1.2, and your CVS server is basically
configured for simple use locally.
2.4 Restricting Access ~/CVSROOT root@sprocket $ cat >> writers doc fred someguy youthere ^D ~/CVSROOT root@sprocket $We then need to add this file to the module, like so: ~/CVSROOT root@sprocket $ cvs add writers cvs add: scheduling file `writers' for addition cvs add: use 'cvs commit' to add this file permanently ~/CVSROOT root@sprocket $Don't commit yet. Append the name 'writers' to the end of the 'checkoutlist' file. This lets CVS know it has a new config file! ~/CVSROOT root@sprocket $ cvs edit checkoutlist ~/CVSROOT root@sprocket $ cat >> checkoutlist writers ^D ~/CVSROOT root@sprocket $Now, we can commit our changes to both files at once, by specifying them both on the command line. Also, I'm using the -m switch here, instead of having to use an editor. Useful if the comment is short.
~/CVSROOT root@sprocket $ cvs commit -m \
"Added writers file, restricting access to
developers" \
checkoutlist writers
Checking in checkoutlist;
/cvs/CVSROOT/checkoutlist,v <-- checkoutlist
new revision: 1.2; previous revision: 1.1
done
RCS file: /cvs/CVSROOT/writers,v
done
Checking in writers;
/cvs/CVSROOT/writers,v <-- writers
initial revision: 1.1
done
cvs commit: Rebuilding administrative file database
~/CVSROOT root@sprocket $
Now, only 'doc', fred', 'someguy', and 'youthere' can write to this CVS
repository.
Your CVS server is now ready for use.
2.5 Network Setup cvspserver 2401/tcp #CVS network serverAnd then add something like the following to /etc/inetd.conf cvspserver stream tcp nowait root /usr/bin/cvs cvs --allow-root=/cvs pserver(Substitute /usr/bin/cvs for wherever 'cvs' is on your system, and the argument to --allow-root to the location of your Repository.). Restart inetd. The CVS pserver should now be running. You can do a quick test of the server as a normal user : /usr/home/doc doc@sprocket $ cvs -d :pserver:doc@sprocket:/cvs login (Logging in to doc@sprocket) CVS password: /usr/home/doc doc@sprocket $If it accepts your login password, then your pserver is up and running! S. 3 - Basic Usage of CVS
3.1 The CVSROOT variable :pserver:<username>@<host>:/cvsdirectorySo, if user 'doc' wants to connect to the CVS server on 'sprocket', and the CVS repository on sprocket is in /cvs, then doc's CVSROOT environment variable would look like : :pserver:doc@sprocket:/cvsWe will be concentrating on network use from now on. 3.2 Logging in If we're working over the network, we need to log into the CVS server to perform operations. This is done with the 'cvs login' command. ~ doc@consortium $ export CVSROOT=:pserver:doc@sprocket:/cvs
3.3 Importing Existing Code /tmp/cvsWU2948: 5 lines, 244 characters. N MyProject/Makefile N MyProject/README cvs server: Importing /cvs/MyProject/src N MyProject/src/main.c N MyProject/src/blah.c N MyProject/src/somethingelse.c cvs server: Importing /cvs/MyProject/doc N MyProject/doc/manual.txt N MyProject/doc/manual.html N MyProject/doc/manual.pdf No conflicts created by this import ~/prog/MyProject doc@consortium $Your current directory is now imported into CVS as the 'MyProject' module. Note that you need to create a separte checkout of the module again if you want to poerform CVS operations on it. 3.4 Checking out a Module In order to do CVS operations (adding file, amending files, etc.) on a module, you need to 'check out' a working copy of the module to your machine. You can then do operations in the files on this working copy. Say we want to checkout a working copy of our 'MyProject' module, we can do it like this: ~/cvs doc@consortium $ cvs checkout MyProject cvs server: Updating MyProject U MyProject/Makefile U MyProject/README cvs server: Updating MyProject/doc U MyProject/doc/manual.html U MyProject/doc/manual.pdf U MyProject/doc/manual.txt cvs server: Updating MyProject/src U MyProject/src/blah.c U MyProject/src/main.c U MyProject/src/somethingelse.c ~/cvs doc@consortium $Note that you can check out an individual directory of a module as well. Say we wanted just the src/ directory of the 'MyProject' module, we could do that with: ~/prog/MyProject doc@consortium $ cvs checkout MyProject/src This will checkout the src/ directory of the MyProject module. You now have a working copy of the module.
3.5 Adding A File ~/cvs/MyProject doc@consortium $ cvs add INSTALL cvs server: scheduling file `INSTALL' for addition cvs server: use 'cvs commit' to add this file permanently ~/cvs/MyProject doc@consortium $ cvs commit INSTALL <edit log file> RCS file: /cvs/MyProject/INSTALL,v done Checking in INSTALL; /cvs/MyProject/INSTALL,v <-- INSTALL initial revision: 1.1 done ~/cvs/MyProject doc@consortium $Notice that we ran "cvs commit" on the file after we ran "cvs add". This commits our changes to the CVS server. It doesn't commit automatically just in case you want to do several amendments to your current working directory, which can then be done in a batch by doing a simple "cvs commit" (with no file arguments).
3.6 Updating your Working Copy ~/cvs/MyProject doc@consortium $ cvs update -d cvs server: Updating . cvs server: Updating doc cvs server: Updating src U src/main.c U src/somethingelse.c ~/cvs/MyProject doc@consortium $I use the -d switch, which creates files in the working copy that didn't exist before, and that have appeared in the repository (i.e. have been added by someone else). The 'U' before the files mentioned indicates they have been 'U'pdated. Other letters that may appear here are 'P' for new files, 'M' for files you've modified locally and not committed, and 'C' for files you've updated locally, and that have had different changes done by someone else. (This is called a "Conflict", I'll go into resolving them in another tutorial in detail, for the moment just try to merge the 2 sets of changes manually).
3.7 Editing a file ~/cvs/MyProject/src doc@consortium $ cvs update main.c ~/cvs/MyProject/src doc@consortium $The copy we have is up-to-date, good. We then want to mark ourselves as an editor of this file. The "cvs edit" command looks after this. ~/cvs/MyProject/src doc@consortium $ cvs edit main.c ~/cvs/MyProject/src doc@consortium $This tells the CVS server that we're editing the file. This can be useful for if other people want to know who's editing the file. (They can run "cvs editors" on the file.) Like so: /usr/home/fred/demo/MyProject/src fred@scrappy $ cvs editors main.c main.c doc Fri Jul 21 20:18:38 2000 GMT consortium.thehouse /usr/home/doc/cvs/MyProject/src /usr/home/fred/demo/MyProject/src fred@scrappy $Fred can then come thump me over the head and ask me what changes I plan to make to the file. "cvs edit" is, of course, optional. If you want exclusive access to the file (i.e. you're doing major restructuring of it), you can lock it, by running "cvs admin -l" on it. (Of course, when you're finished editing the file, run "cvs admin -u" on it. The failure to do this can be the cause of...accidents. This is how developers get brutally beaten. This is also why only CVS users that are in the UNIX group called 'cvsadmin' on the CVS server itself can lock files.) Okay, you're now ready to edit the file. Go ahead and edit it. When you're finished editing, you want to commit your changes. Run "cvs commit" on the file. You then want to tell the CVS server you're no longer editing the file. run "cvs unedit" on it. Your changes have now been added to the repository.
3.8 Deleting a File ~/cvs/MyProject/src doc@consortium $ rm blah.c ~/cvs/MyProject/src doc@consortium $ cvs delete blah.c cvs server: scheduling `blah.c' for removal cvs server: use 'cvs commit' to remove this file permanently ~/cvs/MyProject/src doc@consortium $ cvs commit blah.c <edit log file> Removing blah.c; /cvs/MyProject/src/blah.c,v <-- blah.c new revision: delete; previous revision: 1.1.1.1 done ~/cvs/MyProject/src doc@consortium $ S 4. Advice, tips, funky things
4.1 Getting that Weird String thing from 1.1 (or: The CVS ID) $Id: cvs-tutorial.txt,v 1.8 2000/07/21 20:31:40 doc Exp $
4.2 Other Weird String Things.
$Log: cvs-tutorial.txt,v $
4.3 Adding CVS users that don't exist as UNIX users. desiredusername:EnCrYpTeDpAsSwOrD:realuserThe fisrts entry in this colon-separted list is the desired username to allow. The second entry is the password for that user, done in standard unix crypt() format. The third entry is the real UNIX user on the server that file operations will be done as (so, you can set up a user that can write to just the repository and nothing else). If you have apache installed, there's a utility called 'htpasswd' which can generate the first 2 fields for you. You can then add the tird field manually. Once you have the 'passwd' file added, add it with "cvs add". To tell the CVS server to read this file, you can append the name of the file to the 'checkoutlist' file in the CVSROOT module. Once you've done this, you can then commit your changes with 'cvs commit'. ~/cvs/CVSROOT doc@consortium $ echo "passwd" >> checkoutlist ~/cvs/CVSROOT doc@consortium $ cvs add passwd cvs server: scheduling file `passwd' for addition cvs server: use 'cvs commit' to add this file permanently ~/cvs/CVSROOT doc@consortium $ cvs commit -m "added passwd file" cvs commit: Examining . Checking in checkoutlist; /cvs/CVSROOT/checkoutlist,v <-- checkoutlist new revision: 1.6; previous revision: 1.5 done Checking in passwd; /cvs/CVSROOT/passwd,v <-- passwd initial revision: 1.1 done cvs server: Rebuilding administrative file database ~/cvs/CVSROOT doc@consortium $This leads me to the next, and final topic for now...
4.4 Anonymous Access anonymous::anonuser'anonuser' is a real user on the server that doesn't have write access to the CVS repository. This then allows people to log into the CVS server as 'anonymous', with no password, and have read-only access.
Bye. - DoCRelated: Continuing CVS: Tags, Branches, triggers and CVSWEB. Managing Access with CVS Subversion - a better CVS About the author, Dave O Connor. | |||||||||||||||