Showing posts with label Subversion. Show all posts
Showing posts with label Subversion. Show all posts

Subversion Versioning Models

The core mission of a version control system is to enable collaborative editing and sharing
of data. But different systems use different strategies to achieve this. It's important to understand
these different strategies for a couple of reasons. First, it will help you compare and contrast existing version control systems, in case you encounter other systems similar
to Subversion. Beyond that, it will also help you make more effective use of Subversion,
since Subversion itself supports a couple of different ways of working.



The Problem of File Sharing
All version control systems have to solve the same fundamental problem: how will the system allow users to share information, but prevent them from accidentally stepping on each other's feet? It's all too easy for users to accidentally overwrite each other's changes in the repository.

“The problem to avoid”. Suppose we have two coworkers, Harry and Sally. They each decide to edit the same repository file at the same time. If Harry saves his changes to the repository first, then it's possible that (a few moments later) Sally could accidentally overwrite them with her own new version of the file. While Harry's version of the file won't be lost forever (because the system remembers every change), any changes Harry made won't be present in Sally's newer version of the file, because she never saw Harry's changes to begin with. Harry's work is still effectively lost—or at least missing from the latest version of the file—and probably by accident. This is definitely a situation we want to avoid!



The Lock-Modify-Unlock Solution
Many version control systems use a lock-modify-unlock model to address the problem of many authors clobbering each other's work. In this model, the repository allows only one person to change a file at a time. This exclusivity policy is managed using locks. Harry must “lock” a file before he can begin making changes to it. If Harry has locked a file, then Sally cannot also lock it, and therefore cannot make any changes to that file. 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, Sally can take her turn by locking and editing the file.

The problem with the lock-modify-unlock model is that it's a bit restrictive and often becomes a roadblock for users:

• Locking may cause administrative problems. Sometimes Harry will lock a file and then forget about it. Meanwhile, because Sally is still waiting to edit the file, her hands are tied. And then Harry goes on vacation. Now Sally has to get an administrator to release Harry's lock. The situation ends up causing a lot of unnecessary delay and wasted time.

• Locking may cause unnecessary serialization. What if Harry is editing the beginning of a text file, and Sally simply wants to edit the end of the same file? These changes don't overlap at all. They could easily edit the file simultaneously, and no great harm would come, assuming the changes were properly merged together. There's no need for them to take turns in this situation.

• Locking may create a false sense of security. Suppose Harry locks and edits file A, while Sally simultaneously locks and edits file B. But what if A and B depend on one another, and the changes made to each are semantically incompatible? Suddenly A and B don't work together anymore. The locking system was powerless to prevent the problem—yet it somehow provided a false sense of security. It's easy for Harry and Sally to imagine that by locking files, each is beginning a safe, insulated task, and thus they need not bother discussing their incompatible changes early on. Locking often becomes a substitute for real communication.



The Copy-Modify-Merge Solution
Subversion, CVS, and many other version control systems use a copy-modify-merge model as an alternative to locking. In this model, each user's client contacts the project repository and creates a personal working copy—a local reflection of the repository's files and directories. Users then work simultaneously and independently, modifying their private copies. Finally, the private copies are merged together into a new, final version. The version control system often assists with the merging, but ultimately, a human being is responsible for making it happen correctly.

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 same file A within their copies. Sally saves her 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 copied 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; once he has both sets of changes integrated, he saves his working copy back to the repository.

But what if Sally's changes do overlap with Harry's changes? What then? This situation is called a conflict, and it's usually not much of a problem. When Harry asks his client to merge the latest repository changes into his working copy, his copy of file A is somehow flagged as being in a state of conflict: he'll be able to see both sets of conflicting changes and manually choose between them. Note that software can't automatically resolve conflicts; only humans are capable of understanding and making the necessary intelligent choices. Once Harry has manually resolved the overlapping changes—perhaps after a discussion with Sally—he can safely save the merged file back to the repository.

The copy-modify-merge model may sound a bit chaotic, but in practice, it runs extremely smoothly. Users can work in parallel, never waiting for one another. When they work on the same files, it turns out that most of their concurrent changes don't overlap at all; conflicts are infrequent. And the amount of time it takes to resolve conflicts is usually far less than the time lost by a locking system.

In the end, it all comes down to one critical factor: user communication. When users communicate poorly, both syntactic and semantic conflicts increase. No system can force users to communicate perfectly, and no system can detect semantic conflicts. So there's no point in being lulled into a false sense of security that a locking system will somehow prevent conflicts; in practice, locking seems to inhibit productivity more than anything else.

Source of Information : Version Control with Subversion For Subversion 1.5 (Compiled from r3036)

Subversion's Components

Subversion, once installed, has a number of different pieces. The following is a quick overview of what you get. Don't be alarmed if the brief descriptions leave you scratching your head—there are plenty more pages in this book devoted to alleviating that confusion.


svn
The command-line client program.


svnversion
A program for reporting the state (in terms of revisions of the items present) of a working copy.


svnlook
A tool for directly inspecting a Subversion repository.


svnadmin
A tool for creating, tweaking or repairing a Subversion repository.


svndumpfilter
A program for filtering Subversion repository dump streams.


mod_dav_svn
A plug-in module for the Apache HTTP Server, used to make your repository available to others over a network.


svnserve
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.


svnsync
A program for incrementally mirroring one repository to another over a network.


Assuming you have Subversion installed correctly, you should be ready to start. The next two chapters will walk you through the use of svn, Subversion's command-line client program.

