Svn – Tortoise SVN / Subversion push updates to Windows 2008 Server

dedicated-serversvntortoisesvnwindows-server-2008

I am googling like crazy trying to find a solution for this – but not having much luck!

I have TortoiseSVN and Subversion running on my local Windows XP machine. I make changes to my website and commit these locally. I then want to push these changes to the live website. This is hosted on our dedicated server (Windows 2008 Server).

I've spoken to the hosting company who confirmed they do not support SVN and as it's a windows box will not have SSH – so that's not an option.

Is there any software or a method I could use to push just the changes I commit back to my remote server? Or do I have to manually upload the changes using FTP (which I do at the moment which is a pain!)

Thanks for any info!

Best Answer

Side note

Windows-box can have SSH

Hints

You have to read and grok SVN Book anyway, if you want to use Subversion. Chapter 5.3.2 "Implementing Repository Hooks" tells us basics about repository (server-side) hooks (you can use hooks in your repo), later, in "Repository Hooks" discussed more deep. You'll see at post-commit hook for your task

Because you work with TortoiseSVN, you can also use TortoiseSVN client-side hooks (they handle the smaller set of of events, because work with Working Copy, not repository), which can be post-commit also

Anyway, for deploy-hook you have to write non-interactive (preferably) script (ordinary bat-file, PowerShell, exe...), which transfer /some fileset/ from you to final destination and perform some other management on the side of live site.

During planning stage you have to define, which deploy-policy you want (and able) to follow

  • Full sync of WC-state with site (more complex logic, more time on deploy and hence more downtime)
  • Only dumb copy of changed files (less downtime, more pre-processing before deploy, some historical-artifacts not cleaned and site can be not full mirror of WC)

Depending on selected the policy, command(s) of preparing fileset for transfer will differ, as well as a set of operations on the site.

Short summary

TSVN Hook (easy doable than server)

  • Full sync
    • Create ExportDir
    • Export WC to ExportDir
    • Connect to site-host (FTP, SCP, ...)
    • Disable site (?)
    • Delete all versioned (not local data) files in site-tree
    • Upload new site-tree from ExportDir
    • Enable site (?)
    • Disconect
    • Delete ExportDir
  • Copy updates
    • Create ExportDir
    • Get list of affected in last revision (committed now) files with svn log -q -v --limit 1 (+some tricks for getting full localpathes) or with >svn diff --summarize -r PREV:COMMITTED (+ exclude from list D /deleted/ files
    • Copy fileleset to ExportDir
    • Connect to site-host
    • Copy files, overwriting old
    • Disconnect
    • Delete ExportDir

ADD-ON

Lost&Found story

I haven't ready to use recipe for "uploading only changed, in Windows" (I'm lazy and upload full exported WC, when it's needed), but have some ideas.

In these examples I use (part of) my repo http://mayorat.ursinecorner.ru:8088/svn/Hello/trunk/, checkouted into local dir z:\Hello\ with task "upload changed in last commit files into FTP using pure Windows-tools as much as possible"

  • Files in last commit

    z:\Hello>svn log -v -q -l 1

    r33 | lazybadger | 2012-02-28 16:10:41 +0600 (Вт, 28 фев 2012) Changed paths: M /trunk/Hello.en.txt

  • Extract list of affected files - TBD (grep as last resort)

    /trunk/Hello.en.txt

  • Convert filename to local path - TBD

from svn info we are interested in two strings

URL: http://mayorat.ursinecorner.ru:8088/svn/Hello/trunk
Repository Root: http://mayorat.ursinecorner.ru:8088/svn/Hello

URL - Repository Root = /trunk

to which we'll add / and remove this substring from the beginning filename /trunk/Hello.en.txt, Hello.en.txt is file in the root of z:\Hello

  • Copy files into ExportDir (obvious)
  • Cd ExportDir
  • Build script, which will be used Windows FTP-client ftp (read about -s parameter of ftp) in command ftp -s:uploader -i -n ftp-host, something like

user user pass

cd /our/path

mput *.*

bye

  • user command can be changed to using _netrc trick.

  • Mput, if doesn't work recursive, will be replaced with set of put, cd, lcd, mkdir