1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
|
<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>Introduction to RCS Issue 20</title>
</HEAD>
<BODY BGCOLOR="#EEE1CC" TEXT="#000000" LINK="#0000FF" VLINK="#0020F0"
ALINK="#FF0000">
<!--endcut ============================================================-->
<H4>
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H2>Introduction to RCS</H2>
<H4>By Hådin Løvdal
<a href="mailto:halovda@krs.hia.no">halovda@krs.hia.no</a></H4>
</center>
<hr>
<P>
Do you find yourself having lots of different unsorted and more or less
old backup files lying around when working on something, but do not dare
to delete any of them because you might need to go back and find out
what changes you have made compared to your current version ?
<P>
Would you like to get all those backups out of the way (without reducing
the number of backups), have them sorted and systemated, and perhaps
even with some sort of documentation like exactly when changes where
made, by who (when several persons are involved), and a few lines that
describes the changes which can be the input of an automatically made
change-log ?
<P>
In that case read on because RCS will do that for you.
<HR>
<P>
Lets have a look at an example (a traditional hello world program)
of what RCS can do:
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>ls -l
total 0
(hlovdal) localhost:/tmp/rcstest>cat > hello.c
/*
* $Id: rcs.html,v 1.1.1.1 1997/09/14 15:01:51 schwarz Exp $
*
* $Log: rcs.html,v $
* Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
* Imported files
*
*/
main(){
printf("hello world");
}
(hlovdal) localhost:/tmp/rcstest>gcc -o hello hello.c
(hlovdal) localhost:/tmp/rcstest>./hello
hello world(hlovdal) localhost:/tmp/rcstest>ls -l
total 5
-rwxrwx--- 1 hlovdal hlovdal 3928 Jun 28 01:01 hello
-rw-rw---- 1 hlovdal hlovdal 60 Jun 28 01:00 hello.c
(hlovdal) localhost:/tmp/rcstest>
</PRE>
<P>
(The two $-tags in the comment are for automatically documentation, more
about those later)
<P>
Our hello world program works now, so we would like to save it in it's
current state before making any changes to it. This is done by running
ci, Check In, on the source file. That is, the source file is put into
the RCS database. When the file is checked in, it is by default also
removed from the current directory.
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>mkdir RCS
(hlovdal) localhost:/tmp/rcstest>ci hello.c
RCS/hello.c,v <-- hello.c
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> A plain simple hello world program
>> .
initial revision: 1.1
done
(hlovdal) localhost:/tmp/rcstest>ls -l
total 5
drwxrwx--- 2 hlovdal hlovdal 1024 Jun 28 01:02 RCS
-rwxrwx--- 1 hlovdal hlovdal 3928 Jun 28 01:01 hello
(hlovdal) localhost:/tmp/rcstest>
</PRE>
<P>
By looking into the RCS directory we can now see that there is a
file with the same name as our program with an extra extension ",v".
(By omitting the RCS directory the file would be in the current directory)
This file now holds the source plus some additional information, and
will later on contain the source for all versions. The rcs file is not
particularly interesting to look at directly:
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>cat RCS/hello.c,v
head 1.1;
access;
symbols;
locks; strict;
comment @ * @;
1.1
date 97.06.28.01.03.43; author hlovdal; state Exp;
branches;
next ;
desc
@A plain simple hello world program
@
1.1
log
@Initial revision
@
text
@/*
* $Id: rcs.html,v 1.1.1.1 1997/09/14 15:01:51 schwarz Exp $
*
* $Log: rcs.html,v $
* Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
* Imported files
*
*/
main(){
printf("hello world");
}
@
(hlovdal) localhost:/tmp/rcstest>
</PRE>
<P>
This our first version of the hello world program sort of worked, but
it lacks an ending newline and the source isn't pretty. Lets fix that.
The source was moved when it was checked in, so we must use co, Check Out,
to copy the source out of the RCS database.
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>co hello.c
RCS/hello.c,v --> hello.c
revision 1.1
done
(hlovdal) localhost:/tmp/rcstest>ls -l
total 6
drwxrwx--- 2 hlovdal hlovdal 1024 Jun 28 01:02 RCS
-rwxrwx--- 1 hlovdal hlovdal 3928 Jun 28 01:01 hello
-r--r----- 1 hlovdal hlovdal 189 Jun 28 01:04 hello.c
(hlovdal) localhost:/tmp/rcstest>
</PRE>
<P>
Note that co by default fetches the source read-only. This is
usually not what we want, so in order to get the source writable we
use the "-l" option to mark the file locked for others.
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>co -l hello.c
RCS/hello.c,v --> hello.c
revision 1.1 (locked)
done
(hlovdal) localhost:/tmp/rcstest>ls -l
total 6
drwxrwx--- 2 hlovdal hlovdal 1024 Jun 28 01:02 RCS
-rwxrwx--- 1 hlovdal hlovdal 3928 Jun 28 01:01 hello
-rw-r----- 1 hlovdal hlovdal 197 Jun 28 01:05 hello.c
(hlovdal) localhost:/tmp/rcstest>
</PRE>
<P>
By looking at the hello.c file we see that now some values have been
inserted into $Id: rcs.html,v 1.1.1.1 1997/09/14 15:01:51 schwarz Exp $ and $Log: rcs.html,v $
inserted into $Id$ and Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
inserted into $Id$ and Imported files
inserted into $Id$ and.
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>cat hello.c
/*
* $Id: rcs.html,v 1.1.1.1 1997/09/14 15:01:51 schwarz Exp $
*
* $Log: rcs.html,v $
* Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
* Imported files
*
* Revision 1.1 1997/06/28 01:03:43 hlovdal
* Initial revision
*
*/
main(){
printf("hello world");
}
(hlovdal) localhost:/tmp/rcstest>vi hello.c
...
</PRE>
<P>
We makes a few changes. Exactly what was changed can be examined with
the program rcsdiff.
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>rcsdiff hello.c
===================================================================
RCS file: RCS/hello.c,v
retrieving revision 1.1
diff -r1.1 hello.c
9,10c9,14
< main(){
< printf("hello world");
---
>
> #include <stdio.h>
>
> int main(int argc, char *argv[]){
> printf("hello world\n");
> return 0;
(hlovdal) localhost:/tmp/rcstest>
</PRE>
<P>
The rcsdiff program is just a front end for ordinary diff, so it accepts
all the options to diff, for example "-u".
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>rcsdiff -u hello.c
===================================================================
RCS file: RCS/hello.c,v
retrieving revision 1.1
diff -u -r1.1 hello.c
--- hello.c 1997/06/28 01:03:43 1.1
+++ hello.c 1997/06/28 01:05:21
@@ -6,6 +6,10 @@
* Initial revision
*
*/
-main(){
-printf("hello world");
+
+#include <stdio.h>
+
+int main(int argc, char *argv[]){
+ printf("hello world\n");
+ return 0;
}
(hlovdal) localhost:/tmp/rcstest>
</PRE>
<P>
This version looks good, so we want to save it with Check In. By giving
option "-l", ci runs a implicit "co -l" so that the source file remains
checked out. When ci is run we are asked to enter a log description of
our changes. This log description is inserted into $Log: rcs.html,v $
our changes. This log description is inserted into Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
our changes. This log description is inserted into Imported files
our changes. This log description is inserted into.
<P>
<PRE>
(hlovdal) localhost:/tmp/rcstest>ci -l hello.c
RCS/hello.c,v <-- hello.c
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> Fixed main prototype, inserted a missing newline and a missing #include
>> .
done
(hlovdal) localhost:/tmp/rcstest>cat hello.c
/*
* $Id: rcs.html,v 1.1.1.1 1997/09/14 15:01:51 schwarz Exp $
*
* $Log: rcs.html,v $
* Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
* Imported files
*
* Revision 1.2 1997/06/28 01:07:23 hlovdal
* Fixed main prototype, inserted a missing newline and a missing #include
*
* Revision 1.1 1997/06/28 01:03:43 hlovdal
* Initial revision
*
*/
#include <stdio.h>
int main(int argc, char *argv[]){
printf("hello world\n");
return 0;
}
(hlovdal) localhost:/tmp/rcstest>gcc -o hello hello.c
(hlovdal) localhost:/tmp/rcstest>./hello
hello world
(hlovdal) localhost:/tmp/rcstest>
</PRE>
<P>
<HR>
<H2>
In short RCS is this simple to use:
</H2>
<OL>
<LI>"mkdir RCS"
<LI>Insert $Id: rcs.html,v 1.1.1.1 1997/09/14 15:01:51 schwarz Exp $ and $Log: rcs.html,v $
<LI>Insert $Id$ and Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
<LI>Insert $Id$ and Imported files
<LI>Insert $Id$ and into one comment. Optional, but nice
to have. (NB! Note that $Log: rcs.html,v $
to have. (NB! Note that Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
to have. (NB! Note that Imported files
to have. (NB! Note that does *not* include previous
versions. If $Log: rcs.html,v $
versions. If Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
versions. If Imported files
versions. If is inserted after some time only that
and later versions will end up in the log. It is therefore
smart to have $Log: rcs.html,v $
smart to have Revision 1.1.1.1 1997/09/14 15:01:51 schwarz
smart to have Imported files
smart to have in the file from the start)
<LI>Edit the file
<LI>Optionally run rcsdiff when you want to see what changes
you have made since last check in.
<LI>Run "ci -l" each time you want to save what you have done so far.
<LI>Repeat 3 to 5.
</OL>
<P>
For more info on RCS look at the rcsintro(1) man page.
<P>
Here in this example RCS is used on C source, but RCS can be used on many
other things. Config files in /etc are for example excellent candidates
of being put under RCS control.
<P>
RCS is one method of version control. Two others are SCCS and CVS.
CVS (Concurrent Versions System) is a further development of RCS intended
to be used on larger software projects. For example most (?) BSD clones
are distributed and developed using CVS.
<P>
SCCS (Source Code Control System) is an old proprietary system which few
(if any) uses. I think SCCS and RCS have a somewhat a similar relation
as traditional compress vs gzip.
<P>
<!--===================================================================-->
<P> <hr> <P>
<center><H5>Copyright © 1997, Hå Løvdal<BR>
Published in Issue 20 of the Linux Gazette, August 1997</H5></center>
<!--===================================================================-->
<P> <hr> <P>
<A HREF="./lg_toc20.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../lg_frontpage.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./sameer.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./lyx.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
<!--startcut ==========================================================-->
</BODY>
</HTML>
<!--endcut ============================================================-->
|