When a client reads data from the repository, it normally sees only the latest version of the filesystem tree. But the client also has the ability to view previous states of the filesystem. For example, a client can ask historical questions like, ”what did this directory contain last Wednesday?”, or “who was the last person to change this file, and what changes did they make?” These are the sorts of questions that are at the heart of any version control system: systems that are designed to record and track changes to data over time.
锁定-修改-解锁 方案
Many version control systems use a lock-modify-unlock model to address this problem, which is a very simple solution. In such a system, the repository allows only one person to change a file at a time. First Harry must lock the file before he can begin making changes to it. Locking a file is a lot like borrowing a book from the library; if Harry has locked a file, then Sally cannot make any changes to it. If she tries to lock the file, the repository will deny the request. All she can do is read the file, and wait for Harry to finish his changes and release his lock. After Harry unlocks the file, his turn is over, and now Sally can take her turn by locking and editing.
复制-修改-合并 方案
Here’s an example. Say that Harry and Sally each create working copies of the same project, copied from the repository. They work concurrently, and make changes to the repository first. When Harry attempts to save his changes later, the repository informs him that his file A is out-of-date. In other words, that file A in the repository has somehow changed since he last copoed it. So Harry asks his client to merge any new changes from the repository into his working copy of file A. Chances are that Sally’s changes don’t overlap with his own; so once he has both sets of changes integrated, he saves his working copy back to the repository.
After you’ve made some changes to the files in your working copy and verified that they work properly, Subversion provides you with commands to publish your changes to the other people working with you on your project(by writing to the repository).If other people publish their own changes, Subversion provides you with commands to merge those changes into your working directory(by reading from the repository).