版本管理:RCS之命令基础篇
RCS作为非常古老的版本工具,远远在SVN和已经退役的CVS之前。它的古老程度应该比Web开发的ASP前代的CGI还要久远。但是作为非常简单的文本格式的版本管理工具,它使用时间跨度之久令人惊奇。如果想对版本管理实现方式进行深入研究的话,RCS提供了一种最为简单的方式,,v文件是RCS的全部,以文本形式存放,简单易读,对于想深入了解版本管理或者想开发类似工具的开发者来说,绝对是可以借鉴的。
安装
比如像centos等,新的centos7之前应该都是被缺省安装的。如果没有的话,yum install rcs即可。230k左右的package,可以完成很多的功能。
===================================================================================================================================================Package Arch Version Repository Size
===================================================================================================================================================
Installing:
rcs x86_64 5.9.0-5.el7 base 230 kTransaction Summary
===================================================================================================================================================
版本确认
[root@host31 ~]# rcs --version
rcs (GNU RCS) 5.9.0
Copyright (C) 2010-2013 Thien-Thi Nguyen
Copyright (C) 1990-1995 Paul Eggert
Copyright (C) 1982,1988,1989 Walter F. Tichy, Purdue CS
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@host31 ~]#
checkin命令:ci
准备
[root@host31 ~]# mkdir -p /local/testrcs
[root@host31 ~]# cd /local/testrcs
[root@host31 testrcs]# mkdir RCS
[root@host31 testrcs]# echo "#include <stdio.h>" >hello.h
checkin命令:ci
[root@host31 testrcs]# ci hello.h
RCS/hello.h,v <-- hello.h
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> initial version
>> .
initial revision: 1.1
done
[root@host31 testrcs]#
checkin后的确认,发现文件不见了,只有RCS下生成的,v文件了
[root@host31 testrcs]# ll
total 0
drwxr-xr-x. 2 root root 22 Aug 15 21:48 RCS
[root@host31 testrcs]# ll RCS
total 4
-r--r--r--. 1 root root 213 Aug 15 21:48 hello.h,v
[root@host31 testrcs]# cat RCS/hello.h,v
head 1.1;
access;
symbols;
locks; strict;
comment @ * @;1.1
date 2016.08.15.17.47.54; author root; state Exp;
branches;
next ;desc
@initial version
@1.1
log
@Initial revision
@
text
@#include <stdio.h>
@
[root@host31 testrcs]#
再看hello.h,v文件你会清晰地发现版本管理中需要考虑的东西内容,branch/lock/log/tag/操作等,你在SVN中能做到的事情RCS同样可以做到,只不过有时需要再封装一层。在没有SVN和git甚至没有CVS的时代我们就曾经通过自己封装RCS做到多项目同时开发,branch/tag/自动merge无所不能,工具本身没有所谓那个更好,对我们来说只是方便和合适最为重要。
checkout命令:co
[root@host31 testrcs]# ll
total 0
drwxr-xr-x. 2 root root 22 Aug 15 21:48 RCS
[root@host31 testrcs]# co hello.h
RCS/hello.h,v --> hello.h
revision 1.1
done
[root@host31 testrcs]#
修正差分确认:rcsdiff
准备:事前lock住要修正的文件。
[root@host31 testrcs]# co -l hello.h
RCS/hello.h,v --> hello.h
revision 1.1 (locked)
done
[root@host31 testrcs]#
在hello.h中增加一行
[root@host31 testrcs]# cat hello.h
#include <stdio.h>
#include <string.h>
[root@host31 testrcs]#
checkin之前确认差分
[root@host31 testrcs]# rcsdiff hello.h
===================================================================
RCS file: RCS/hello.h,v
retrieving revision 1.1
diff -r1.1 hello.h
1a2
> #include <string.h>
[root@host31 testrcs]#
checkin, 在1.1的版本之上生成1.2,ci -u即可保证本地文件在checkin之后不被删除。
[root@host31 testrcs]# ci -u hello.h
RCS/hello.h,v <-- hello.h
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> add string.h
>> .
done
[root@host31 testrcs]# ll
total 4
-r--r--r--. 1 root root 39 Aug 15 22:00 hello.h
drwxr-xr-x. 2 root root 22 Aug 15 22:03 RCS
[root@host31 testrcs]#
也可以使用如下的方式进行确认
[root@host31 testrcs]# rcsdiff -r1.1 -r1.2 hello.h
===================================================================
RCS file: RCS/hello.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -r1.1 -r1.2
1a2
> #include <string.h>
[root@host31 testrcs]#
创建branch
[root@host31 testrcs]# ci -r2.0 -f -m "initial" hello.h
RCS/initial,v <-- initial
ci: initial: No such file or directory
RCS/hello.h,v <-- hello.h
new revision: 2.0; previous revision: 1.2
done
[root@host31 testrcs]#
[root@host31 testrcs]# co -l hello.h
RCS/hello.h,v --> hello.h
revision 2.0 (locked)
done
[root@host31 testrcs]#
[root@host31 testrcs]# rcsdiff hello.h
===================================================================
RCS file: RCS/hello.h,v
retrieving revision 2.0
diff -r2.0 hello.h
2a3
> #include "test.h"
[root@host31 testrcs]#
[root@host31 testrcs]# ci -u hello.h
RCS/hello.h,v <-- hello.h
new revision: 2.1; previous revision: 2.0
enter log message, terminated with single '.' or end of file:
>> modify for 2.0
>> .
done
[root@host31 testrcs]#
在2.1的版本上继续lock,修改,checkin,发现只能继续生成2.2的版本
[root@host31 testrcs]# co -l -r2.1 hello.h
RCS/hello.h,v --> hello.h
revision 2.1 (locked)
done
[root@host31 testrcs]# vi hello.h
[root@host31 testrcs]# rcsdiff hello.h
===================================================================
RCS file: RCS/hello.h,v
retrieving revision 2.1
diff -r2.1 hello.h
3a4
> #include "test2.1.h"
[root@host31 testrcs]# ci -u -m "add test2.1.h" hello.h
RCS/add test2.1.h,v <-- add test2.1.h
ci: add test2.1.h: No such file or directory
RCS/hello.h,v <-- hello.h
new revision: 2.2; previous revision: 2.1
done
[root@host31 testrcs]#
如果我们现在对旧的版本1.1进行lock,然后修正,然后checkin会发生什么呢
[root@host31 testrcs]# co -l -r1.1 hello.h
RCS/hello.h,v --> hello.h
revision 1.1 (locked)
done
[root@host31 testrcs]# vi hello.h
[root@host31 testrcs]# rcsdiff hello.h
===================================================================
RCS file: RCS/hello.h,v
retrieving revision 2.2
diff -r2.2 hello.h
2,4c2
< #include <string.h>
< #include "test.h"
< #include "test2.1.h"
---
> #include "test1.1.h"
[root@host31 testrcs]# ci -u -m "add test1.1.h" hello.h
RCS/add test1.1.h,v <-- add test1.1.h
ci: add test1.1.h: No such file or directory
RCS/hello.h,v <-- hello.h
new revision: 1.1.1.1; previous revision: 1.1
done
[root@host31 testrcs]#
1.0/2.0进行大的Trunk管理,在其下生成的1.1 2.1等进行lock,进一步生成第一层的Branch,这是个4位的版本号,1.1.1.1, 第四位是文件自身的版本号,第三位第一层Branch号,第一位和第二位结合起来为发生branch的位置。能不能生成2层的branch呢,答案是肯定的,如果项目有奇葩的需求的话,你可以继续往下生成branch。现在你的版本号是1.1.1.1.1.1了,够不够长。
[root@host31 testrcs]# co -l -r1.1.1.1 hello.h
RCS/hello.h,v --> hello.h
revision 1.1.1.1 (locked)
done
[root@host31 testrcs]# vi hello.h
[root@host31 testrcs]# rcsdiff hello.h
===================================================================
RCS file: RCS/hello.h,v
retrieving revision 2.2
diff -r2.2 hello.h
2,4c2,3
< #include <string.h>
< #include "test.h"
< #include "test2.1.h"
---
> #include "test1.1.h"
> #include "test1.1.1.1.h"
[root@host31 testrcs]#
[root@host31 testrcs]# ci -u -m "add test1.1.1.1.h" hello.h
RCS/add test1.1.1.1.h,v <-- add test1.1.1.1.h
ci: add test1.1.1.1.h: No such file or directory
RCS/hello.h,v <-- hello.h
new revision: 1.1.1.2; previous revision: 1.1.1.1
done
[root@host31 testrcs]#
[root@host31 testrcs]# co -l -r1.1.1.1 hello.h
RCS/hello.h,v --> hello.h
revision 1.1.1.1 (locked)
done
[root@host31 testrcs]# vi hello.h
[root@host31 testrcs]# rcsdiff hello.h
===================================================================
RCS file: RCS/hello.h,v
retrieving revision 2.2
diff -r2.2 hello.h
2,4c2,3
< #include <string.h>
< #include "test.h"
< #include "test2.1.h"
---
> #include "test1.1.h"
> #include "test1.1.1.1.branch.h"
[root@host31 testrcs]# ci -u -m "1.1.1.1 branch" hello.h
RCS/1.1.1.1 branch,v <-- 1.1.1.1 branch
ci: 1.1.1.1 branch: No such file or directory
RCS/hello.h,v <-- hello.h
new revision: 1.1.1.1.1.1; previous revision: 1.1.1.1
done
[root@host31 testrcs]#
rlog确认详细信息
[root@host31 testrcs]# rlog hello.hRCS file: RCS/hello.h,v
Working file: hello.h
head: 2.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 8; selected revisions: 8
description:
initial version
----------------------------
revision 2.2
date: 2016/08/15 22:13:25; author: root; state: Exp; lines: +1 -0
*** empty log message ***
----------------------------
revision 2.1
date: 2016/08/15 22:10:19; author: root; state: Exp; lines: +1 -0
modify for 2.0
----------------------------
revision 2.0
date: 2016/08/15 22:07:41; author: root; state: Exp; lines: +0 -0
*** empty log message ***
----------------------------
revision 1.2
date: 2016/08/15 22:03:45; author: root; state: Exp; lines: +1 -0
add string.h
----------------------------
revision 1.1
date: 2016/08/15 21:47:54; author: root; state: Exp;
branches: 1.1.1;
Initial revision
----------------------------
revision 1.1.1.2
date: 2016/08/15 22:31:13; author: root; state: Exp; lines: +1 -0
*** empty log message ***
----------------------------
revision 1.1.1.1
date: 2016/08/15 22:15:10; author: root; state: Exp; lines: +1 -0
branches: 1.1.1.1.1;
*** empty log message ***
----------------------------
revision 1.1.1.1.1.1
date: 2016/08/15 22:32:27; author: root; state: Exp; lines: +1 -0
*** empty log message ***
=============================================================================
[root@host31 testrcs]#
rlog -h 则可以单独列出symbolicnames等信息
[root@host31 testrcs]# rlog -h hello.hRCS file: RCS/hello.h,v
Working file: hello.h
head: 2.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 8
=============================================================================
[root@host31 testrcs]#
修改注释 rcs -m
修正前rlog信息
revision 1.1
date: 2016/08/15 21:47:54; author: root; state: Exp;
branches: 1.1.1;
Initial revision
[root@host31 testrcs]# rcs -m1.1:"initial version" hello.h
RCS file: RCS/hello.h,v
done
[root@host31 testrcs]#
修正后rlog信息
revision 1.1
date: 2016/08/15 21:47:54; author: root; state: Exp;
branches: 1.1.1;
initial version
注意:-m和版本之间不能有空格等细小的事项
管理symbolic names: rcs -n
为什么要用symbolic names,很简单,作tag。使用方便的管理工具的时候你可能不会意识到版本管理工具替你做了什么,但是用RCS,需要一个文件一个文件的设定上tag,无论什么样的版本管理工具,他们都应该是类似,有一种特定的方法将某一时间断面的所有文件进行整体管理。现代的版本管理工具不会让你如此麻烦,但同时也拿去了我们了解其实际运作的机会。
[root@host31 testrcs]# rcs -nNewBranch:1.1.1.1.1.1 hello.h
RCS file: RCS/hello.h,v
done
[root@host31 testrcs]# rlog -h hello.hRCS file: RCS/hello.h,v
Working file: hello.h
head: 2.2
branch:
locks: strict
access list:
symbolic names:
NewBranch: 1.1.1.1.1.1
keyword substitution: kv
total revisions: 8
=============================================================================
[root@host31 testrcs]#
删除symbolic names
[root@host31 testrcs]# rcs -nNewBranch hello.h
RCS file: RCS/hello.h,v
done
[root@host31 testrcs]# rcs -h hello.h
rcs: unknown option: -h
[root@host31 testrcs]# rlog -h hello.hRCS file: RCS/hello.h,v
Working file: hello.h
head: 2.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 8
=============================================================================
[root@host31 testrcs]#
注意事项:-nname:rev 的版本如果不存在的时候会出错,注意空格
删除版本 rcs -o
删除1.1.1.1.1.1这个很闹心的版本
[root@host31 testrcs]# rcs -o1.1.1.1.1.1 hello.h
RCS file: RCS/hello.h,v
deleting revision 1.1.1.1.1.1
done
[root@host31 testrcs]#
除了指定版本删除,还有可以指定from和to的一定范围的删除方式
方式 | 详细说明 |
---|---|
rev1:rev2 | 从rev1删到rev2 |
rev1: | 删除rev1开始的分支所有版本 |
:rev2 | 删除到rev2的所有版本 |
此操作无比凶险,执行之前务必保存好,v文件以便恢复
版本管理:RCS之命令基础篇相关推荐
- Cisco路由器命令基础篇
模式转换命令 用户模式----特权模式,使用命令"enable" 特权模式----全局配置模式,使用命令"config t" 全局配置模式----接口模式,使用 ...
- attrib批量显示文件夹_1.2Windows之DOS命令基础篇-学习attrib+del+copy+xcopy命令
学习要点: 1.设置文件属性:attrib 2.删除命令:del 3.复制文件:copy 4.复制文件(夹):xcopy --------------------------------------- ...
- Linux shell命令(基础篇)
命令行: Linux shell命令: pwd:打印当前工作的路径. ls:展示当前目录下的内容. ls -l : 查看某一目录会得到一个7个字段的列表. **七个字段分别对应的含义:**第1 ...
- 项目版本管理的最佳实践:gitflow基础篇
对于项目版本管理,你是否存在这样的痛点:项目分支多而杂不好管理,git log界面commit信息错乱复杂无规范,版本回退不知道选择什么版本合适--. 项目版本管理的最佳实践系列,笔者将以两篇文章的形 ...
- Java全链路复习面经-基础篇(2.5万字全文)
序言 主要分为两篇,一篇基础篇,涵盖Java基础,数据库,JVM,计算机网络等知识 另一篇为框架篇,主要为流行框架,如Spring.SpringMVC.Mybatis.SpringBoot.Sprin ...
- fdisk 分区_【linux】循序渐进学运维-基础篇-分区命令fdisk
大家好,我是高胜寒,本文是Linux运维-循序渐进学运维-基础篇的第47篇文章. 本文我们来讨论一下fdisk命令的使用,使用fdisk可以做分区管理. 1. 命令概述: fdisk 作用: 磁盘分区 ...
- LINUX学习基础篇(六)帮助命令
LINUX学习基础篇(六)帮助命令 帮助命令 man(Manual) info help - -help 帮助命令 man(Manual) 作用:查看联机帮助手册. 执行权限:所有用户. man命令的 ...
- LINUX学习基础篇(十二)痕迹命令
LINUX学习基础篇(十二)痕迹命令 系统痕迹命令 w命令 who命令 last命令 lastlog命令 lastb命令 系统痕迹命令 系统中有一些重要的痕迹日志文件,如/var/log/wtmp./ ...
- 【linux】循序渐进学运维-基础篇-netstat命令详解
大家好,我是高胜寒,本文是Linux运维-循序渐进学运维-基础篇的第62篇文章 文章目录 前言 一. netstat命令详解 作用 1. 常用参数 2. 命令使用 1) 参数作用详解 2) 网络连接状 ...
最新文章
- confirm自定义按钮文字_公众号涨粉神器——自定义菜单,互动运营更灵活!
- 从创作工具到虚拟超现实主义,聊一聊VR的艺术王国
- erlang-百度云推送Android服务端功能实现-erlang
- C 语言精髓之变参函数
- Docker - 实战TLS加密通讯
- python学习笔记之random模块
- Mybatis框架 导入/导出功能的实现
- AI 对不起 我还爱着你
- SAMBA服务和FTP/sshd 服务讲解
- Crackme 25
- Joson请求后台数据维护
- ESP8266 NonOS-SDK Web配网
- 计算机算法基础_如何自学计算机专业
- 系统重装之后如何恢复mysql数据
- 深入理解读写锁ReentrantReadWriteLock
- 西门子840Dsl系统的刀具列表数据采集
- MATLAB学习(2)输出函数
- inductive bias:归纳偏置
- PDF压缩在线怎么操作?这几个操作谁还不知道
- Photoshop 速写效果