Linux and SVN: Need a shelll script to transfer updated files to test server after making an svn update

878 Views Asked by At

The task/problem is: We wish to follow a proper development methodology using SVN. The projects will be in PHP, Apache server and Linux OS. The process should be as

  1. Developers work on the code on their local copy(local machine). The local copy is linked with the SVN repo(our own svn repository)
  2. For every completed task, there is a SVN commit.
  3. There is middle-layer server, which has the code from the same SVN repo. This layer is used only to get SVN updates from the repo and then transfer the updated files to the Test Server.

Note: There are multiple test servers for multiple projects. The middle-layer will be common between all the projects. The destination test server where the updated files are to be transfered will be decided here.

I need help for step 3.

How to get/maintain a list of all the updated files for different projects. Then a shell script to select the source dir(on the middle layer) and the dest dir(test server) and then rsync all the updated files on the test server. All the servers are on the same network.

1

There are 1 best solutions below

0
On

I have to agree with H2CO3's comment. Having said that, it is possible to achieve what you need with svn:

svn merge -r BASE:HEAD --dry-run .

will give you a list of all files which have been updated since the last svn update. With the help of sed, awk, or perl you could then easily munge this into an include list suitable for consumption by rsync. Here's another similar command which may be of use but which is much more verbose and harder to parse:

svn log -r BASE:HEAD -v

However I would question whether rsync is the right tool for the job here. Why not just use svn directly on the test server? Why do you even need the server in the middle? You already said that all servers are on the same network, so perhaps you have an extra requirement which you didn't state?

Finally, I would strongly recommend that you look at git-svn. There are loads of good introductory articles online to help with this, and so much more becomes possible when you have git at your finger tips. I happily used git-svn for over a year of collaboration with a team who were mostly stuck on svn, and they would have been none the wiser if I hadn't told them what I was doing. (I also eventually converted them to git, but that's another story :-)