Source of Information : Version Control with Subversion For Subversion 1.5 (Compiled from r3036)

Subversion's Features

When discussing the features that Subversion brings to the version control table, it is often
helpful to speak of them in terms of how they improve upon CVS's design. If you're not familiar
with CVS, you may not understand all of these features. And if you're not familiar
with version control at all, your eyes may glaze over unless you first read Chapter 1, Fundamental
Concepts, in which we provide a gentle introduction to version control.

Subversion provides:

Directory versioning
CVS only tracks the history of individual files, but Subversion implements a “virtual”
versioned filesystem that tracks changes to whole directory trees over time. Files and
directories are versioned.



True version history
Since CVS is limited to file versioning, operations such as copies and renames—which
might happen to files, but which are really changes to the contents of some containing
directory—aren't supported in CVS. Additionally, in CVS you cannot replace a versioned
file with some new thing of the same name without the new item inheriting the
history of the old—perhaps completely unrelated—file. With Subversion, you can add,
delete, copy, and rename both files and directories. And every newly added file begins
with a fresh, clean history all its own.



Atomic commits
A collection of modifications either goes into the repository completely, or not at all.
This allows developers to construct and commit changes as logical chunks, and prevents
problems that can occur when only a portion of a set of changes is successfully
sent to the repository.



Versioned metadata
Each file and directory has a set of properties—keys and their values—associated with
it. You can create and store any arbitrary key/value pairs you wish. Properties are versioned
over time, just like file contents.



Choice of network layers
Subversion has an abstracted notion of repository access, making it easy for people to
implement new network mechanisms. Subversion can plug into the Apache HTTP
Server as an extension module. This gives Subversion a big advantage in stability and
interoperability, and instant access to existing features provided by that server—
authentication, authorization, wire compression, and so on. A more lightweight,
standalone Subversion server process is also available. This server speaks a custom
protocol which can be easily tunneled over SSH.



Consistent data handling
Subversion expresses file differences using a binary differencing algorithm, which
works identically on both text (human-readable) and binary (human-unreadable) files.
Both types of files are stored equally compressed in the repository, and differences are
transmitted in both directions across the network.



Efficient branching and tagging
The cost of branching and tagging need not be proportional to the project size. Subversion
creates branches and tags by simply copying the project, using a mechanism similar
to a hard-link. Thus these operations take only a very small, constant amount of
time.



Hackability
Subversion has no historical baggage; it is implemented as a collection of shared C libraries
with well-defined APIs. This makes Subversion extremely maintainable and usable
by other applications and languages.

Source of Information : Version Control with Subversion For Subversion 1.5 (Compiled from r3036)

Subversion's History

In early 2000, CollabNet, Inc. (http://www.collab.net) began seeking developers to write a replacement for CVS. CollabNet offers a collaboration software suite called CollabNet Enterprise
Edition (CEE) of which one component is 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 name “Subversion”, but also with 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. With the help of some well-placed prods from Brian Behlendorf and Jason Robbins of CollabNet, and 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 had the same frustrating experiences with CVS, and welcomed the chance to finally do something about it.

The original design team settled on some simple goals. They didn't want to break new ground in version control methodology, they just wanted to fix CVS. They decided that Subversion would match CVS's features, and preserve the same development model, but not duplicate CVS's most obvious flaws. And although it did not need to be a drop-in replacement for CVS, it should be similar enough that any CVS user could make the switch with little effort.

After fourteen months of coding, Subversion became “self-hosting” on August 31, 2001. That is, Subversion developers stopped using CVS to manage Subversion's own source code, and started using Subversion instead.

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. Collab-Net's copyright license is fully compliant with the Debian Free Software Guidelines. In other words, anyone is free to download, modify, and redistribute Subversion as he pleases; no permission from CollabNet or anyone else is required.

Source of Information : Version Control with Subversion For Subversion 1.5 (Compiled from r3036)

Is Subversion the Right Tool?

If you're a user or system administrator pondering the use of Subversion, the first question you should ask yourself is: "is this the right tool for the job?" Subversion is a fantastic hammer, but be careful not to view every problem as a nail.

If you need to archive old versions of files and directories, possibly resurrect them, or examine logs of how they've changed over time, then Subversion is exactly the right tool for you. If you need to collaborate with people on documents (usually over a network) and keep track of who made which changes, then Subversion is also appropriate. This is why Subversion is so often used in software development environments — programming is an inherently social activity, and Subversion makes it easy to collaborate with other programmers. Of course, there's a cost to using Subversion as well: administrative overhead. You'll need to manage a data-repository to store the information and all its history, and be diligent about backing it up. When working with the data on a daily basis, you won't be able to copy, move, rename, or delete files the way you usually do. Instead, you'll have to do all of those things through 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, 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". There are simpler tools that efficiently replicate data without the overhead of tracking.

Source of Information : Version Control with Subversion For Subversion 1.5 (Compiled from r3036)

What is Subversion?

Subversion is a free/open-source version control system. 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 can operate across networks, which allows it to be used by people on different computers. At some level, the ability for various people to modify and manage the same set of data from their respective locations fosters collaboration. Progress can occur more quickly without a single conduit through which all modifications must occur. And because the work is versioned, you need not fear that quality is the trade-off for losing that conduit—if some incorrect change is made to the data, just undo that change. 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.

Source of Information : Version Control with Subversion For Subversion 1.5 (Compiled from r3036)


Subscribe to Developer Techno ?
Enter your email address:

Delivered by FeedBurner