使用RCS的示例

要在RCS中使用文件,我们首先需要使用命令ci filename将文件检入,然后添加以结尾的描述。

[john@centos ~]$ ls -l
total 4
-rw-rw-r--. 1 john john 80 Apr 23 09:53 rcs_test_file.txt
[john@centos ~]$ ci rcs_test_file.txt
rcs_test_file.txt,v  <--  rcs_test_file.txt
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> My RCS test file
>> .
initial revision: 1.1
done
[john@centos ~]$ ls -l
total 4
-r--r--r--. 1 john john 274 Apr 23 09:54 rcs_test_file.txt,v

要将文件退回以便可以读取,我们需要签出文件:

[john@centos ~]$ ls -l
total 4
-r--r--r--. 1 john john 274 Apr 23 09:54 rcs_test_file.txt,v
[john@centos ~]$ co rcs_test_file.txt
rcs_test_file.txt,v  -->  rcs_test_file.txt
revision 1.1
done
[john@centos ~]$ ls -l
total 8
-r--r--r--. 1 john john  80 Apr 23 10:00 rcs_test_file.txt
-r--r--r--. 1 john john 274 Apr 23 09:54 rcs_test_file.txt,v

如果我们需要对此只读文件进行更改,则必须首先签出该文件:

[john@centos ~]$ co -l rcs_test_file.txt
rcs_test_file.txt,v  -->  rcs_test_file.txt
revision 1.1 (locked)
done

其中一个文件已签出,您现在可以使用选择的编辑器来编辑此文件。在此示例中,我使用的是vi编辑器。进行更改后,需要以通常的方式保存这些更改。

[john@centos ~]$ vi rcs_test_file.txt
[john@centos ~]$ ls -l
total 8
-rw-r--r--. 1 john john 106 Apr 23 10:09 rcs_test_file.txt
-r--r--r--. 1 john john 284 Apr 23 10:02 rcs_test_file.txt,v

现在我们需要重新签入文件并解锁

[john@centos ~]$ ls -l
total 8
-rw-r--r--. 1 john john 106 Apr 23 10:09 rcs_test_file.txt
-r--r--r--. 1 john john 284 Apr 23 10:02 rcs_test_file.txt,v
[john@centos ~]$ ci -u rcs_test_file.txt
rcs_test_file.txt,v  <--  rcs_test_file.txt
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> Added a fourth Line of text
>> .
done

显示有关RCS文件的信息

要显示有关RCS拥有的文件的信息,可以使用命令rlog

[john@centos ~]$ rlog rcs_test_file.txt

RCS file: rcs_test_file.txt,v
Working file: rcs_test_file.txt
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;     selected revisions: 2
description:
My RCS test file
----------------------------
revision 1.2
date: 2013/04/23 09:12:08;  author: john;  state: Exp;  lines: +1 -0
Added a fourth Line of text
----------------------------
revision 1.1
date: 2013/04/23 08:54:19;  author: john;  state: Exp;
Initial revision
=============================================================================

比较RCS修订

命令rcsdiff运行diff命令来比较给定的每个RCS文件的两个修订版。两个比较不同版本的变化,我们必须指定-r参数:

例如:rcsdiff -rrev1 -rrev2 rcs_filename

[john@centos ~]$ rcsdiff -r1.2 -r1.1 rcs_test_file.txt
===================================================================
RCS file: rcs_test_file.txt,v
retrieving revision 1.2
retrieving revision 1.1
diff -r1.2 -r1.1
4d3
< Add a fourth line of text

如果同时省略了rev1和rev2,则rcsdiff会将默认分支(默认情况下是主干)上的最新修订与相应工作文件的内容进行比较。这对于确定自上次签入以来所做的更改很有用。

如果给定了rev1,但省略了rev2,则rcsdiff会将RCS文件的修订版rev1与相应工作文件的内容进行比较。

显示和签出旧版本的文件

要检索文件以前版本的内容,我们需要在Checking Out命令co中使用参数-r 版本号。要显示文件的特定版本,我们使用-p参数在屏幕上显示指定的版本。首先,我们可以使用rlog命令来显示可用的版本:

RCS file: rcs_test_file.txt,v
Working file: rcs_test_file.txt
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;     selected revisions: 2
description:
My RCS test file
----------------------------
revision 1.2
date: 2013/04/23 09:12:08;  author: john;  state: Exp;  lines: +1 -0
Added a fourth Line of text
----------------------------
revision 1.1
date: 2013/04/23 08:54:19;  author: john;  state: Exp;
Initial revision
=============================================================================

让我们显示文本文件rcs_test_file.txt初始版本

[john@centos ~]$ co -p1.1 rcs_test_file.txt
rcs_test_file.txt,v  -->  standard output
revision 1.1
Line one of rcs test file
Line two of rcs test file
Line three of rcs test file

现在让我们显示修订1.2

[john@centos ~]$ co -p 1.2 rcs_test_file.txt
co: RCS/1.2,v: No such file or directory
rcs_test_file.txt,v  -->  standard output
revision 1.2
Line one of rcs test file
Line two of rcs test file
Line three of rcs test file
Add a fourth line of text

在CentOS安装rcs

软件包:rcs-5.7-37.el6.i686.rpm
下载地址:http://pkgs.org/centos-6-rhel-6/centos-rhel-i386/rcs-5.7-37.el6.i686.rpm/download/

这里使用wget下载

[root@centos tmp]# cd /tmp
[root@centos tmp]# wget http://mirror.centos.org/centos/6/os/i386/Packages/rcs-5.7-37.el6.i686.rpm

安装rcs

[root@centos tmp]# rpm -ihv rcs-5.7-37.el6.i686.rpm
warning: rcs-5.7-37.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:rcs                    ########################################### [100%]

RCS-版本控制系统 Revision Control System

RCS是设计用于控制文件的多个版本的系统。RCS控制修订的存储,检索和合并。RCS在创建文档和脚本的人们中很受欢迎。RCS允许个人对文件进行更改,然后回滚到该文件的先前版本。

RCS-版本控制系统

了解如何使用RCS-版本控制系统来维护文件和脚本。

在基于Debian上安装RCS

john@john-desktop:~$ sudo apt-get install rcs
日期:2019-04-29 03:17:36 来源:oir作者:oir