Debian Codegraph @

Rcs.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>Rcs - Perl Object Class for Revision Control System.</title>
5 <link rev="made" href="mailto:root@localhost" />
6 </head>
7
8 <body style="background-color: white">
9
10 <p><a name="__index__"></a></p>
11 <!-- INDEX BEGIN -->
12
13 <ul>
14
15 <li><a href="#name">NAME</a></li>
16 <li><a href="#synopsis">SYNOPSIS</a></li>
17 <li><a href="#description">DESCRIPTION</a></li>
18 <ul>
19
20 <li><a href="#object_constructor">OBJECT CONSTRUCTOR</a></li>
21 <li><a href="#class_methods">CLASS METHODS</a></li>
22 <li><a href="#object_attribute_methods">OBJECT ATTRIBUTE METHODS</a></li>
23 <li><a href="#rcs_parse_methods">RCS PARSE METHODS</a></li>
24 <li><a href="#rcs_system_methods">RCS SYSTEM METHODS</a></li>
25 </ul>
26
27 <li><a href="#examples">EXAMPLES</a></li>
28 <ul>
29
30 <li><a href="#create_access_list">CREATE ACCESS LIST</a></li>
31 <li><a href="#parse_rcs_archive_file">PARSE RCS ARCHIVE FILE</a></li>
32 <li><a href="#checkin_file">CHECK-IN FILE</a></li>
33 <li><a href="#checkout_file">CHECK-OUT FILE</a></li>
34 <li><a href="#rcsdiff">RCSDIFF</a></li>
35 <li><a href="#rcsclean">RCSCLEAN</a></li>
36 </ul>
37
38 <li><a href="#author">AUTHOR</a></li>
39 <li><a href="#contributors">CONTRIBUTORS</a></li>
40 <li><a href="#copyright">COPYRIGHT</a></li>
41 </ul>
42 <!-- INDEX END -->
43
44 <hr />
45 <p>
46 </p>
47 <h1><a name="name">NAME</a></h1>
48 <p>Rcs - Perl Object Class for Revision Control System (RCS).</p>
49 <p>
50 </p>
51 <hr />
52 <h1><a name="synopsis">SYNOPSIS</a></h1>
53 <pre>
54 use Rcs;</pre>
55 <pre>
56 # Use tags to control how the rcs programs handle errors
57 # and the use of the rcs -q (quiet) flag.
58 use Rcs qw(nonFatal Verbose);</pre>
59 <p>The default behavior is to run rcs programs with the -q (quiet) flag,
60 and to die if any rcs program returns an error.</p>
61 <p>
62 </p>
63 <hr />
64 <h1><a name="description">DESCRIPTION</a></h1>
65 <p>This Perl module provides an object oriented interface to access
66 <strong>Revision Control System (RCS)</strong> utilities. RCS must be installed on
67 the system prior to using this module. This module should simplify
68 the creation of an RCS front-end.</p>
69 <p>
70 </p>
71 <h2><a name="object_constructor">OBJECT CONSTRUCTOR</a></h2>
72 <p>The <strong>new</strong> method may be used as either a class method or an object
73 method to create a new object.</p>
74 <pre>
75 # called as class method
76 $obj = Rcs-&gt;new;</pre>
77 <pre>
78 # called as object method
79 $newobj = $obj-&gt;new;</pre>
80 <p>Note: You may now set the pathname of the working file through the object
81 constructor. This is the same as calling the pathname method after
82 calling the new method.</p>
83 <p>Thus</p>
84 <pre>
85 $obj = Rcs-&gt;new($pathname);</pre>
86 <p>is the same as</p>
87 <pre>
88 $obj = Rcs-&gt;new;
89 $obj-&gt;pathname($pathname);</pre>
90 <p>See <strong>pathname</strong> method for additional details.</p>
91 <p>
92 </p>
93 <h2><a name="class_methods">CLASS METHODS</a></h2>
94 <p>Besides the object constructor, there are three class methods provided
95 which effect any newly created objects.</p>
96 <p>The <strong>arcext</strong> method sets the RCS archive extension, which is ',v' by
97 default.</p>
98 <pre>
99 # set/unset RCS archive extension
100 Rcs-&gt;arcext(''); # set no archive extension
101 Rcs-&gt;arcext(',v'); # set archive extension to ',v'
102 $arc_ext = Rcs-&gt;arcext(); # get current archive extension</pre>
103 <p>The <strong>bindir</strong> method sets the directory path where the RCS executables
104 (i.e. rcs, ci, co) are located. The default location is '/usr/local/bin'.</p>
105 <pre>
106 # set RCS bin directory
107 Rcs-&gt;bindir('/usr/bin');</pre>
108 <pre>
109 # access RCS bin directory
110 $bin_dir = Rcs-&gt;bindir;</pre>
111 <p>The <strong>quiet</strong> method sets/unsets the quiet mode for the RCS executables.
112 Quiet mode is set by default.</p>
113 <pre>
114 # set/unset RCS quiet mode
115 Rcs-&gt;quiet(0); # unset quiet mode
116 Rcs-&gt;quiet(1); # set quiet mode</pre>
117 <pre>
118 # access RCS quiet mode
119 $quiet_mode = Rcs-&gt;quiet;</pre>
120 <p>These methods may also be called as object methods.</p>
121 <pre>
122 $obj-&gt;arcext('');
123 $obj-&gt;bindir('/usr/bin');
124 $obj-&gt;quiet(0);</pre>
125 <p>
126 </p>
127 <h2><a name="object_attribute_methods">OBJECT ATTRIBUTE METHODS</a></h2>
128 <p>These methods set the attributes of the RCS object.</p>
129 <p>The <strong>file</strong> method is used to set the name of the RCS working file. The
130 filename must be set before invoking any access of modifier methods on the
131 object.</p>
132 <pre>
133 $obj-&gt;file('mr_anderson.pl');</pre>
134 <p>The <strong>arcfile</strong> method is used to set the name of the RCS archive file.
135 Using this method is optional, as the other methods will assume the archive
136 filename is the same as the working file unless specified otherwise. The
137 RCS archive extension (default ',v') is automatically added to the filename.</p>
138 <pre>
139 $obj-&gt;arcfile('principle_mcvicker.pl');</pre>
140 <p>The <strong>workdir</strong> methods set the path of the RCS working directory. If not
141 specified, default path is '.' (current working directory).</p>
142 <pre>
143 $obj-&gt;workdir('/usr/local/source');</pre>
144 <p>The <strong>rcsdir</strong> methods set the path of the RCS archive directory. If not
145 specified, default path is './RCS'.</p>
146 <pre>
147 $obj-&gt;rcsdir('/usr/local/archive');</pre>
148 <p>The <strong>pathname</strong> method will set both the working filename and archive
149 directory.</p>
150 <pre>
151 $obj-&gt;pathname($RCS_DIR . '/' . 'butthead.c');
152 and
153 $obj-&gt;pathname($RCS_DIR . '/' . 'butthead.c,v');</pre>
154 <p>are the same as</p>
155 <pre>
156 $obj-&gt;rcsdir($RCS_DIR);
157 $obj-&gt;file('butthead.c');</pre>
158 <p>
159 </p>
160 <h2><a name="rcs_parse_methods">RCS PARSE METHODS</a></h2>
161 <p>This class provides methods to directly parse the RCS archive file.</p>
162 <p>The <strong>access</strong> method returns a list of all user on the access list.</p>
163 <pre>
164 @access_list = $obj-&gt;access;</pre>
165 <p>The <strong>author</strong> method returns the author of the revision. The head revision
166 is used if no revision argument is passed to method.</p>
167 <pre>
168 # returns the author of revision '1.3'
169 $author = $obj-&gt;author('1.3');</pre>
170 <pre>
171 # returns the authos of the head revision
172 $author = $obj-&gt;author;</pre>
173 <p>The <strong>head</strong> method returns the head revision.</p>
174 <pre>
175 $head = $obj-&gt;head;</pre>
176 <p>The <strong>lock</strong> method returns the locker of the revision. The method returns
177 null if the revision is unlocked. The head revision is used if no revision
178 argument is passed to method. When called in list context the lock method
179 returns a hash of all locks.</p>
180 <pre>
181 # returns locker of revision '1.3'
182 $locker = $obj-&gt;lock('1.3');</pre>
183 <pre>
184 # returns locker of head revision
185 $locker = $obj-&gt;lock;</pre>
186 <pre>
187 # return hash of all locks
188 %locks = $obj-&gt;lock; # called in list context
189 foreach $rev (keys %locks) {
190 $locker = $locks{$rev};
191 print &quot;User $locker has revision $rev locked\n&quot;;
192 }</pre>
193 <p>The <strong>revisions</strong> method returns a list of all revisions of archive file.</p>
194 <pre>
195 @revisions = $obj-&gt;revisions;</pre>
196 <p>The <strong>state</strong> method returns the state of the revision. The head revision
197 is used if no revision argument is passed to method.</p>
198 <pre>
199 # returns state of revision '1.3'
200 $state = $obj-&gt;state('1.3');</pre>
201 <pre>
202 # returns state of head revision
203 $state = $obj-&gt;state;</pre>
204 <p>The <strong>symbol</strong> method returns the <code>symbol(s)</code> associated with a revision.
205 If called in list context, method returns all symbols associated with
206 revision. If called in scalar context, method returns last symbol
207 assciated with a revision. The head revision is used if no revision argument
208 is passed to method.</p>
209 <pre>
210 # list context, returns all symbols associated with revision 1.3
211 @symbols = $obj-&gt;symbol('1.3');</pre>
212 <pre>
213 # list context, returns all symbols associated with head revision
214 @symbols = $obj-&gt;symbol;</pre>
215 <pre>
216 # scalar context, returns last symbol associated with revision 1.3
217 $symbol = $obj-&gt;symbol('1.3');</pre>
218 <pre>
219 # scalar context, returns last symbol associated with head revision
220 $symbol = $obj-&gt;symbol;</pre>
221 <p>The <strong>symbols</strong> method returns a hash, keyed by symbol, of all of the revisions
222 associated with the file.</p>
223 <pre>
224 %symbols = $obj-&gt;symbols;
225 foreach $sym (keys %symbols) {
226 $rev = $symbols{$sym};
227 }</pre>
228 <p>The <strong>revdate</strong> method returns the date of a revision. The returned date format
229 is the same as the localtime format. When called as a scalar, it returns the
230 system date number. If called is list context, the list
231 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) is returned.</p>
232 <pre>
233 # scalar mode
234 $scalar_date = $obj-&gt;revdate;
235 print &quot;Scalar date number = $scalar_date\n&quot;;
236 $date_str = localtime($scalar_date);
237 print &quot;Scalar date string = $date_str\n&quot;;</pre>
238 <pre>
239 # list mode
240 @list_date = $obj-&gt;revdate;
241 print &quot;List date = @list_date\n&quot;;</pre>
242 <p>The <strong>dates</strong> method returns a hash of revision dates, keyed on revision. The
243 hash values are system date numbers. When called in scalar mode, the method
244 returns the most recent revision date.</p>
245 <pre>
246 # list mode
247 %DatesHash = obj-&gt;dates;
248 @dates_list = sort {$b&lt;=&gt;$a} values %DatesHash;
249 $MostRecent = $dates_list[0];</pre>
250 <pre>
251 # scalar mode
252 $most_recent = $obj-&gt;dates;
253 print &quot;Most recent date = $most_recent\n&quot;;
254 $most_recent_str = localtime($most_recent);
255 print &quot;Most recent date string = $most_recent_str\n&quot;;</pre>
256 <p>The <strong>symrev</strong> method returns the revision against which a specified symbol was
257 defined. If the symbol was not defined against any version of this file, 0 is
258 returned.</p>
259 <pre>
260 # gets revision that has 'MY_SYMBOL' defined against it
261 $rev = $obj-&gt;symrev('MY_SYMBOL');</pre>
262 <p>The <strong>daterev</strong> method returns revisions which were created before a specified
263 date. Method may take one or six arguments. If one arguments is passed, then
264 the argument is a date number. If six arguments are passed, then they represent
265 a date string.</p>
266 <pre>
267 # one argument, date number
268 # gets revisions created before Sun Sep 6 22:23:47 1998
269 @revs = $obj-&gt;daterev(841436420);</pre>
270 <pre>
271 # six argument
272 # gets revisions created before 25th June 1998 16:45:30
273 @revs = $obj-&gt;daterev(1998, 6, 25, 16, 45, 30);</pre>
274 <p>The <strong>comments</strong> method returns a hash of revision comments, keyed on revision.
275 A key value of 0 returns the description.</p>
276 <pre>
277 %comments = $obj-&gt;comments;
278 $description = $comments{0};
279 $comment_1_3 = $comments{'1.3'};</pre>
280 <p>
281 </p>
282 <h2><a name="rcs_system_methods">RCS SYSTEM METHODS</a></h2>
283 <p>These methods invoke the RCS system utilities.</p>
284 <p>The <strong>ci</strong> method calls the RCS ci program.</p>
285 <pre>
286 # check in, and then check out in unlocked state
287 $obj-&gt;ci('-u');</pre>
288 <p>The <strong>co</strong> method calls the RCS co program.</p>
289 <pre>
290 # check out in locked state
291 $obj-&gt;co('-l');</pre>
292 <p>The <strong>rcs</strong> method calls the RCS rcs program.</p>
293 <pre>
294 # lock file
295 $obj-&gt;rcs('-l');</pre>
296 <p>The <strong>rcsdiff</strong> method calls the RCS rcsdiff program. When called in
297 list context, this method returns the outpout of the rcsdiff program.
298 When called in scalar context, this method returns the return status of
299 the rcsdiff program. The return status is 0 for the same, 1 for some
300 differences, and 2 for error condition.</p>
301 <p>When called without parameters, rcsdiff does a diff between the current
302 working file, and the last revision checked in.</p>
303 <pre>
304 # call in list context
305 @diff_output = $obj-&gt;rcsdiff;</pre>
306 <pre>
307 # call in scalar context
308 $changed = $obj-&gt;rcsdiff;
309 if ($changed) {
310 print &quot;Working file has changed\n&quot;;
311 }</pre>
312 <p>Call rcsdiff with parameters to do a diff between any two revisions.</p>
313 <pre>
314 @diff_output = $obj-&gt;rcsdiff('-r1.2', '-r1.1');</pre>
315 <p>The <strong>rlog</strong> method calls the RCS rlog program. This method returns the
316 output of the rlog program.</p>
317 <pre>
318 # get complete log output
319 @rlog_complete = $obj-&gt;rlog;</pre>
320 <pre>
321 # called with '-h' switch outputs only header information
322 @rlog_header = $obj-&gt;rlog('-h');
323 print @rlog_header;</pre>
324 <p>The <strong>rcsclean</strong> method calls the RCS rcsclean program.</p>
325 <pre>
326 # remove working file
327 $obj-&gt;rcsclean;</pre>
328 <p>
329 </p>
330 <hr />
331 <h1><a name="examples">EXAMPLES</a></h1>
332 <p>
333 </p>
334 <h2><a name="create_access_list">CREATE ACCESS LIST</a></h2>
335 <p>Using method <strong>rcs</strong> with the <strong>-a</strong> switch allows you to add users to
336 the access list of an RCS archive file.</p>
337 <pre>
338 use Rcs;
339 $obj = Rcs-&gt;new;</pre>
340 <pre>
341 $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);
342 $obj-&gt;workdir(&quot;./project_tree/src&quot;);
343 $obj-&gt;file(&quot;cornholio.pl&quot;);</pre>
344 <p>Methos <strong>rcs</strong> invokes the RCS utility rcs with the same parameters.</p>
345 <pre>
346 @users = qw(beavis butthead);
347 $obj-&gt;rcs(&quot;-a@users&quot;);</pre>
348 <p>Calling method <strong>access</strong> returns list of users on access list.</p>
349 <pre>
350 $filename = $obj-&gt;file;
351 @access_list = $obj-&gt;access;
352 print &quot;Users @access_list are on the access list of $filename\n&quot;;</pre>
353 <p>
354 </p>
355 <h2><a name="parse_rcs_archive_file">PARSE RCS ARCHIVE FILE</a></h2>
356 <p>Set class variables and create 'RCS' object.
357 Set bin directory where RCS programs (e.g. rcs, ci, co) reside. The
358 default is '/usr/local/bin'. This sets the bin directory for all objects.</p>
359 <pre>
360 use Rcs;
361 Rcs-&gt;bindir('/usr/bin');
362 $obj = Rcs-&gt;new;</pre>
363 <p>Set information regarding RCS object. This information includes name of the
364 working file, directory of working file ('.' by default), and RCS archive
365 directory ('./RCS' by default).</p>
366 <pre>
367 $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);
368 $obj-&gt;workdir(&quot;./project_tree/src&quot;);
369 $obj-&gt;file(&quot;cornholio.pl&quot;);</pre>
370 <pre>
371 $head_rev = $obj-&gt;head;
372 $locker = $obj-&gt;lock;
373 $author = $obj-&gt;author;
374 @access = $obj-&gt;access;
375 @revisions = $obj-&gt;revisions;</pre>
376 <pre>
377 $filename = $obj-&gt;file;</pre>
378 <pre>
379 if ($locker) {
380 print &quot;Head revision $head_rev is locked by $locker\n&quot;;
381 }
382 else {
383 print &quot;Head revision $head_rev is unlocked\n&quot;;
384 }</pre>
385 <pre>
386 if (@access) {
387 print &quot;\nThe following users are on the access list of file $filename\n&quot;;
388 map { print &quot;User: $_\n&quot;} @access;
389 }</pre>
390 <pre>
391 print &quot;\nList of all revisions of $filename\n&quot;;
392 foreach $rev (@revisions) {
393 print &quot;Revision: $rev\n&quot;;
394 }</pre>
395 <p>
396 </p>
397 <h2><a name="checkin_file">CHECK-IN FILE</a></h2>
398 <p>Set class variables and create 'RCS' object.
399 Set bin directory where RCS programs (e.g. rcs, ci, co) reside. The
400 default is '/usr/local/bin'. This sets the bin directory for all objects.</p>
401 <pre>
402 use Rcs;
403 Rcs-&gt;bindir('/usr/bin');
404 Rcs-&gt;quiet(0); # turn off quiet mode
405 $obj = Rcs-&gt;new;</pre>
406 <p>Set information regarding RCS object. This information includes name of
407 working file, directory of working file ('.' by default), and RCS archive
408 directory ('./RCS' by default).</p>
409 <pre>
410 $obj-&gt;file('cornholio.pl');</pre>
411 <pre>
412 # Set RCS archive directory, is './RCS' by default
413 $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);</pre>
414 <pre>
415 # Set working directory, is '.' by default
416 $obj-&gt;workdir(&quot;./project_tree/src&quot;);</pre>
417 <p>Check in file using <strong>-u</strong> switch. This will check in the file, and will then
418 check out the file in an unlocked state. The <strong>-m</strong> switch is used to set the
419 revision comment.</p>
420 <p>Command:</p>
421 <pre>
422 $obj-&gt;ci('-u', '-mRevision Comment');</pre>
423 <p>is equivalent to commands:</p>
424 <pre>
425 $obj-&gt;ci('-mRevision Comment');
426 $obj-&gt;co;</pre>
427 <p>
428 </p>
429 <h2><a name="checkout_file">CHECK-OUT FILE</a></h2>
430 <p>Set class variables and create 'RCS' object.
431 Set bin directory where RCS programs (e.g. rcs, ci, co) reside. The
432 default is '/usr/local/bin'. This sets the bin directory for all objects.</p>
433 <pre>
434 use Rcs;
435 Rcs-&gt;bindir('/usr/bin');
436 Rcs-&gt;quiet(0); # turn off quiet mode
437 $obj = Rcs-&gt;new;</pre>
438 <p>Set information regarding RCS object. This information includes name of
439 working file, directory of working file ('.' by default), and RCS archive
440 directory ('./RCS' by default).</p>
441 <pre>
442 $obj-&gt;file('cornholio.pl');</pre>
443 <pre>
444 # Set RCS archive directory, is './RCS' by default
445 $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);</pre>
446 <pre>
447 # Set working directory, is '.' by default
448 $obj-&gt;workdir(&quot;./project_tree/src&quot;);</pre>
449 <p>Check out file read-only:</p>
450 <pre>
451 $obj-&gt;co;</pre>
452 <p>or check out and lock file:</p>
453 <pre>
454 $obj-&gt;co('-l');</pre>
455 <p>
456 </p>
457 <h2><a name="rcsdiff">RCSDIFF</a></h2>
458 <p>Method <strong>rcsdiff</strong> does an diff between revisions.</p>
459 <pre>
460 $obj = Rcs-&gt;new;
461 $obj-&gt;bindir('/usr/bin');</pre>
462 <pre>
463 $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);
464 $obj-&gt;workdir(&quot;./project_tree/src&quot;);
465 $obj-&gt;file(&quot;cornholio.pl&quot;);</pre>
466 <pre>
467 print &quot;Diff of current working file\n&quot;;
468 if ($obj-&gt;rcsdiff) { # scalar context
469 print $obj-&gt;rcsdiff; # list context
470 }
471 else {
472 print &quot;Versions are Equal\n&quot;;
473 }</pre>
474 <pre>
475 print &quot;\n\nDiff of revisions 1.2 and 1.1\n&quot;;
476 print $obj-&gt;rcsdiff('-r1.2', '-r1.1');</pre>
477 <p>
478 </p>
479 <h2><a name="rcsclean">RCSCLEAN</a></h2>
480 <p>Method <strong>rcsclean</strong> will remove an unlocked working file.</p>
481 <pre>
482 use Rcs;
483 Rcs-&gt;bindir('/usr/bin');
484 Rcs-&gt;quiet(0); # turn off quiet mode
485 $obj = Rcs-&gt;new;</pre>
486 <pre>
487 $obj-&gt;rcsdir(&quot;./project_tree/archive&quot;);
488 $obj-&gt;workdir(&quot;./project_tree/src&quot;);
489 $obj-&gt;file(&quot;cornholio.pl&quot;);</pre>
490 <pre>
491 print &quot;Quiet mode NOT set\n&quot; unless Rcs-&gt;quiet;</pre>
492 <pre>
493 $obj-&gt;rcsclean;</pre>
494 <p>
495 </p>
496 <hr />
497 <h1><a name="author">AUTHOR</a></h1>
498 <p>Craig Freter, &lt;<em><a href="mailto:[email protected]">[email protected]</a></em>&gt;</p>
499 <p>
500 </p>
501 <hr />
502 <h1><a name="contributors">CONTRIBUTORS</a></h1>
503 <p>David Green, &lt;<em><a href="mailto:[email protected]">[email protected]</a></em>&gt;</p>
504 <p>Jamie O'Shaughnessy, &lt;<em><a href="mailto:[email protected]">[email protected]</a></em>&gt;</p>
505 <p>Raju Krishnamurthy, &lt;<em><a href="mailto:[email protected]">[email protected]</a></em>&gt;</p>
506 <p>
507 </p>
508 <hr />
509 <h1><a name="copyright">COPYRIGHT</a></h1>
510 <p>Copyright (C) 1997,2003 Craig Freter. All rights reserved.
511 This program is free software; you can redistribute it and/or
512 modify it under the same terms as Perl itself.</p>
513
514 </body>
515
516 </html>