11.07.2015 Views

Version Control with Subversion - Login

Version Control with Subversion - Login

Version Control with Subversion - Login

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Advanced TopicsNow, as is common in graphic design work, there's a change in plans, which causes thecar's color to be a concern. So Sally updates her working copy to HEAD, fires up her photoeditingsoftware, and sets about tweaking the image so that the car is now cherry red.Meanwhile, Harry, feeling particularly inspired that day, decides that the image would havegreater impact if the car also appears to have suffered greater impact. He, too, updates toHEAD, and then draws some cracks on the vehicle's windshield. He manages to finish hiswork before Sally finishes hers, and after admiring the fruits of his undeniable talent, hecommits the modified image. Shortly thereafter, Sally is finished <strong>with</strong> the car's new finishand tries to commit her changes. But, as expected, <strong>Subversion</strong> fails the commit, informingSally that her version of the image is now out of date.Here's where the difficulty sets in. If Harry and Sally were making changes to a text file,Sally would simply update her working copy, receiving Harry's changes in the process. Inthe worst possible case, they would have modified the same region of the file, and Sallywould have to work out by hand the proper resolution to the conflict. But these aren't textfiles—they are binary images. And while it's a simple matter to describe what one wouldexpect the results of this content merge to be, there is precious little chance that any softwareexists that is smart enough to examine the common baseline image that each ofthese graphic artists worked against, the changes that Harry made, and the changes thatSally made, and then spit out an image of a busted-up red Mustang <strong>with</strong> a cracked windshield!Of course, things would have gone more smoothly if Harry and Sally had serialized theirmodifications to the image—if, say, Harry had waited to draw his windshield cracks onSally's now-red car, or if Sally had tweaked the color of a car whose windshield wasalready cracked. As is discussed in the section called “The Copy-Modify-Merge Solution”,most of these types of problems go away entirely where perfect communication betweenHarry and Sally exists. 7 But as one's version control system is, in fact, one form of communication,it follows that having that software facilitate the serialization of nonparallelizableediting efforts is no bad thing. This is where <strong>Subversion</strong>'s implementation of the lockmodify-unlockmodel steps into the spotlight. This is where we talk about <strong>Subversion</strong>'slocking feature, which is similar to the “reserved checkouts” mechanisms of other versioncontrol systems.<strong>Subversion</strong>'s locking feature exists ultimately to minimize wasted time and effort. By allowinga user to programmatically claim the exclusive right to change a file in the repository,that user can be reasonably confident that any energy he invests on unmergeable changeswon't be wasted—his commit of those changes will succeed. Also, because <strong>Subversion</strong>communicates to other users that serialization is in effect for a particular versioned object,those users can reasonably expect that the object is about to be changed by someoneelse. They, too, can then avoid wasting their time and energy on unmergeable changesthat won't be committable due to eventual out-of-dateness.When referring to <strong>Subversion</strong>'s locking feature, one is actually talking about a fairly diversecollection of behaviors, which include the ability to lock a versioned file 8 (claiming the exclusiveright to modify the file), to unlock that file (yielding that exclusive right to modify), tosee reports about which files are locked and by whom, to annotate files for which lockingbefore editing is strongly advised, and so on. In this section, we'll cover all of these facetsof the larger locking feature.The Three Meanings of “Lock”In this section, and almost everywhere in this book, the words “lock” and “locking” describea mechanism for mutual exclusion between users to avoid clashing commits.Unfortunately, there are two other sorts of “lock” <strong>with</strong> which <strong>Subversion</strong>, and thereforethis book, sometimes needs to be concerned.7 Communication wouldn't have been such bad medicine for Harry and Sally's Hollywood namesakes, either, forthat matter.8 <strong>Subversion</strong> does not currently allow locks on directories.63

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!