bubaflub has asked for the wisdom of the Perl Monks concerning the following question:

Problem: The hosting company (Mosso) that our clients are on does not offer shell access, only FTP. We would like to use subversion to keep all files under source control with each website having a separate repository. (Changing to Mercurial or Bazaar is not an option.)

Failed solution: Initially I worked on a post-commit hook script that would upload the most recently updated files. My co-worker mentioned that often times the changes made in one revision shouldn't be made "live" and this script would lack the control to upload multiple revisions.

Possibilities: Since I need to generate a list of files that have been changed, I can get that information from two places: svn log or svn diff. svn log is helpful because it can be exported as XML and will tell me when files have been moved. svn diff is useful because there is a --summarize option that will "flatten" the output - files modified across multiple revisions will be listed only once with the final change.

Snags: As alluded to earlier, I need to be able to identify files that have been moved, as svn diff may just show the file as deleted and added again elsewhere. This isn't a huge problem until the files are huge (such as flash movies). But I also need to "flatten" the changes, that is, if a file has been modified in two revisions, it only needs to be updated once. svn log only shows the modifications per revision and will not "flatten" the log.

Further considerations: Using FTP to recursively add, delete, and rename directories could be problematic. Also, I don't want to clobber files in the event that they have been updated outside the source control - perhaps checking the last revision date and/or file size (which is problematic if the file was uploaded in ASCII mode and not binary).

Questions: Is there some obvious / easier approach I should be taking? Does anyone have any recommendations on how to go about this?

I'm really appreciative of anyone who took time to read this, and will accept anything from full blown scripts to code snippets to suggestions of "best practices" to harsh rebukes.

Thanks,
Bob

Replies are listed 'Best First'.
Re: Automate SVN and FTP
by moritz (Cardinal) on May 06, 2008 at 17:25 UTC
    Take a look at rsync, it can transfer files over ftp.

    If that doesn't work well for you (and nobody else has a very good recommendation), don't work around it. Switch that freakin' hosting company (or ask the old one if you can get shell access+svn for a few more bucks). It just doesn't pay off to build (possible fragile) solutions around crappy systems. A decent hosting package with shell access isn't that expensive anymore, and it can save you loads of troubles.

Re: Automate SVN and FTP
by Herkum (Parson) on May 06, 2008 at 18:03 UTC

    I agree with moritz, don't spend too much time fooling around with a crappy vendor or a limited environment. You will waste more time trying to work around their limitations than you need too.

    I think this is one of the first, and hardiest lessons to learn as a programmer, fix the environment rather fix your program. Your life will be some much easier.

      Herkum and moritz,

      Thank you for the quick responses!

      I would, of course, prefer a hosting environment with shell access. It's not because Mosso (which is owned and operated by Rackspace) is technologically inadequate, but because they host across a homogeneous cluster - both IIS and Apache (as well as ASP, .NET, PHP4 & 5, Perl, Ruby on Rails) on Windows and Linux - that there is no shell access. I imagine that my files are sitting somewhere on a NAS and mounted across multiple machines.

      That being said, I am technologically constrained by the higher-ups - Mosso and SVN are non-negotiable.

      I'm open to hearing how I could use rsync as part of the "tool chain" - will it take care of the recursive directory and FTP clobbering issues?

      Thanks,
      Bob

        I'm open to hearing how I could use rsync as part of the "tool chain" - will it take care of the recursive directory and FTP clobbering issues?

        I think it will do all the work for you. I have never used it over FTP before, but so far it has never disappointed me ;-)

        Just read the man page and play with it a bit, it's really a great tool for one-way synchronizations.

Re: Automate SVN and FTP
by Issac (Initiate) on Jan 18, 2011 at 12:38 UTC
    I've tried http://svn2ftp.com and it does exactly what you need. It's a hosted SVN repository system which automatically will sync to FTP accounts on each commit. You can switch between dev/live too