PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 17 ■ VERSION CONTROL WITH SUBVERSION

Adding megaquiz/trunk/megaquiz.orig/trunk/src
Adding megaquiz/trunk/megaquiz.orig/branches
Adding megaquiz/trunk/megaquiz.orig/tags
Adding megaquiz/branches
Adding megaquiz/quiztools
Adding megaquiz/quiztools/AccessManager.php
Adding megaquiz/main.php
Adding megaquiz/command
Adding megaquiz/command/Command.php
Adding megaquiz/command/FeedbackCommand.php
Adding megaquiz/command/CommandContext.php
Adding megaquiz/command/LoginCommand.php
Adding megaquiz/tags
Committed revision 1.


Now that you have imported your project, you should move your source directory out of the way. If
you’re feeling bold, you could delete it; otherwise rename it. I generally add the extension .orig to the
directory name:


$ cd ..
$ mv megaquiz megaquiz.orig


An important point to remember here is that importing a project does not in any way transform the
source directory. If you want to use version control, you must check out your project from the repository
after you have imported it. You can check out a project with the checkout subcommand.


$ svn checkout svn+ssh://localhost/var/local/svn/megaquiz/trunk megaquiz-trunk


Remember, the dollar sign at the beginning of the line represents the shell prompt. The rest of the
line is what a user might type. Subversion will re-create the trunk directory in a new directory named
megaquiz-trunk, reporting as it does so:


A megaquiz-trunk/megaquiz.orig
A megaquiz-trunk/megaquiz.orig/trunk
A megaquiz-trunk/megaquiz.orig/trunk/pkg
A megaquiz-trunk/megaquiz.orig/trunk/src
A megaquiz-trunk/megaquiz.orig/branches
A megaquiz-trunk/megaquiz.orig/tags
Checked out revision 1.


If you look into the newly created megaquiz-trunk directory, you will see that it, and all of its
subdirectories, contain a folder called .svn. This contains metadata about your project and its
repository. You can pretty much ignore the .svn directories, but you should not delete any of them.
Now that you have a sandbox set up, it is time to start work. You can edit and save your files as
normal, but remember, you are no longer alone! You need to keep your work synchronized with the
central repository, or you will lose the benefits afforded by Subversion.

Free download pdf