Read Part 1
Now that we have already set up a Subversion repository as well as automatic file additions and commits, we need to account for deletions and provide access to versioned data.
When a file is deleted from a Subversion working copy without the proper procedures (which is pretty much what we are going to do) Subversion is shocked not to find the file when checking repository status.
$ svn status /path/to/working/copy
! deleted-file
All we need to do is let Subversion know we want to delete the file using the
svn delete
command. As in the previous installment, a little finagling from a shell script gets the job done.#!/bin/bash
svn status /path/to/working/copy | grep ^\? | cut -c 8- | xargs svn add
svn status /path/to/working/copy | grep ^\! | cut -c 8- | xargs svn delete
svn commit -m "Automatic snapshot" /path/to/working/copy
You may note that now we have two calls to the svn status command. Below the above is rewritten to cache the output of this command in order to improve performance, but I wanted to show this format just once to compare to the previous version of the script.
#!/bin/bash
svn status /path/to/working/copy > /tmp/svn-status.txt
grep ^\? < /tmp/svn-status.txt | cut -c 8- | xargs svn add
grep ^\! < /tmp/svn-status.txt | cut -c 8- | xargs svn delete
svn commit -m "Automatic snapshot" /path/to/working/copy
Unfortunately, without handling file moves and renames through Subversion, they cannot efficiently. A moved or renamed file looks like a missing and new file pair to Subversion.
$ svn status /path/to/working/copy
! old-file-path
? new-file-path
Even though we can't handle this as efficiently as Subversion can, we can still handle it. No additional work is required to handle file renames or moves.
Next time, we will provide access to the versioned file system over the network without the need for clients to use the
svn
command line tool.
3 comments:
Part 3
Thanks for this nice Tutorial!
I haven’t much to say on this time but you do great job and appreciate your blog.
Post a Comment