PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

■Chapter 17: Version Control with Subversion ...................................................


developer merges her work into the central repository means that you no longer have to worry about
reconciling multiple strands of development by hand. Even better, you can check out versions of your
codebase based on a date or a label. So when your code reaches a stable point, suitable for showing to a
client as work in progress, for example, you can tag that with an arbitrary label. You can then use that tag to
check out the correct codebase when your client swoops into your office looking to impress an investor.
Wait! There’s more! You can also manage multiple strands of development at the same time. If this
sounds needlessly complicated, imagine a mature project. You have already shipped the first version,
and you’re well into development of version 2. Does version 1.n go away in the meantime? Of course not.
Your users are spotting bugs and requesting enhancements all the time. You may be months away from
shipping version 2, so where do you make and test the changes? Subversion lets you maintain distinct
branches of the codebase. So you might create a bug-fix branch of your version 1.n for development on
the current production code. At key points, this branch can be merged back into the version 2 code (the
trunk), so that your new release can benefit from improvements to version 1.n.


■Note Subversion is not the only version control system available. You might also like to look into Git


(http://git-scm.com/) or Mercurial (http://mercurial.selenic.com/). These are new and increasingly


popular version control systems. Both use a decentralized model.


Let’s get on and look at some of these features in practice.

Getting Subversion


If you are working with a Unix-like operating system (such as Linux or FreeBSD), you may already have a
Subversion client installed and ready to use.
Try typing


$ svn help


from the command line. You should see some usage information that will confirm that you are ready to get
started. If you do not already have Subversion, you should consult your distribution’s documentation. You
will almost certainly have access to a simple installation mechanism such as Yum or Apt.


■Note Throughout this chapter, I denote command line input by displaying it in bold text. A dollar sign ($)


represents the command prompt.


If you get an error message, you may need to download and install Subversion yourself. You can acquire both


source and binaries from http://subversion.apache.org/.


■Note If you'd rather work with a graphical user interface (GUI) instead of the command line, you might want to


take a look at RapidSVN, a cross-platform front-end to Subversion. You can find it at


http://rapidsvn.tigris.org/. If you’re a Windows user, you should also evaluate TortoiseSVN


(http://tortoisesvn.tigris.org/).

Free download pdf