909-911.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 149 行
HTML
149 行
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Source Code Control</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=56//-->
<!--PAGES=909-911//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="906-909.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="912-914.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading14"></A><FONT COLOR="#000077">Retrieving Version Information from an RCS File</FONT></H3>
<P>Instead of querying the contents of an RCS file based on keywords, you might be interested in obtaining summary information about the version attributes using the <TT>rlog</TT> command with the <TT>-t</TT> option. On the <TT>finest.c</TT> RCS file, the output from</P>
<!-- CODE SNIP //-->
<PRE>
$ rlog -t finest.c
</PRE>
<!-- END CODE SNIP //-->
<P>produces output formatted like this:
</P>
<!-- CODE //-->
<PRE>
RCS file: finest.c,v; Working file: finest.c
head: 3.2
locks: pete: 2.1; strict
access list: rick tim
symbolic names:
comment leader: “ * “
total revisions: 10;
description:
You know…programming at its finest…
=========================================================
</PRE>
<!-- END CODE //-->
<P><TT>head</TT>refers to the version number of the highest revision in the entire stream. <TT>locks</TT> describes which users have versions checked out and the type of lock (strict or implicit for the RCS file owner). <TT>access list</TT> is a list of users who are authorized to make deltas on this RCS file. The next section illustrates how user-access privileges for an RCS file can be changed.</P>
<H3><A NAME="Heading15"></A><FONT COLOR="#000077">Administering Access</FONT></H3>
<P>One of the most important functions of RCS is to mediate the access of users to a set of files. For each file, RCS maintain a list of users who have permission to create deltas on that file. This list is empty to begin with, so that all users have permission to make deltas. The <TT>rcs</TT> command is used to assign usernames or group names with delta privileges. The command</P>
<!-- CODE SNIP //-->
<PRE>
$ rcs -arick,tim finest.c
</PRE>
<!-- END CODE SNIP //-->
<P>enables the users Rick and Tim to make deltas on <TT>finest.c</TT> and simultaneously restricts all other users (except the owner) from that privilege.</P>
<P>Perhaps you change your mind and decide that the user Rick is not worthy of making deltas on your wonderful <TT>finest.c</TT> program. You can deny him that privilege using the <TT>-e</TT> option:</P>
<!-- CODE SNIP //-->
<PRE>
& rcs -erick finest.c
</PRE>
<!-- END CODE SNIP //-->
<P>Suddenly, in a fit of paranoia, you trust no one to make deltas on <TT>finest.c</TT>. Like a software Mussolini, you place a global lock (which applies to everyone, including the owner) on release 2 of <TT>finest.c</TT> using the <TT>-e</TT> and <TT>-L</TT> options</P>
<!-- CODE SNIP //-->
<PRE>
$ rcs -e -L2 finest.c
</PRE>
<!-- END CODE SNIP //-->
<P>so that no one can make changes on any delta in the release 2 stream. Only the file owner can make changes, but this person still has to explicitly put a lock on the file for every check-out and check-in operation.
</P>
<H3><A NAME="Heading16"></A><FONT COLOR="#000077">Comparing and Merging Revisions</FONT></H3>
<P>Revisions can be compared to each other to discover what, if any, differences lie between them. This can be used as a means of safely merging together edits of a single source file by different developers. The <TT>rcsdiff</TT> command is used to show differences between revisions existing in an RCS file or between a checked-out version and the most current revision in the RCS file. To compare the <TT>finest.c</TT> 1.2 version to the 1.5 version, enter</P>
<!-- CODE SNIP //-->
<PRE>
$ rcsdiff -r1.2 -r1.5 finest.c
</PRE>
<!-- END CODE SNIP //-->
<P>The output is something like
</P>
<!-- CODE SNIP //-->
<PRE>
RCS file: finest.c,v
retrieving revision 1.1
rdiff -r1.2 -r1.5 finest.c
6a7,8
>
> /* …but what good is this? */
</PRE>
<!-- END CODE SNIP //-->
<P>This output indicates that the only difference between the files is that two new lines have been added after the original line six. To just compare your current checked-out version with that of the “head” version in the RCS file, simply enter
</P>
<!-- CODE SNIP //-->
<PRE>
$ rcsdiff finest.c
</PRE>
<!-- END CODE SNIP //-->
<P>Once you have determined if there are any conflicts between your edits and others, you may decide to merge revisions. You can do this with the <TT>rcsmerge</TT> command. The format of this command is to take one or two filenames representing the version to be merged and a third filename indicating the working file (in the following example, this is <TT>finest.c</TT>).</P>
<P>The command</P>
<!-- CODE SNIP //-->
<PRE>
$ rcsmerge -r1.3 -r1.6 finest.c
</PRE>
<!-- END CODE SNIP //-->
<P>produces output like this:
</P>
<!-- CODE SNIP //-->
<PRE>
RCS file: finest.c,v
retrieving revision 1.3
retrieving revision 1.6
Merging differences between 1.3 and 1.6 into finest.c
</PRE>
<!-- END CODE SNIP //-->
<P>If any lines between the two files overlap, <TT>rcsmerge</TT> indicates the lines that originate from a particular merged file in the working copy. You have to resolve these overlaps by explicitly editing the working copy to remove any conflicts before checking the working copy back into RCS.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>Note: </B><BR>There is an implied order in which the files to be merged are placed in the <TT>rcsmerge</TT> command. If you are placing a higher version before a lower one at the <TT>-r</TT> options, this is essentially undoing the edits that have transpired from the older (lower) version to the newer (higher) version.<HR></FONT>
</BLOCKQUOTE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="906-909.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="912-914.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?