13

I currently commit files to my SVN server (which is located on my web host), and from there I SSH in and export them to the working directory in my htdocs.

As my application gets larger and larger, a full export is a waste of time. How can I only export the files that have been changed?

svn export -r xxxx:HEAD http://svn/

Is a solution I had found, so maybe this can help? How can I automatically get the revision?

Pete
  • 245
  • 2
  • 11
  • A BASH solution to this is here : http://stackoverflow.com/questions/4783362/exporting-only-changed-files-from-subversion-maintaining-directory-structure – AnOldMan Dec 07 '13 at 15:18

8 Answers8

7

I have been using the following Bash script:

for i in $(svn diff --summarize -r 1:2 http://repo_path | awk '{ print $2 }'); do p=$(echo $i | sed -e 's{http://repo_path/{{'); mkdir -p $(dirname $p); svn export $i $p; done 

Similar to hudolejev's solution, it outputs the changes between revisions (1 and 2) in this case and loops over the files and folders.

Loftx
  • 1,760
  • 4
  • 29
  • 50
  • Same question as to hudolejev: Any chances to mix your solution, so it would do the export of only changes files over FTP to a remote server, instead of local path? Need that to get newest version of repository from development server to a FTP server running on customer machine. Thanks in advance... – trejder Jun 26 '12 at 08:47
  • Great, now I just need to edit it to a generic script that would work for the repo I am in, and take revisions numbers as parameters, and I am good to go! – Aqeel Zafar Mar 19 '13 at 11:22
6

This works with the use of Tortoise SVN. I'm not sure it can be done without it.

I had a similar issue where I had made changes to several thousand files (dont ask...it is an inherited problem!) out of 10's of thousands, so I didn't want to upload the whole directory or rely on winscp to correctly match the dates (since this server is in the US and im in AUS).

So I checked-in to SVN then via "Show Log" in Tortoise SVN. I then right-clicked on the most recent revision (although it could be any rev you live) and selected "compare with previous revision". I then selected all the files that appeared (CTRL-A) and right-clicked "export selection to" and BAM all the updated files in correct folder structure are saved and ready for upload.

Martin Brown
  • 24,692
  • 14
  • 77
  • 122
User123342234
  • 1,455
  • 14
  • 17
2

I would do an SVN checkout into a local repositore, and then rsync the changed files into the web root. Or just do the checkout into the webroot and deny access to all .svn directories.

Daniel
  • 27,718
  • 20
  • 89
  • 133
  • 1
    Why you're so sure, that no other possibilities exits? In fact, there are many, even presented among answers here. Bash script, Perl script, using tools like svn2web etc. What makes you so sure, that you have presented all possible options? – trejder Jun 26 '12 at 08:41
  • +1 Okey, there are other possibilities. I changed the answer. – Daniel Jun 28 '12 at 05:24
  • Greate! :] Have a nice day! :] – trejder Jun 29 '12 at 08:14
2

No pure-SVN solution exists that I am aware of, but you can try the following:

svn update | egrep "^(A|U)[ ]+(.*)" | cut -b 2 | xargs -i cp -R "{}" /path/to/public_html

In your working directory, you get an update and parse the output -- svn update.

All files marked with A and U are candidates to copy -- egrep "^(A|U)[ ]+(.*)".

Remove A or U to get the file name -- cut -b 2.

Copy files that changed since your last update -- xargs -i cp -R "{}" /path/to/public_html.

(Sorry for clumsy shell-fu, still learning).

EDIT: Use cut instead of tr (fixed)

hudolejev
  • 5,846
  • 4
  • 22
  • 28
  • 1
    +1 for nice command line. I would create a small bash script from it. This again can be remotely called by using the "putty" "remote command" feature, so you can do the update with a click of an icon on your desktop. – Daniel Jun 08 '10 at 18:05
  • @hudolejev: Any chances to mix your solution, so it would do the export of only changes files over FTP to a remote server, instead of local path? Need that to get newest version of repository from development server to a FTP server running on customer machine. Thanks in advance... – trejder Jun 26 '12 at 08:45
  • For uploads, I'd change the last part to: `xargs -i wput "{}" ftp://server.url/`, or even use SCP: `xargs -i scp -r "{}" server.url:/path/to/whatever`. Haven't tested, just guessing. – hudolejev Aug 30 '12 at 16:13
1

I'm not sure if this is the same problem you're referring to, but when committing files for a web application I'm working on, I've used the svn2ftp.py SVN hook to automatically FTP modified files to a staging server. It was pretty easy to install and I've never had a problem with it.

Cerin
  • 60,957
  • 96
  • 316
  • 522
1

I guess it's similar to an issue I had. Often I needed to ftp to my web server only those files that were changed recently. Rsync was not available on the web server, so I couldn't use it.
There is another one solution I use in my work. I use SVN in combination with Trac that I have installed on my local server. Among of other Trac has a possiblity to show changes between two revisions or introduced in certain changeset. If you've never used Trac, please visit Trac project's home page to browse its repository. It's publicly available.
As an example I expanded the latest stable release (in the moment of writing this post), which is 0.12. The latest revision I can see is 10792. You can click the revision number to display revision log for this branch. Now you can do two things:

  • either select two revisions in Diff column and click View changes button to see differences between them
  • or click a small gear icon in Rev. column to see a changeset related to certain revision (see this page).

In both cases you would see similar page with the list of modified files and nicely formatted changes between the old and the new files. At the bottom of the page you can find links to download differences in two formats: unified diff and zip. The last one is exactly what you need - a zip archive containing only modified files. You can now unzip the archive and easily ftp modified files to a web server. In large projects it really saves time.
If you are not familiar with Trac please refer to Trac's documentation available on project's web pages or if you'd prefer you could get the book Managing Software Development with Trac and Subversion I found really useful.

Marek
  • 11
  • 1
0

A note for any other passersby ... if you'd like the same benefits of @User123342234's solution in working with Tortoise but would prefer not to commit the changes to your shared / remote repository before being able to export them. The same outcome can be achieved by creating a local svn repository using Tortoise (a little known feature). You can then export your remote branch and import it into your local repository. Then export your local modified working copy of the remote repository over the working copy of your local repository and commit it. You can now use "Show Log" on the local repository to export the changes of the commit, all without having to first commit to the shared / remote repository. Not necessarily trivial, but was significantly helpful to me in at least once instance.

LeastOne
  • 370
  • 4
  • 14
0

svn2ftp 0.3 - bash script. free to use, export files to ftp from svn repository. (cheking revisions) files: start.sh - script, settings.properties - svn, ftp, project properties.

  • URL you provided does not exits any more. Does anyone have any knowledge, where this script can be found? I'm asking precisely about svn2ftp, as there are similar tools like svn2web, which I've tried and was not satisfied with the results. – trejder Jun 26 '12 at 08:43