Listing the affected files in a Subversion revision
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.




