Subversion is a free/open source version control system (VCS). That is, Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine.”
Subversion 的版本库可以通过网络访问,从而使用户可以在不同的电脑上进行操作。从某种程度上来说,允许用户在各自的空间里修改和管理同一组数据可以促进团队协作。因为修改不再是单线进行,开发速度会更快。此外,由于所有的工作都已版本化,也就不必担心由于错误的更改而影响软件质量—如果出现不正确的更改,只要撤销那一次更改操作即可。
Some version control systems are also software configuration management (SCM) systems. These systems are specifically tailored to manage trees of source code and have many features that are specific to software development—such as natively understanding programming languages, or supplying tools for building software. Subversion, however, is not one of these systems. It is a general system that can be used to manage any collection of files. For you, those files might be source code—for others, anything from grocery shopping lists to digital video mixdowns and beyond.
如果你是一个考虑如何使用 Subversion 的用户或管理员,你要问自己的第一件事就是: "这是这项工作的正确工具吗?",Subversion 是一个梦幻般的锤子,但要小心不要把任何问题当作钉子。
如果你希望归档文件和目录旧版本,有可能要恢复或需要查看日志获得其修改的历史,那么 Subversion 是你需要的工具。如果你需要和别人协作文档(通常通过网络)并跟踪所做的修改,那么 Subversion 也适合。这是 Subversion 为什么使用在软件开发环境—编程是天生的社会活动,Subversion 使得与其他程序员的交互变得简单。当然,使用 Subversion 也有代价:管理负担。你会需要管理一个存放所有历史的数据版本库,并需要经常的备份。而在日常的工作中,你不能像往常一样复制, 移动, 重命名或删除文件,相反,你需要通过 Subversion 完成这些工作。
Assuming you're fine with the extra workflow, you should still make sure you're not using Subversion to solve a problem that other tools solve better. For example, because Subversion replicates data to all the collaborators involved, a common misuse is to treat it as a generic distribution system. People will sometimes use Subversion to distribute huge collections of photos, digital music, or software packages. The problem is that this sort of data usually isn't changing at all. The collection itself grows over time, but the individual files within the collection aren't being changed. In this case, using Subversion is “overkill.”[2] There are simpler tools that efficiently replicate data without the overhead of tracking changes, such as rsync or unison.
In early 2000, CollabNet, Inc. (http://www.collab.net) began seeking developers to write a replacement for CVS. CollabNet offered[3] a collaboration software suite called CollabNet Enterprise Edition (CEE), of which one component was version control. Although CEE used CVS as its initial version control system, CVS's limitations were obvious from the beginning, and CollabNet knew it would eventually have to find something better. Unfortunately, CVS had become the de facto standard in the open source world largely because there wasn't anything better, at least not under a free license. So CollabNet determined to write a new version control system from scratch, retaining the basic ideas of CVS, but without the bugs and misfeatures.
In February 2000, they contacted Karl Fogel, the author of Open Source Development with CVS (Coriolis, 1999), and asked if he'd like to work on this new project. Coincidentally, at the time Karl was already discussing a design for a new version control system with his friend Jim Blandy. In 1995, the two had started Cyclic Software, a company providing CVS support contracts, and although they later sold the business, they still used CVS every day at their jobs. Their frustration with CVS had led Jim to think carefully about better ways to manage versioned data, and he'd already come up with not only the Subversion name, but also the basic design of the Subversion data store. When CollabNet called, Karl immediately agreed to work on the project, and Jim got his employer, Red Hat Software, to essentially donate him to the project for an indefinite period of time. CollabNet hired Karl and Ben Collins-Sussman, and detailed design work began in May 2000. With the help of some well-placed prods from Brian Behlendorf and Jason Robbins of CollabNet, and from Greg Stein (at the time an independent developer active in the WebDAV/DeltaV specification process), Subversion quickly attracted a community of active developers. It turned out that many people had encountered the same frustrating experiences with CVS and welcomed the chance to finally do something about it.
最初的设计小组设定了简单的开发目标。他们不想在版本控制方法学中开垦处女地,他们只是希望修正 CVS。他们决定 Subversion 应符合 CVS 的特性,并保留相同的开发模型,但不再重复 CVS 的一些显著缺陷。尽管 Subversion 并不需要成为 CVS 的完全替代品,但它应该与 CVS 保持足够的相似性,以使 CVS 用户可以轻松的转移到 Subversion 上。
经过14个月的编码,2001年8月31日,Subversion 能够“自己管理自己”了,开发者停止使用 CVS 保存 Subversion 的代码,而使用 Subversion 本身。
While CollabNet started the project, and still funds a large chunk of the work (it pays the salaries of a few full-time Subversion developers), Subversion is run like most open source projects, governed by a loose, transparent set of rules that encourage meritocracy. In 2009, CollabNet worked with the Subversion developers towards the goal of integrating the Subversion project into the Apache Software Foundation (ASF), one of the most well-known collectives of open source projects in the world. Subversion's technical roots, community priorities, and development practices were a perfect fit for the ASF, many of whose members were already active Subversion contributors. In early 2010, Subversion was fully adopted into the ASF's family of top-level projects, moved its project web presence to http://subversion.apache.org, and was rechristened “Apache Subversion”.
图 1 “Subversion 的架构”给出了 Subversion 设计总体上的“俯视图”。
On one end is a Subversion repository that holds all of your versioned data. On the other end is your Subversion client program, which manages local reflections of portions of that versioned data. Between these extremes are multiple routes through a Repository Access (RA) layer, some of which go across computer networks and through network servers which then access the repository, others of which bypass the network altogether and access the repository directly.
安装好的 Subversion 由几个部分组成,下面将简单的介绍一下这些组件。下文的描述或许过于简略,不易理解,但不用担心—本书后面的章节中会用更多的内容来详细阐述这些组件。
命令行客户端程序
此工具用来显示工作副本的状态(用术语来说,就是当前项目的修订版本)。
直接查看 Subversion 版本库的工具
建立, 调整和修复 Subversion 版本库的工具
Apache HTTP 服务器的一个插件,使版本库可以通过网络访问
A custom standalone server program, runnable as a daemon process or invokable by SSH; another way to make your repository available to others over a network
过滤 Subversion 版本库转储数据流的工具
一个通过网络增量镜像版本库的程序
The first edition of this book was published by O'Reilly Media in 2004, shortly after Subversion had reached 1.0. Since that time, the Subversion project has continued to release new major releases of the software. Here's a quick summary of major new changes since Subversion 1.0. Note that this is not a complete list; for full details, please visit Subversion's web site at http://subversion.apache.org.
1.1 版本引入了 FSFS,纯文件的版本库存储选项。虽然 Berkeley DB 后端被广泛的使用,但因为 FSFS 其较低的门槛和较小的管理需要,FSFS 还是成为新建版本库的缺省的选项。另外这个版本能够将符号链纳入版本控制,能够自动封装 URL,还有本地化的用户界面。
1.2 版本引入了文件在服务器端锁定的功能,实现对特定资源的顺序访问。虽然 Subversion 一直基本上是一个并行版本控制系统,特定类型的的二进制文件(例如艺术作品)不能合并在一起,锁定特性填补了对此类资源的版本化保护。随着锁定也引入了一个完整的 WebDAV 自动版本实现,允许 Subversion 版本库作为网络文件夹加载。最后,Subversion 1.2 开始使用新的,更快的二进制差异算法来压缩和检索文件的旧版本。
1.3 版本为 svnserve 服务器引入路径为基础的授权控制,与 Apache 服务器对应的特性匹配。Apache 服务器自己也获得了新的日志特性,Subversion 其它语言的 API 绑定也取得了巨大的进步。
1.4 版本引入了完全的新工具 — svnsync — 用来通过网络完成单向的版本库复制。一个重要的部分是工作副本元数据得到修补,不再使用 XML(获得客户端的速度改善),而 Berkeley DB 版本库后端获得了在发生崩溃时自动恢复的能力。
Release 1.5 took much longer to finish than prior releases, but the headliner feature was gigantic: semi-automated tracking of branching and merging. This was a huge boon for users, and pushed Subversion far beyond the abilities of CVS and into the ranks of commercial competitors such as Perforce and ClearCase. Subversion 1.5 also introduced a bevy of other user-focused features, such as interactive resolution of file conflicts, sparse checkouts, client-side management of changelists, powerful new syntax for externals definitions, and SASL authentication support for the svnserve server.
Release 1.6 continued to make branching and merging more robust by introducing tree conflicts, and offered improvements to several other existing features: more interactive conflict resolution options; de-telescoping and outright exclusion support for sparse checkouts; file-based externals definitions; and operational logging support for svnserve similar to what mod_dav_svn offered. Also, the command-line client introduced a new shortcut syntax for referring to Subversion repository URLs.