版本控制


6
二 10

使用RCS管理配置文件

时下是SVNGit大行其道的时候,RCS出现的频率很小。

RCS,全称 Revision Control System ,一种版本控制系统,用于保存配置文件、Shell脚本和其他任何操作过的文本文件的多个修订版本。与SVN、Git、以及CVS不同的是,RCS不支持C/S结构,RCS的所有内容都保存在本地文件系统中。因此,RCS,不适合多人协作(于是出了SVN、Git这样的版本控制系统),相反的却非常适合管理员(甚至是多位管理员)来管理配置文件。假如你有很多机器要管理,那么另当别论!

RCS将所有修订版本都保存在文件当前目录下名为RCS/的目录中,假如该目录不存在,则保存在与文件相同的目录里。为了不使当前目录看上去很凌乱,建议使用RCS目录。

以Apache配置为例:

1. 创建仓库
mkdir /etc/httpd/conf/RCS
2. 将配置文件httpd.conf初始化到仓库中
ci -i /etc/httpd/conf/httpd.conf
/etc/httpd/conf/RCS/httpd.conf,v <– /etc/httpd/conf/httpd.conf
enter description, terminated with single ‘.’or end of file:
NOTE: This is NOT the log message!

>> Apache Configuration Files
>> .
initial revision: 1.1
done
ci -i 进行“登入和初始化”,为RCS提供文件的第一份完好的副本。RCS提示输入初始化说明,然后从当前目录中删除该文件。
3. 登出文件
co /etc/httpd/conf/httpd.conf
/etc/httpd/conf/RCS/httpd.conf,v –> /etc/httpd/conf/httpd.conf
revision 1.1
done

在RCS初始化文件文件后,登出该文件。
4. 操作配置文件
锁定文件,以防操作时其他用户对访文件进行更新。实际上,RCS是使用文件权限来控制“锁”的,比如co httpd.conf的时候,httpd.conf的文件权限被设置成444,于是不能编辑,当co -l httpd.conf时,权限被设置成 644,于是可以编辑,当ci -u httpd.conf,文件权限又被设置成444。
co -l /etc/httpd/conf/httpd.conf
/etc/httpd/conf/RCS/httpd.conf,v –> /etc/httpd/conf/httpd.conf
revision 1.1 (locked)
done

现在可以随意修改了。
5. 提交文件
完成编辑工作后,重新登入并用ci -u 解锁
ci -u /etc/httpd/conf/httpd.conf
/etc/httpd/conf/RCS/httpd.conf,v <– /etc/httpd/conf/httpd.conf
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single ‘.’or end of file:
>> unload negotiation_module and negotiation_module
>> .
done
请务必使用有意义的日志!
6. 查看文件修改了哪些内容
比如我加载了mod_logio模块:
rcsdiff /etc/httpd/conf/httpd.conf
==================================
RCS file: RCS/httpd.conf,v
retrieving revision 1.2
diff -r1.2 httpd.conf
167c167
< #LoadModule logio_module modules/mod_logio.so

> LoadModule logio_module modules/mod_logio.so

也可以查看两个不同版本之间的差别
rcsdiff -r1.1 -r1.2 httpd.conf
7. 查看修订log
rlog /etc/httpd/conf/httpd.conf
8. 登出某个版本
co -l -r1.1 /etc/httpd/conf/httpd.conf
9. 常见问题( Troubleshooting)
常见的是在登入或者登出的时候出现问题,那可能是在某些节点忘记了 -l (在co中)或 -u(在ci中)选项。通常可以先制作备份,然后再次登出该文件并复回原来的位置:
cd /etc/httpd/conf
cp httpd.conf httpd.conf.bk
co -l httpd.conf
cp httpd.conf.bk httpd.conf
ci -u httpd.conf

6.参考:
《Linux Server Hacks》
http://www.juyimeng.com/httpd-conf-version-control.html


28
三 09

分布式版本控制

Git: http://git-scm.com/

Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.

Git is used for version control of files, much like tools such as Mercurial, Bazaar, Subversion, CVS, Perforce, and Visual SourceSafe.

Git在苹果系统上非常流行。

Mercurial : http://www.selenic.com/mercurial/wiki/
http://mercurial.selenic.com/

A fast, lightweight Source Control Management system designed for efficient handling of very large distributed projects.

Bazaar : http://bazaar-vcs.org/

Bazaar is a distributed version control system that Just Works. While other systems require you to adapt to their model of working, Bazaar adapts to the way you want to work, and you can try it out in five minutes.

MySQL, Mailman, Launchpad, and the Linux Foundation are among the many projects and organizations using Bazaar.

Bazaar runs on Windows, GNU/Linux, UNIX and Mac OS, and requires only Python 2.4. If you can run Python, you can run Bazaar! It is an official GNU project, licensed under the GPLv2 or later, at your option.

Perforce  : http://www.perforce.com/perforce/products.html

The Perforce Software Configuration Management System features comprehensive SCM capabilities built around a scalable client/server architecture. Users can access the Perforce Server through a range of Perforce client software. Perforce can be deployed quickly and easily, and requires minimal administration even for large or distributed sites

参考:

http://en.wikipedia.org/wiki/Distributed_revision_control

为什么我们要放弃Subversion : http://www.infoq.com/cn/articles/thoughtworks-practice-partiv