If you have no idea what Subversion is, or how to install Subversion, or how to add photos to a Subversion repository, please read Organize and version control digital photos with Subversion (basic) first. Here we are going to discuss some advanced topics.
Recommended folder layout
Subversion has no restriction on the folder layout in the repository. What folder layout to choose is totally up to you. The Subversion documentation recommends creating a "trunk" and a "branches" folder at the root of the the repository. Here's a folder layout I use:
|-trunk
| |-20070901
| \-20080304
\-branches
|-web
| |-20070901
| \-20080304
\-printing
|-20070901
\-20080304I keep the maximum-size photos in the "trunk" folder. When I need to resize or crop some photos, for example, for posting on my website, I do the converting job and then put the converted photos in the "branches" folder.
Move/Rename photos
Suppose you followed the instructions in Organize and version control digital photos with Subversion (basic) and created such a folder layout:
|-20070901
\-20080304How do you convert this layout to the one recommended above? Here you need the "move" command. You can follow these commands:
D:
cd \photo
svn mkdir trunk
svn mkdir branches
svn move 20070901 trunk\
svn move 20080304 trunk\
svn commit -m "move photos into trunk\"The "mkdir" command is used for making a new folder. If you encounter an error committing the changes (the last command), try to run
svn updatethen commit again.
You can also use the "move" command to rename files and folders. Don't forget to commit the changes to the repository.
Making branches
There's more than one way to do this. Here's my way to make a web posting branch:
- Make a copy from the trunk to the branches folder. Execute:
D:
cd \photo
svn mkdir branches\web
svn copy trunk\20070901 branches\web[/code]- Convert all photos in D:\photo\branches\web\20070901. I use a PHP script calling ImageMagick to do this job. Here's my php script:
<?php
$resDir = opendir(".");
while (($strFile = readdir($resDir)) !== false) {
if (is_dir($strFile)) continue;
system("convert ".$strFile." -resize 520x520 ".$strFile);
}
?>First make sure PHP CLI and ImageMagick are installed properly. Then put the php script in D:\photo\branches\web\20070901, and execute the script. The photos will then all be resized with the longer side 520px. You can also use another script language to achieve the same effect.
- Run "svn commit" to commit the changes to the repository.
Backup the photo repository
To backup the repository, use this command:
svnadmin dump --deltas file:///d:/repos/photo > D:\backup\photo.bakHere "--deltas" is an option for saving disk space. D:\backup\photo.bak is the backup file.
Restore the photo repository from a backup file
Suppose you want to restore D:\backup\photo.bak to the repository D:\repos\photo_new. Execute:
svnadmin load file:///d:/repos/photo_new < D:\backup\photo.bakMigration
Simply backup the repository and restore it somewhere else.
Summary
We show the above examples in order to demonstrate the usage of these Subversion commands:
svn mkdir (make a new folder)
svn move (move files/folders)
svn copy (copy files/folders)
svnadmin dump (backup a repository)
svnadmin load (restore a repository)To totally master Subversion, you are recommended to read more on Version Control with Subversion.
Last edited by Wen at 2008-11-08 11:11:28
- Convert all photos in D:\photo\branches\web\20070901. I use a PHP script calling ImageMagick to do this job. Here's my php script:
User login





