You are not logged in.

#1 2009-12-10 14:07:05

deicist
Member
Registered: 2009-03-17
Posts: 36

simple 'create a patch from subversion' script

This script was written for a specific use, in a specific environment:

here's the setup:

You have a (development) PHP project under subversion source control, and another, un-versioned (live) copy.  You make changes to the development version, committing them to the repository as you go, until you're happy with your changes, then you want to copy any files that have changed since revision X (the last time you moved things across) from the development project into the live site.

This script gets any modified / added files from revision X upwards from the repository and puts them (preserving the directory structure) into a directory called 'patch-rX'.  You can then just drop these into your live site to 'patch' it to the latest revision.

It's not particularly elegant, and it doesn't deal with files that are removed from the repository (I'd have to parse the 'status' bit of each line, find out what's happened to the file and so-on) but as a quick and dirty hack it works quite well.

run it like this:

make patch.sh REVISION URL

where REVISION is the lowest revision number to get changes from and URL is the url of your repository.

#!/bin/bash
#make patch.sh
#by Paul B
#tall_paulb@hotmail.com
#simple script to make a very simple patch from a repository
#call with make patch.sh REVISION URL
#REVISION should be the lowest revision to get changes from, script gets all changes from REVISION to HEAD
#URL is the url of your repository
#eg: make patch.sh 750 svn://redmine.tyrrellsystems.com/tms/tms_dev/Trunk


#first we need to get a list of changes since requested revision 
svn diff -r$1 $2 --summarize > filelist.txt

#now remove the repo information from each line, so we're just left with the path from the root upwards
sed -i "s#$2# #g" filelist.txt
sed -i "s#M  # #g" filelist.txt
sed -i "s#A  # #g" filelist.txt

#now loop through what we've got
#create the relevant folder, and export the file into it
for i in $(cat filelist.txt); 
do 
    filename=$(basename $i);
    path=$(dirname $i);
    mkdir -p patch-r$1/$path 
    svn export --force $2/$path/$filename patch-r$1/$path/$filename
    echo "$filename"; 
done

Offline

#2 2009-12-10 21:57:08

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: simple 'create a patch from subversion' script

This sounds similar to svn-export. Perhaps you would find that useful as well.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB