ONLamp.com
oreilly.comSafari Books Online.Conferences.

advertisement


Accessing Secure Subversion Servers
Pages: 1, 2, 3

More svn commands

You can also delete files. However, don't use rm to do so. The proper method is svn delete:



% ls
apache	default.php	en	test

% svn delete test
D	test

% ls
apache	default.php	en

See how svn removed that file from my working copy? The D also indicates that issuing a commit will delete the file from the repository:

% svn commit -m "removed test file"
Deleting	test
Committed revision 4.

Why is it showing revision 4 when I'm at revision 2? Because someone else has committed a change since the last time I ran svn update. Let's see what it is:

% svn update
U frameset.html
Updated to revision 4.

Note that a new (added) file starts with A, a deleted file starts with D, and a modified (updated) file starts with U. Someone else modified the file frameset.html before I committed my change. svn log would tell me who, and I would see that my change was revision 4 and the other person's change was revision 3.

I could get exact details on the file's modifications by issuing a diff on revision 3:

% svn diff -r 3
Index: en/frameset.html
=================================================================
--- en/frameset.html (revision 3)
+++ en/frameset.html (working copy)
@@ -2,10 +2,10 @@
<snip>
-<frameset rows="21%, 79%" border="0">
+<frameset rows=27%,73%" border="0">
<snip other changes>

You'll see that this is like any diff output. In this snippet, a single line has changed from its original values of 21 percent and 79 percent to new values of 27 percent and 73 percent.

If you wish to modify an existing file, simply make your edits. You don't have to svn add, as the file already exists. When you issue your next svn commit, your modifications will upload to the repository. Do remember to add a useful message to remind yourself and others of the edits you made.

Summary of svn commands

Here are the commands you'll use most often:

  • svn update--Always do this before changing your working copy or if a commit indicates a higher revision number than you were expecting.

  • svn add--Whenever you create a file; you have to create the file before you can add it.

  • svn delete--When you wish to delete a file. (Don't use rm in your working copy!)

  • svn commit--To upload your changes. Include -m with a message; otherwise, svn will open the vi editor so you can add your comments to the log.

  • svn log--To view the log of changes.

  • svn diff -r #--To see details of the changes made by the specified revision.

Chapter 9 of the SVN book gives details and examples for all of the svn commands.

Installing and Using a GUI

I originally planned to use esvn as the GUI, but found that the current version truncated the name of the repository, which made it impossible to use any svn commands. However, I had good luck with rapidsvn.

Installing on FreeBSD was a simple matter of:

# pkg_add -r rapidsvn

There are also binaries available as a Debian .deb, a Red Hat RPM, and a Windows installer.

Once devel2 had keychain set up and working, I had him open up rapidsvn and choose Checkout from the Repository menu. (Figure 1). He typed the same URL that devel1 had used at the command line, and chose to save his working copy as www. Selecting Add to Bookmarks ensures that the copy will show up as a tree in the left pane.

Thumbnail, click for full-size image.
Figure 1. Checking out with rapidsvn--click for full-size image

Once he had a working copy, devel2 went into the View menu and chose Preferences, then Programs. Here he defined his favorite editor and file explorer. That made it very easy for him to navigate between existing files on his system and his working copy.

The Modify menu contains the most often used svn commands. Each has either a Ctrl-letter or a function key shortcut for quick access. Once devel1 learned how to use the various svn commands, he quickly became comfortable with the interface and was able to return to his real work of web development.

Summary

svn provides a feature-rich yet easy-to-learn method for sharing a project's files between users. Edits are simple to track, and if need be, users can revert any file to an earlier revision. While I've covered the most used commands in this article, refer to the Subversion web site for more information on how to get the most out of your repository.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.


Read more FreeBSD Basics columns.

Return to the BSD DevCenter

Return to O'Reilly SysAdmin



Sponsored by: