This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature

Version control for non-programmers with Subversion

By Keith R. Fieldhouse on June 08, 2005 (8:00:00 AM)

Share    Print    Comments   

Imagine a utility that lets you make an annotated backup of any of your project files with the click of a mouse or a single command. It would let you review the history of your backups and recover any version you wished. And it would integrate with your file browser and would keep track of files that have changed since your last backup. The utility exists -- Subversion, and its companion program TortoiseSVN, can help you safely manage your files as you work with them.

Subversion is one of a class of programs that has been used by programmers for decades: the source code control system, which developers use to manage changes to program source code. Such software has features that enable large teams to work in a distributed environment on the same files while keeping track of who has done what, and when. But even if you work by yourself on spreadsheets and word processing documents, you can harness the power of Subversion to eliminate the need to litter your directories with files like "forcast.xlsOLD" and "Presentation.docFirstDraft."

To get started with Subversion you'll need to download the latest version from the Subversion Web site. If you're using a Linux system, you should install Subversion from the program repository for your distribution (using apt, yum, or up2date). For Microsoft Windows users, the Subversion team has made a Windows-style installer.

If you are using a Windows system, you should install TortoiseSVN as well. TortoiseSVN allows you to execute Subversion commands directly from the Windows Explorer file manager by adding a set of right-click context menus to your files and folders.

Once you've installed Subversion and TortoiseSVN on your system, you'll need to set up a Subversion repository where the program can keep the copies of the documents that you've "checked in" to its database. Subversion saves only the differences between versions of files that you're storing in its repository, saving space in comparison with keeping multiple copies of the files. Subversion can always recreate any revision of a file.

To create a repository, at a command prompt issue the following command:

svnadmin create --fs-type=fsfs<nobr> <wbr></nobr>/data/SvnRepository

The directory you specify should be an existing empty directory.

Alternatively, using TortoiseSVN, right-click on an empty directory (we'll assume C:\SvnRepository). Select the "TortoiseSVN->Create Repository Here..." menu item. You'll be prompted to select a repository type. As with the command-line example, choose fsfs.

We'll assume that you intend to keep all of your Subversion-controlled documents in a single directory called ProjectDocs. If you'd like to set up more directories to work with Subversion, repeat the setup steps below for each directory in question.

Before Subversion can manage your documents, you must import them into the Subversion repository. To do so, change directory to your ProjectDocs directory. Make sure the directory (and its children) contain only the files you wish to store in the Subversion repository. Issue the following command:

svn import . file:///data/SvnRepository/ProjectDocs

You'll note that we've used a file:// URL to specify a location within the SvnRepository that we created earlier. When you issue this command, you'll be placed in an editor in which you can enter a description of this directory. When you save and exit the editor buffer, all of the files (and subdirectories) in your ProjectDocs directory will be copied into your Subversion repository.

The process with TortoiseSVN is about as simple. Right-click on your ProjectDocs directory and select "TortoiseSVN->Import...". In the resulting dialog, you can browse to the Subversion repository you created and add to the URL the directory within the repository you want to import into. In our example, the URL to import to will be file:///C:/SvnRepository/ProjectDocs. As with the command line, you'll be given an opportunity to describe the change you've made.

When you import a directory into Subversion, it is not converted into what is called a working directory -- that is, a directory that's connected to the Subversion repository and allows you to commit revisions or changes to your documents to the repository. To create a working copy of your ProjectDocs directory, first rename the one you just imported to something like ProjectDocs.presvn. Then issue the following command to check out your working copy:

svn co file:///data/SvnRepository/ProjectDocs ProjectDocs

When you issue this command, Subversion will create a new "working copy" of your ProjectDocs directory. After you've verified that it's complete and correct, you can delete the one that you'd moved out of the way.

To create a working copy with TortoiseSVN, right-click in the directory in which you want to create your working copy and select "Check Out...". You'll need to use the same URL that you used to import the directory (it should be in the drop-down list).

Now any time you make changes to one of the files in your ProjectDocs directory you can "commit" them to the Subversion repository by issuing the command svn commit while in the directory. With TortoiseSVN, right-click on the file or directory you wish to commit and select "Commit...". When you issue the command, Subversion will scan the files in the directory and copy all of the changes you've made to the repository. As with the import command, you'll be given the opportunity add a comment describing the changes you've made. If you want to commit only a particular file, you can pass the name of the file as an argument to the commit command.

Now that you've set up your ProjectDocs directory you can work with your documents as usual. Whenever you reach a point that you'd like to preserve, simply commit the file or the directory. In the future, if you create a new file in your ProjectDocs directory (say NewFile.doc) issue the command svn add NewFile.doc. After that, you can commit the file as usual. TortoiseSVN provides a "TortoiseSVN->Add" context menu for the same purpose.

Whenever you commit anything to your repository, Subversion increments a revision number. You refer to previous versions of your files by this revision number. To see the revisions of a particular file (say MyDoc.doc) execute the command:

svn log MyDoc.doc

This will show you the revisions of your file and the descriptions you entered when you committed the changes. To get an older revision (say 6) of your file, make sure you've committed any changes to the file. Then issue the command:

svn update -r 6 MyDoc.doc

Your current copy of the file will be replaced with the file from back at revision 6 of your repository. When you want the current version back, just issue the update command without the -r option. TortoiseSVN has "Show log<nobr> <wbr></nobr>...", "Update to revision...", and "Update..." context menu items that let you accomplish the same things.

Those are the basics of working with Subversion as a private data management utility. Obviously software that's designed to work with hundreds of files and developers at a time has significantly more features and capabilities. If you'd like to learn more about how Subversion works, the excellent Subversion Book is the place to start.

Day-to-day use of Subversion is easy. Just commit your files whenever you've reached a point that's worth saving and describe the changes that you're committing. It's remarkably liberating to be able to attempt significant changes to a document when you know that it's a simple matter to recover a previous version with a single command or click of the mouse.

Share    Print    Comments   

Comments

on Version control for non-programmers with Subversion

Note: Comments are owned by the poster. We are not responsible for their content.

Wrong URL

Posted by: Anonymous Coward on June 09, 2005 03:50 AM
You got the URL wrong. It's tortoisesvn.tigris.org, not tortisesvn.tigris.org.

#

Detailed installation of Subversion on Windows

Posted by: Anonymous Coward on June 09, 2005 04:17 AM
Here is another resource to install Subversion on Windows with TortoiseSVN, also OpenSSH, and additional pieces.

<a href="http://www.adbdat.net/adbdat/2005/04/01/subversion-installation-on-windows/" title="adbdat.net">Subversion Installation on Windows</a adbdat.net>

#

Questions: svn add (and svn move)

Posted by: The Spoonman on June 09, 2005 05:40 AM

I've been playing around with the idea of using Subversion to maintain my home directory (I read an article from someone who was using CVS on his). Seems to me to be the perfect solution to my issue of having a work and personal laptop and a desktop. Great way to keep them all in sync. It also helps deal with the Mac leaving<nobr> <wbr></nobr>.DS_Store resource fork files all over the place.


However, complexity of use was the main reason I never got around to playing with it seriously. Complexity in the use of the svn add and move commands. Is it necessary to use the svn add command every time I want to create a new file? Can't I just create a new file and commit changes? Won't svn catch that? As a follow-up, does this apply to svn move, as well? Let's say I have a file in one directory, and I want to move it to another...do I need to move the file in explorer (or finder), and then open a command prompt and issue an svn move?


I suppose I could write a wrapper script around the mv command on each box to issue both mv and svn move if it's in my home somewhere. I typically move stuff around using the bash shell, but a lot of times it's just easier to use the GUI (such as selecting a lot of random files).

#

Re:Questions: svn add (and svn move)

Posted by: kirkjobsluder on June 09, 2005 06:01 AM
Is it necessary to use the svn add command every time I want to create a new file? Can't I just create a new file and commit changes? Won't svn catch that?

Not out of the box. The reason is that a lot of processes add files that probably should not be committed to the repository: (latex and source code compilation).

As a follow-up, does this apply to svn move, as well? Let's say I have a file in one directory, and I want to move it to another...do I need to move the file in explorer (or finder), and then open a command prompt and issue an svn move?

You would need a wrapper script for this.

On the other hand, subversion is great if you need to synchronize work directories between different computer systems.

#

Re:Questions: svn add (and svn move)

Posted by: The Spoonman on June 09, 2005 07:50 AM


Thanks for the reply.


Not out of the box. The reason is that a lot of processes add files that probably should not be committed to the repository: (latex and source code compilation).


Just to be clear, then: out of the box, svn will commit pretty much any and all changes I make to a directory, including adding files. It's only if I twiddle with it that I really need to use svn add so that I can make sure that svn only grabs the files I want it to during commit, right?


You would need a wrapper script for this.


Okay, that's what I figured. Part of the holdup on implementing this setup is simply finding the time to reorganize my 2G of personal files so that they're how I want them to start.<nobr> <wbr></nobr>:) That'll cut down on my need to deal with it later.


On the other hand, subversion is great if you need to synchronize work directories between different computer systems.


