Listing the affected files in a Subversion revision

24 November 2009 | Matt Perdeaux |

A quick trick that I'm finding very useful for those little deployments that don't require a full export of the Subversion repository. A little regex on the standard verbose output of the Subversion log like so:


svn log -r HEAD -v | egrep '^ +[A-Z]'


will output a list of the files included in the specified revision, e.g.:


M /trunk/apps/Feedback/views.py
A /trunk/fabfile.py


The letters "A", "M" or "D" denote whether the file was added, modified or deleted.

A little bit of Python looping and manipulation later, and there's a very nice little code snippet:


pipe = os.popen("svn log -r "HEAD -v | egrep '^ +[A-Z]'")

lstUpload = []
lstRemove = []
for i in pipe.readlines():
  file = i.strip().replace('/trunk/','').split(' ')
  if file[0] == 'A' or file[0] == 'M': lstUpload.append(file[1])
  if file[0] == 'D': lstRemove.append(file[1])


Which gives us a list of files to upload to the live server, and a list of files to delete from it. Very quick and easy - bung it in your Fabric script and rest easy pilgrim.


Add a comment

  Your name is required.
  Your email address is required.
        

  Please enter the answer in figures (type 12 NOT twelve).
 
  NB - We will not publish or disclose your email address to third parties. We require it so we can check you're not a nasty spambot, and so we can display your Gravatar if you have one. Apologies for the little arithmetic test, but we've been having terrible trouble with comment spam.

Matt's latest tweets

Loading...

Latest blog entries

Blog archive

Categories


www.associativetrails.com