2.2. Creating a Repository

Subversion keeps its information about your code in a database called a repository. To create one of those, find a nice, out-of the way spot on a hard drive somewhere. Ideally, this spot is on a remote server accessible over the network. The next-best case would be to store the repository on a remote hard drive. If neither option is available, then you can set up the repository on the same drive as your Rails project. In a team project, it's important that all team members have access to the repository.

Wherever you put the repository, the first step is to tell Subversion to create the repository with the svnadmin create command. Let's say that you've decided to put the Subversion repository on your local system at /usr/local/subversion. In that case, you can create your repository by entering the following commands:

$ cd /usr/local/subversion
$ svnadmin create ./soupsonline

Just to clarify, the command-line examples in this book should work under most flavors of Linux and under Mac OS X. Windows users will need to either use a Unix shell emulator like Cygwin or just flip the slashes around in the pathnames.

There won't be any text response in the command shell, but Subversion will have created the necessary files to manage an empty code repository in the directory /usr/local/subversion/soupsonline.

By convention, you need to set up three top-level subdirectories — trunk, tags, and branches — for each Subversion project. The trunk directory is for the current code base as it is being worked on live — the code for the project in this book will go in your trunk directory. A branch is an offshoot of your main code that is still receiving changes. A common branch scenario is to create a branch after a release of your software, and apply bug fixes to the branch without affecting the development of your trunk code. A tag is simply a snapshot of the code base at a particular point in time, with a friendly name and no expectation of further development. As far as Subversion is concerned, though, there is no difference between a tag and a branch — the distinction is solely in how they are treated administratively. Because of this, you'll sometimes see suggestions that the three-directory setup is a historical artifact, and that a different organization may be more manageable. However, for the moment, the three directories are the recommended standard, so this project will stick to that structure.

The svn mkdir command will create the directories inside the new repository. You can run this command as follows from anywhere on your file system (replace the <DIR> marker with the absolute path to the top level of your Subversion folder):

$ svn mkdir --message="standard project start" "file:///<DIR>/soupsonline/trunk"
"file:///<DIR>/soupsonline/tags" "file:///<DIR>/soupsonline/branches" Committed revision 1.

The new directories are being referred to as local file URLs rather than as remote pathnames (although Subversion will accept pathnames here as well). If you created your repository on a remote system, you would of course use an http:// or svn:// URL to the new directory depending on how the remote server was configured.

The Committed revision 1. response back from the Subversion server tells you that the change has been accepted, and now Subversion is tracking three directories.

At this point, you have an empty Subversion repository and a Rails application skeleton that don't know about each other's existence. It's time to introduce them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.205.214