I say that very thing to myself every night when I go to manually syncronize changes between my work laptop and my stuff at home, or when I go out of town and need to get the pictures I've taken off my laptop and properly placed.<nobr> <wbr></nobr>:)

#

Re:Questions: svn add (and svn move)

Posted by: kirkjobsluder on June 09, 2005 08:58 AM
Just to be clear, then: out of the box, svn will commit pretty much any and all changes I make to a directory, including adding files. It's only if I twiddle with it that I really need to use svn add so that I can make sure that svn only grabs the files I want it to during commit, right?

Ok, this is one of those mildly annoying things about subversion.

<tt>svn add foo/</tt>

will add:
<tt>foo/bar.txt</tt>
<tt>foo/bar.txt~</tt>
<tt>foo/code.c</tt>
<tt>foo/code.o</tt>

However, you must explicitly add new files into the directory.

<tt>touch foo/baz.txt</tt>

Won't add baz.txt to the directory. You need to explicitly do:

<tt>svn add foo/baz.txt;svn commit</tt>

to add it.

Generally, this is a good thing because you don't want generated files to be added to the repository when you do a commit.

So to summarize, when you <tt>svn add</tt> a directory, you add everything in the directory. When you <tt>svn commit</tt> a directory, you only commit the files that had been previously added.

#

Re:Questions: svn add (and svn move)

Posted by: Anonymous Coward on June 09, 2005 03:46 PM
You could use webdav with auto-versionning, like that, as soon as you add a file to your webdav, it's added to svn, as soon as you modify it, the change is commited.

It's guarenteed to send your revision count through the roof, but it'll work (or so say the guys at svn)

#

Re:Questions: svn add (and svn move)

Posted by: Anonymous Coward on June 18, 2005 04:57 PM
instead of rsync and scripting rsync try using "unison" !!
(<a href="http://www.cis.upenn.edu/~bcpierce/unison/" title="upenn.edu">http://www.cis.upenn.edu/~bcpierce/unison/</a upenn.edu>)

#

Re:Questions: svn add (and svn move)

Posted by: richlv on June 13, 2005 09:22 PM
for automatic synchronization i use rsync - single command and my files on laptop ar in sync with those on server or workstation. no versioning, though (but i do nightly backups<nobr> <wbr></nobr>;) )

#

Re:Questions: svn add (and svn move)

Posted by: The Spoonman on June 13, 2005 09:43 PM
I played around with trying rsync. This doesn't work, though, if you've got more than one computer that can update the same data (I have three). You can't determine which one is the latest version, nor whose deletes to "trust".

#

Re:Questions: svn add (and svn move)

Posted by: richlv on June 13, 2005 10:09 PM
there was some do-not-update-newer option, i think, though that's not the best solution.

i currently have scripts that sync either to, either from server - but i have to run them manually, of course.

i don't see a way to handle missing files (deletions) correctly - unless by looking at directory modifying date ? but this would fail if you delete file in one computer and then another on second computer.

as i understand, subversion would be pretty hard to maintain if you work with many files (adding each file ? uh, better rsync with known latest repository).

actually, is there a way to handle this problem gracefully without having systems constantly connected ?
what if you delete a file in one computer and then modify in another one ? what should synchronization software do ?

#

Thank you

Posted by: Anonymous Coward on June 09, 2005 05:42 AM
I have been using Subversion for some time but I still enjoyed the article. It is a great introduction to SVN.

#

Web Client

Posted by: Anonymous Coward on June 09, 2005 06:15 AM
I just wish there was a web client that allowed adding, checking in, and checking out files. I think websvn only allows you to view.

Stephen

#

Thank you!

Posted by: Anonymous Coward on June 10, 2005 12:59 AM
I'm currently writing my thesis in economics, and my thesis directory has already grown too large for my own comfort in an attempt to keep organized. I just played around with Subversion and I must say I'm really, really excited! It could really ease my organization. It also seems really easy to setup and use, a big plus in my world;-)
So, it seems to be just perfect for my needs and I'm absolutely going to use it for the thesis(AND taking backups 'the old way' until I feel secure about Subversion, of course;-)).

Anyway, thanks to the author, and the subversion guys! Great job!

#

cool, thanks

Posted by: Anonymous Coward on June 10, 2005 03:40 AM
I've been in an MS shop for several years been using SourceSafe for work programming.

at home I use 80% Free Software, and have been wanting to do this very thing to my ~/docs folder for ages.

I do have some questions.

I thought there were problems with Binary documents?
Don't I need to set some flag or something to tell it if the document is Binary or Text?
How does Subversion handle Multiple Checkouts?
Can I create my repository on any File System type ie (fat32)
what about my check out folder should that go on my fat32 or ext3 partition?

My main issue is I would want my Repository Avalible for the few times I do boot Windows at home.
So if I create a repository in linux how do I Tell windows about the repository when I reboot?

in Conclusion
Sigh I worry to much...after all its just my Recipe for Black Bean Hummus..:)

#

Re:cool, thanks

Posted by: Anonymous Coward on June 10, 2005 04:28 PM
> I thought there were problems with Binary documents?

No. Subversion recognize automatically binary files.

> How does Subversion handle Multiple Checkouts?

For my experience, subversion handle multiple checkouts and manage conflicts well.

> Can I create my repository on any File System type ie (fat32)

yes

> what about my check out folder should that go on my fat32 or ext3 partition?

There should be no problems...

> if I create a repository in linux how do I Tell windows about the repository when I reboot?

I resolved the problem hosting my repo on www.wush.net

However, I guess you could write your repo on a FAT fs and access the repo from linux and windows.

For other info, see <a href="http://svnbook.red-bean.com/" title="red-bean.com">http://svnbook.red-bean.com/</a red-bean.com>

---
Stefano Spinucci
Italy

#

Re:cool, thanks

Posted by: Anonymous Coward on June 10, 2005 08:22 PM
> I thought there were problems with Binary cuments?
> Don't I need to set some flag or something to tell > it if the document is Binary or Text?

CVS did and needed a flag which would prevent it from touching binary files at all. It would store a brand new copy of binary files for each revision. Subversion automatically detects binary files and uses a special alogithm that is actually designed to save the deltas from binary files. Not exactly sure how it works underneath (would have to look at the source) but it seems to work well.

#

Re:cool, thanks

Posted by: Anonymous Coward on June 14, 2005 02:42 AM
is there any integration with the Konq?
or will I have to do all the checkout checkin stuff via CLI?

#

If you like subversion, read more...

Posted by: Anonymous Coward on June 10, 2005 04:46 PM
Subversion book

<a href="http://svnbook.red-bean.com/" title="red-bean.com">http://svnbook.red-bean.com/</a red-bean.com>

Subversion hosting I tried

<a href="http://www.wush.net/" title="wush.net">http://www.wush.net/</a wush.net>
<a href="http://www.cvsdude.org/" title="cvsdude.org">http://www.cvsdude.org/</a cvsdude.org>
(many more on <a href="http://subversion.tigris.org/project_links.html" title="tigris.org">http://subversion.tigris.org/project_links.html</a tigris.org>)

Subversion links

<a href="http://subversion.tigris.org/project_links.html" title="tigris.org">http://subversion.tigris.org/project_links.html</a tigris.org>

Subversion FAQ

<a href="http://subversion.tigris.org/faq.html" title="tigris.org">http://subversion.tigris.org/faq.html</a tigris.org>

---
Stefano Spinucci
Italy

#

Re:If you like subversion, read more...

Posted by: Anonymous Coward on July 05, 2005 06:42 PM
theres also Projxpert <a href="http://www.projxpert.com/" title="projxpert.com">http://www.projxpert.com/</a projxpert.com>

Samuel.

#

yeah

Posted by: Anonymous Coward on June 10, 2005 11:29 PM
i have the same basic usage that the author described but i use rcs. i.e. i use ci and co to check in and check out from my RCS repository.

rcs is enough for that task.
in linux yes. not in windows

but i may try svn the way the author tells us above just to see and discover svn

#

SVN on Windows

Posted by: Anonymous Coward on June 14, 2005 07:23 AM
I have used Cygwin to create a SVN repositories on Windows. It's simple. Subversion is one of the standard Cygwin packages, so it's easy to install.

#

Subversion may now be accessible via webfolders

Posted by: Anonymous Coward on June 14, 2005 02:34 PM
As of version 1.2, Subversion now supports "auto-versioning", which basically means that integrated DAV clients (like IE's webfolders and the OSX finder) may be clients for subversion. Saving a file in your webfolder, for instance, would correspond to checking in a change. While you cannot view the revision details, this may allow for transparent use from other applications.

I've only performed minimal testing, so I cannot say how well this works.

<a href="http://subversion.tigris.org/svn_1.2_releasenotes.html" title="tigris.org">http://subversion.tigris.org/svn_1.2_releasenotes<nobr>.<wbr></nobr> html</a tigris.org>:
"In informal tests, we've had success reading and writing to Subversion repositories via Windows Web Folders, OS X Finder, Gnome Nautilus, KDE Konqueror, and other DAV clients."

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya